You could use the PageRenderSupport Environmental annotation to set a JavaScript variable in your page class that is the evaluated by the embedded component JavaScript.
MyPageComponent.java: @Environmental private PageRenderSupport pageRenderSupport; @BeginRender void beginRender() { pageRenderSupport.addScript("var myPageCondition = " + isMyCondition() + ";"); } Private boolean isMyCondition() { return myConditionLogic(); } However seems a little weird that you would want to conditionally set the logic on a JavaScript function, seems like you would want to conditionally call the function instead. Adam -----Original Message----- From: Martin Dietze [mailto:[EMAIL PROTECTED] On Behalf Of Martin Dietze Sent: Wednesday, June 27, 2007 1:09 AM To: users@tapestry.apache.org Subject: T5: Conditional JavaScript code Hi, I would like to add inline JavaScript code to a form depending on conditions set within the page class. I thus wrote code like this: | <script type="text/javascript"> | function myFunc() { | <t:if test="prop:myCondition"> | for (var i = 0; i < someConstant; i++) { | doSomethin(); | } | </t:if> | } | </script> This code causes problems since obviously Tapestry expects well-formed HTML code here (note the '<' character). I also run into problems if I put the inline JavaScript into HTML comments, the code gets completely ignored then. Since after each submit of the form the condition in the <t:if> changes I don't really see any alternative to this construct, or is there any fix/better way to do this? Cheers, Martin -- ----------- / http://herbert.the-little-red-haired-girl.org / ------------- =+= Yoda of Borg I am. Assimilated you will be. --------------------------------------------------------------------- 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]