You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/01/11 21:31:09 UTC
Pass java String variable into addscript jquery method.
Hello, I'm looking to pass a Java string variable into my
javaScriptSupport.addScript method. I'm using the tapestry jquery library.
Below is a sample of what I'm looking to do, however this does not function.
void afterRender() {
String test = "test";
javaScriptSupport.addScript("requiredFields(" + test + ");");
}
Any guidance would be of great help, thanks in advance.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-java-String-variable-into-addscript-jquery-method-tp5137957p5137957.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Solved: Re: Pass java String variable into addscript jquery method.
Posted by George Christman <gc...@cardaddy.com>.
I seemed to solve this on my own with the following code.
String test = "test";
javaScriptSupport.addScript("requiredFields(\"%s\");", test);
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-java-String-variable-into-addscript-jquery-method-tp5137957p5138000.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Pass java String variable into addscript jquery method.
Posted by Michael Gentry <mg...@masslight.net>.
Hi George,
I'm doing pretty much the same thing and it works fine:
void afterRender()
{
if (enableJavaScriptTimer)
javaScriptSupport.addScript("registerSessionTimeout(" +
request.getSession(true).getMaxInactiveInterval() + ");");
}
Shouldn't matter if you are doing jQuery or otherwise. Maybe add a
console.log() in your requiredFields() method and then check your JS
console to ensure it is being called.
mrg
On Wed, Jan 11, 2012 at 3:31 PM, George Christman
<gc...@cardaddy.com> wrote:
> Hello, I'm looking to pass a Java string variable into my
> javaScriptSupport.addScript method. I'm using the tapestry jquery library.
>
> Below is a sample of what I'm looking to do, however this does not function.
>
> void afterRender() {
> String test = "test";
> javaScriptSupport.addScript("requiredFields(" + test + ");");
> }
>
> Any guidance would be of great help, thanks in advance.
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-java-String-variable-into-addscript-jquery-method-tp5137957p5137957.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org