You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bhaarat Sharma <bh...@gmail.com> on 2008/03/27 13:54:50 UTC

Struts 1 Javascript Question

Hello

I am using struts 1 to show a link to the user like this
<html:link
                    page="/editProjectMonitor.do" paramId="report_id"
paramName="report"
                    paramProperty="reportId" target="_blank">
                Edit</html:link>

However I want this link to open up from Javascript instead! For javascript
I have a code like the following

function openPopup() {
windowReference = window.open('/cmrs/editProjectMonitor.do?report_id=<%=WHAT
TO PUT HERE? SO I CAN GETT report_id value%>','windowName');
if (!windowReference.opener)
windowReference.opener = self;
}

what can i pass so that report_id value will come. I know in struts2 I could
have used the s:property tag...is there something similar in struts1?

Thanks!!

Re: Struts 1 Javascript Question

Posted by Laurie Harper <la...@holoweb.net>.
bhaarat Sharma wrote:
> Hello
> 
> I am using struts 1 to show a link to the user like this
> <html:link
>                     page="/editProjectMonitor.do" paramId="report_id"
> paramName="report"
>                     paramProperty="reportId" target="_blank">
>                 Edit</html:link>
> 
> However I want this link to open up from Javascript instead! For javascript
> I have a code like the following
> 
> function openPopup() {
> windowReference = window.open('/cmrs/editProjectMonitor.do?report_id=<%=WHAT
> TO PUT HERE? SO I CAN GETT report_id value%>','windowName');
> if (!windowReference.opener)
> windowReference.opener = self;
> }
> 
> what can i pass so that report_id value will come. I know in struts2 I could
> have used the s:property tag...is there something similar in struts1?

Antonio is right, the onclick attribute is probably the easiest way to 
do this, but to answer the question: you can use an EL expression if you 
have them available, as in:

   ...window.open('...?report_id=${report.reportId}'

or, if you don't have JSTL available in your container, you can use the 
bean:write tag:

   ...window.open('...?report_id=<bean:write name="report"
  		property="reportId"/>'

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 1 Javascript Question

Posted by Antonio Petrelli <an...@gmail.com>.
2008/3/27, bhaarat Sharma <bh...@gmail.com>:
> Hello
>
>  I am using struts 1 to show a link to the user like this
>  <html:link
>                     page="/editProjectMonitor.do" paramId="report_id"
>  paramName="report"
>                     paramProperty="reportId" target="_blank">
>                 Edit</html:link>
>
>  However I want this link to open up from Javascript instead!


Oh, the lazyness...
http://struts.apache.org/1.x/struts-taglib/tlddoc/html/link.html
The <html:link> has a "onclick" attribute. Imagine what's this for?

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org