You can accomplish this inside a script, if you are crafty. <set key="requestCycle" expression="component.page.requestCycle"/>
<if expression="requestCycle.getAttribute("foo.bar.baz.first") == null ? requestCycle.setAttribute("foo.bar.baz.first", true), true : false"> Only occurs first time through </if> Basically, if the marker attribute is null, then set the marker attribute and return true. We're using the OGNL comma operator to perform an operation before returning a value. If marker attribute is not null, return false. Yes, that's ugly, so perhaps the next version of the script specificaiton DTD will include built-in support for it. Perhaps something like: <if-first key="foo.bar.baz"> Only occurs first time through. </if-first> ----- Original Message ----- From: "Craig Goss" <[EMAIL PROTECTED]> To: "Howard M. Lewis Ship" <[EMAIL PROTECTED]> Sent: Thursday, September 12, 2002 7:52 AM Subject: RE: [Tapestry-developer] script questions > > Ah, the once only pattern. > > Here's an example from DatePicker: > > I missed the DatePicker example. Good to know I'm not the first one to care > ;^). > > I still wonder if it might be possible to implement a mechanism for > declaring a once-only variable in the .script file? While not overly > difficult to implement once you know about it, the once only pattern (1) is > a lot more code than a simple var declaration (2) physically separates the > variable declaration from the code that uses it and (3) is not at all > obvious to someone who does not know Tapestry well . I realize that this > last argument might not always hold water as the var could be needed by the > component, but in my case it is used only by the javascript. I'm also > assuming that, if there were a mechanism for declaring the var in the > script, it would be available to the component as an 'out' symbol. > > > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Tapestry-developer mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/tapestry-developer
