Re: [S2] Newbie Passing S2 variables to javascript functions

2007-04-30 Thread Roger Varley

Without seeing the error and the JSP code that generated it, it's hard
to tell you what's wrong. However, remember that Javascript runs on the
client, after the page has been generated. View the page source to see
what the syntax error is. In this case, it's probably the lack of quotes
around the OGNL expression. It may also be that an in-line expression
like that wont work.

Here's a couple of suggestions to try:

 ... onclick=enableField('%{#indexValue}') ...
 ... onclick=%{'enableField(\'' + #indexValue + '\')'} ...
 ... onclick=enableField('${indexValue}') ...



I've tried all your suggested variations, but looking at the source,
all the expressions are passed as a string, there's no evaluation of
the expression. Which, now you've explained that Javascript executes
on the client makes sense. So the question becomes is it possible to
interact with the action stack in Javascript?

Regards
Roger

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2] Newbie Passing S2 variables to javascript functions

2007-04-30 Thread Musachy Barroso

script
  // call the function passing the index
  myFunction(s:property value=#indexValue / )

/script

just make sure the indexValue is available when you use it.

musachy

On 4/30/07, Roger Varley [EMAIL PROTECTED] wrote:


 Without seeing the error and the JSP code that generated it, it's hard
 to tell you what's wrong. However, remember that Javascript runs on the
 client, after the page has been generated. View the page source to see
 what the syntax error is. In this case, it's probably the lack of quotes
 around the OGNL expression. It may also be that an in-line expression
 like that wont work.

 Here's a couple of suggestions to try:

  ... onclick=enableField('%{#indexValue}') ...
  ... onclick=%{'enableField(\'' + #indexValue + '\')'} ...
  ... onclick=enableField('${indexValue}') ...


I've tried all your suggested variations, but looking at the source,
all the expressions are passed as a string, there's no evaluation of
the expression. Which, now you've explained that Javascript executes
on the client makes sense. So the question becomes is it possible to
interact with the action stack in Javascript?

Regards
Roger

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Hey you! Would you help me to carry the stone? Pink Floyd


Re: [S2] Newbie Passing S2 variables to javascript functions

2007-04-30 Thread Laurie Harper
Again, though, bear in mind that the s:proprty/ tag will be evaluated 
on the server during page generation whereas the Javascript will be 
executed later, on the client, after the page is delivered.


There's no way to 'interact with the action stack in Javascript', since 
the action stack only exists during page generation and the Javascript 
runs later.


That said, techniques like the one Musachy shows below, or the previous 
examples, *will* allow you to push data from the action stack into your 
scripts at page generation time. You just can't dynamically reference 
the action stack 'live' from Javascript.


 all the expressions are passed as a string, there's no evaluation of
 the expression. Which, now you've explained that Javascript executes

I'm not sure what you mean here; the only thing you can 'pass' is a 
Javascript literal, but that could be a string, integer, even an object 
literal. Just remember that you're generating code, so whatever you 
generate has to be syntactically valid when the browser comes to run it.


If this is all still unclear, maybe you can describe what you are trying 
to achieve in a little more detail.


L.

Musachy Barroso wrote:

script
  // call the function passing the index
  myFunction(s:property value=#indexValue / )

/script

just make sure the indexValue is available when you use it.

musachy

On 4/30/07, Roger Varley [EMAIL PROTECTED] wrote:


 Without seeing the error and the JSP code that generated it, it's hard
 to tell you what's wrong. However, remember that Javascript runs on the
 client, after the page has been generated. View the page source to see
 what the syntax error is. In this case, it's probably the lack of 
quotes

 around the OGNL expression. It may also be that an in-line expression
 like that wont work.

 Here's a couple of suggestions to try:

  ... onclick=enableField('%{#indexValue}') ...
  ... onclick=%{'enableField(\'' + #indexValue + '\')'} ...
  ... onclick=enableField('${indexValue}') ...


I've tried all your suggested variations, but looking at the source,
all the expressions are passed as a string, there's no evaluation of
the expression. Which, now you've explained that Javascript executes
on the client makes sense. So the question becomes is it possible to
interact with the action stack in Javascript?

Regards
Roger

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[S2] Newbie Passing S2 variables to javascript functions

2007-04-27 Thread Roger Varley

Hi

Within a s:iterator tag I have the following statement s:set
name=indexValue value=#status.index/ (because status seems to
disappear when the iterator exits) and I use the expression
%{#indexValue} within other struts s: tags without a problem.

I now need to pass this value to a javascript function i.e
onclick=enableField(%{#indexValue}) but the browser complains about
invalid syntax. How do I pass the value indexValue to a javascript
function?

Regards
Roger

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2] Newbie Passing S2 variables to javascript functions

2007-04-27 Thread Felipe Rodrigues

Once you've setted this var, you can use Plain Old EL to get it.
${indexValue} should work .

A good pratice in this case is define the scope you're setting this var.

Regards,

Felipe


Roger Varley wrote:
 
 Hi
 
 Within a s:iterator tag I have the following statement s:set
 name=indexValue value=#status.index/ (because status seems to
 disappear when the iterator exits) and I use the expression
 %{#indexValue} within other struts s: tags without a problem.
 
 I now need to pass this value to a javascript function i.e
 onclick=enableField(%{#indexValue}) but the browser complains about
 invalid syntax. How do I pass the value indexValue to a javascript
 function?
 
 Regards
 Roger
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-S2--Newbie-Passing-S2-variables-to-javascript-functions-tf3658057.html#a1085
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2] Newbie Passing S2 variables to javascript functions

2007-04-27 Thread Laurie Harper

Roger Varley wrote:

Hi

Within a s:iterator tag I have the following statement s:set
name=indexValue value=#status.index/ (because status seems to
disappear when the iterator exits) and I use the expression
%{#indexValue} within other struts s: tags without a problem.

I now need to pass this value to a javascript function i.e
onclick=enableField(%{#indexValue}) but the browser complains about
invalid syntax. How do I pass the value indexValue to a javascript
function?


Without seeing the error and the JSP code that generated it, it's hard 
to tell you what's wrong. However, remember that Javascript runs on the 
client, after the page has been generated. View the page source to see 
what the syntax error is. In this case, it's probably the lack of quotes 
around the OGNL expression. It may also be that an in-line expression 
like that wont work.


Here's a couple of suggestions to try:

... onclick=enableField('%{#indexValue}') ...
... onclick=%{'enableField(\'' + #indexValue + '\')'} ...
... onclick=enableField('${indexValue}') ...

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]