You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by panpan <xi...@yahoo.com> on 2007/11/27 18:47:16 UTC

S2: concat doesn't work.

In one of my JSP page, I have javascript section
<code>
 <script type="text/javascript">
     var name = '<s:property value="additionalInterests[1].bankName"/>';
     alert("Name: " + name);
 </script></code>
It's working. I can see the valud of the Name.


But the below is not working if replace 1 with a variable
<code>
 <script type="text/javascript">
    var number = 1;
     var name = '<s:property
value="additionalInterests['+number.toString()+'].bankName"/>';
     alert("Name: " + name);
 </script></code>

The result is empty.

Thanks for your helps!
-- 
View this message in context: http://www.nabble.com/S2%3A-concat-doesn%27t-work.-tf4883302.html#a13975923
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: S2: concat doesn't work.

Posted by panpan <xi...@yahoo.com>.
Hi David,

Thank you for your explaination. I just started to work on Javascript
recently and have lots of things to learn.

Why is the first example working? It's a Struts2 tag insice the Javascript.
There are not much differences between the first example and the second
example except the second example replace 1 with a variable. But the
variable belongs to javascript. I guess i'm really confused.

appreciate your time,
panpan

Hernandez, David wrote:
> 
> 
> You're getting confused about the role of Javascript in your
> application, panpan. Javascript does not execute at the same time as
> Java. Java can generate dynamic javascript on the server and send it to
> a client. The javascript then executes on the client (web browser). You
> cannot have javascript code evaluated inside your Java expressions as
> per your example.
> 
> -----Original Message-----
> From: panpan [mailto:xiili@yahoo.com] 
> Sent: Tuesday, November 27, 2007 12:47 PM
> To: user@struts.apache.org
> Subject: S2: concat doesn't work.
> 
> 
> In one of my JSP page, I have javascript section <code>  <script
> type="text/javascript">
>      var name = '<s:property value="additionalInterests[1].bankName"/>';
>      alert("Name: " + name);
>  </script></code>
> It's working. I can see the valud of the Name.
> 
> 
> But the below is not working if replace 1 with a variable <code>
> <script type="text/javascript">
>     var number = 1;
>      var name = '<s:property
> value="additionalInterests['+number.toString()+'].bankName"/>';
>      alert("Name: " + name);
>  </script></code>
> 
> The result is empty.
> 
> Thanks for your helps!
> --
> View this message in context:
> http://www.nabble.com/S2%3A-concat-doesn%27t-work.-tf4883302.html#a13975
> 923
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - -
> 
> This message is intended only for the personal and confidential use of the
> designated recipient(s) named above.  If you are not the intended
> recipient of this message you are hereby notified that any review,
> dissemination, distribution or copying of this message is strictly
> prohibited.  This communication is for information purposes only and
> should not be regarded as an offer to sell or as a solicitation of an
> offer to buy any financial product, an official confirmation of any
> transaction, or as an official statement of Lehman Brothers.  Email
> transmission cannot be guaranteed to be secure or error-free.  Therefore,
> we do not represent that this information is complete or accurate and it
> should not be relied upon as such.  All information is subject to change
> without notice.
> 
> --------
> IRS Circular 230 Disclosure:
> Please be advised that any discussion of U.S. tax matters contained within
> this communication (including any attachments) is not intended or written
> to be used and cannot be used for the purpose of (i) avoiding U.S. tax
> related penalties or (ii) promoting, marketing or recommending to another
> party any transaction or matter addressed herein.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/S2%3A-concat-doesn%27t-work.-tf4883302.html#a13976563
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: S2: concat doesn't work.

Posted by "Hernandez, David" <da...@lehman.com>.
You're getting confused about the role of Javascript in your
application, panpan. Javascript does not execute at the same time as
Java. Java can generate dynamic javascript on the server and send it to
a client. The javascript then executes on the client (web browser). You
cannot have javascript code evaluated inside your Java expressions as
per your example.

-----Original Message-----
From: panpan [mailto:xiili@yahoo.com] 
Sent: Tuesday, November 27, 2007 12:47 PM
To: user@struts.apache.org
Subject: S2: concat doesn't work.


In one of my JSP page, I have javascript section <code>  <script
type="text/javascript">
     var name = '<s:property value="additionalInterests[1].bankName"/>';
     alert("Name: " + name);
 </script></code>
It's working. I can see the valud of the Name.


But the below is not working if replace 1 with a variable <code>
<script type="text/javascript">
    var number = 1;
     var name = '<s:property
value="additionalInterests['+number.toString()+'].bankName"/>';
     alert("Name: " + name);
 </script></code>

The result is empty.

Thanks for your helps!
--
View this message in context:
http://www.nabble.com/S2%3A-concat-doesn%27t-work.-tf4883302.html#a13975
923
Sent from the Struts - User mailing list archive at Nabble.com.


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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.



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


Re: S2: concat doesn't work.

Posted by panpan <xi...@yahoo.com>.
Thanks, Dave. That explains the problem I had for this example. 

newton.dave wrote:
> 
> --- panpan <xi...@yahoo.com> wrote:
>> But the below is not working if replace 1 with a
>> variable
>> <code>
>>  <script type="text/javascript">
>>     var number = 1;
>>      var name = '<s:property
>>
> value="additionalInterests['+number.toString()+'].bankName"/>';
>>      alert("Name: " + name);
>>  </script></code>
> 
> JavaScript is executed *AFTER* your JSP is compiled.
> 
> I'd recommend looking in to the way browsers/HTTP work
> a bit.
> 
> d.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/S2%3A-concat-doesn%27t-work.-tf4883302.html#a13976588
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: S2: concat doesn't work.

Posted by Dave Newton <ne...@yahoo.com>.
--- panpan <xi...@yahoo.com> wrote:
> But the below is not working if replace 1 with a
> variable
> <code>
>  <script type="text/javascript">
>     var number = 1;
>      var name = '<s:property
>
value="additionalInterests['+number.toString()+'].bankName"/>';
>      alert("Name: " + name);
>  </script></code>

JavaScript is executed *AFTER* your JSP is compiled.

I'd recommend looking in to the way browsers/HTTP work
a bit.

d.


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