You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Abhijit Petkar <ap...@webifyservices.com> on 2004/03/08 14:35:19 UTC
Calling javascript method with a dynamic param
Hi All,
This is an issue related to Javascript usage in Tapestry.
I want to call a javascript function with a parameter from a tapestry page.
This parameter is dynamic and comes thru the backend.
<script language="Javascript">
function getErrorText(text){
document.forms[0].ErrorText.value=text;
}
</script>
onFocus="getErrorText('<span jwcid="@InsertText"
value="ognl:parentBean.childBeanMap[@blah.blah.IConstants@Str1].errorText"/>
')"
This doesn't work properly due to the nested usage of double quotes (").
Any idea(s) how to achieve this?
- Abhijit
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Calling javascript method with a dynamic param
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Or use a CDATA section in the .page file:
<binding name="value">
.... expression ...
</binding>
This helps a lot with messy quoting issues.
Erik
On Mar 8, 2004, at 9:40 AM, Jim Menard wrote:
> Abhijit,
>
>> onFocus="getErrorText('<span jwcid="@InsertText"
>> value="ognl:
>> parentBean.childBeanMap[@blah.blah.IConstants@Str1].errorText"/>
>> ')"
>>
>> This doesn't work properly due to the nested usage of double quotes
>> (").
>
> You could turn the whole thing into a Java method and have that method
> return the string. Or, you could try turning it inside-out:
>
> <span jwcid="@Insert" value='ognl:"onFocus=\"getErrorText(" +
> parentBean.childBeamMap[...].errorText+ ")\""'/>
>
> Jim
> --
> Jim Menard, jimm@io.com, http://www.io.com/~jimm/
> "COGITO, EGGO SUM." I think, therefore I am a waffle.
> -- .sig of Mr. Ska on Slashdot.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Calling javascript method with a dynamic param
Posted by Jim Menard <ji...@io.com>.
Abhijit,
> onFocus="getErrorText('<span jwcid="@InsertText"
> value="ognl:
> parentBean.childBeanMap[@blah.blah.IConstants@Str1].errorText"/>
> ')"
>
> This doesn't work properly due to the nested usage of double quotes
> (").
You could turn the whole thing into a Java method and have that method
return the string. Or, you could try turning it inside-out:
<span jwcid="@Insert" value='ognl:"onFocus=\"getErrorText(" +
parentBean.childBeamMap[...].errorText+ ")\""'/>
Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"COGITO, EGGO SUM." I think, therefore I am a waffle.
-- .sig of Mr. Ska on Slashdot.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org