Expansions (the name for the "${...}") syntax do not currently occur inside
comments, only inside body text and inside attributes.

Generally, the correct way to accomplish what you want is to inject the
@Environmental PageRenderSupport object and use the addScript() method to
add JavaScript to the page.  The concept is to keep such JavaScript
minimal.  The JavaScript will be invoked when the page is fully loaded.


On 10/13/07, Ritesh.S <[EMAIL PROTECTED]> wrote:
>
>
> Hello Everybody,
>
> I am new to Tapestry 5, want to access the variables declared in Java
> class
>
> on my Html page in Javascript.
>
> My Java class file  contains
>
>         @Persist
>         private String var = "value";
>
>         public String getVar() {
>                 return var;
>         }
>
>         public void setVar(String var) {
>                 this.var = var;
>         }
>
> I am accessing this variable on my html as below :
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
> <head>
> <script language="javascript" type="text/javascript">
> <!-- //
>         function setvar() {
>                         var somevar = ${personal_on};
>                         // also tried this one
>                         var somevar = "${personal_on}"; //sets
> "${personal_on}" as string not its value
>
>                         //---
>                         //---// some code here which uses above variable
> //---
>                         //---
>
>         }
> // -->
> </script>
> </head>
> <body onload="setup();">
> ---
> </body>
> </html>
>
> This is giving javascript error Object not defined on loading of this html
> page.
>
> I think it not getting it as Tapestry variable in script tags under
> <head>.
> If I use this variable in <body> tags it gets it value as in class.
>
> Why this is happening? Am I missing something?
> Any help will be appreciated.. please help...
>
> Thanks in advance...
> --
> View this message in context:
> http://www.nabble.com/T5-accessing-Java-class-variables-in-Javascript-tf4618529.html#a13190350
> Sent from the Tapestry - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Reply via email to