I have a problem in my tapestry project.
Every time I load one page, it triggers onActivate method if is defined in the page in question. But I don’t know how to catch that event in my layout template.
If I define a variable in the layout.java, for example:
@Property
String a = "foo";
And I pick that variable value at the template (layout.tml):
<p>${a}</p>
Ok, that will print “foo” in the HTML of all pages that use that layout, but If I want to change that value every time that the page reloads, for example defining onActivate in the layout.java.
void onActivate(){
a="bar";
}
This method doesn’t trigger in the layout.java, only in the child pages when it’s defined.
(In the child pages I include the layout like Nathan Q says) How can I refresh the variable value?
Any ideas?
Ok, I find a way to refresh my property value.
And It was very simple:
Instead of declare a property and update that value in the onActivate method, I declare a public method in the layout.java to get that value and make the updating changes there.
This way, I can make any changes to the a variable every time the page loads.