I found out the cause of the persistence issue. In my code I refer to my home
page with its actual page name -- getPage("Simple"), which seems to create a
new instance of the page and re-initialize the property. If I get the page
using getPage("Home"), it works fine as there is no re-initialization.
Is there a work around to be able to refer to the "Home" page with its actual
page name? Otherwise, I could keep on referring to it as Home or rename it
Home.
Thanks,
Joey
Here's my CODE:
/** Simple / Home page **/
public abstract class Simple extends BaseSimplePage implements
PageBeginRenderListener{
@Persist
public abstract String getUserName();
public abstract void setUserName(String s);
public void loadAnotherPage(){
System.out.println("Load another page...");
IPage page = getRequestCycle().getPage("AnotherPage");
getRequestCycle().activate(page);
}
public void pageBeginRender(PageEvent arg0) {
System.out.println("Home.pageBeginRender before set: " + getUserName());
setUserName("New");
System.out.println("Home.pageBeginRender after set: " + getUserName());
}
public void finishLoad(IRequestCycle arg0, IPageLoader arg1,
IComponentSpecification arg2) {
System.out.println("Home.finishLoad");
setUserName("Initial");
super.finishLoad(arg0, arg1, arg2);
}
}
/** AnotherPage **/
public abstract class AnotherPage extends BaseSimplePage{
private static final Logger LOG = Logger.getLogger(AnotherPage.class);
public void loadHome(){
System.out.println("AnotherPage, loading Home page...");
// Simple page is the "Home" page.
// If it is referred to as "Simple", a new instance is created and the
property is re-initialized.
Simple page = (Simple)getRequestCycle().getPage("Simple");
// This does not create a new instance of the Simple page.
// Simple page = (Simple)getRequestCycle().getPage("Home");
getRequestCycle().activate(page);
// Is there a way to set up a "Home" page not named Home.* and be
accessed with cycle.getPage("NotHomeName")?
// (without having its property reinitialized)
}
}
CONSOLE OUTPUT:
Home.finishLoad
Home.pageBeginRender before set: Initial
Home.pageBeginRender after set: New
Load another page...
AnotherPage, loading Home page...
Home.finishLoad
Home.pageBeginRender before set: Initial
Home.pageBeginRender after set: New
> Sample code would be helpful.
>
> P
>
> On Sep 7, 2005, at 4:39 PM, Joey Solis wrote:
>
>> Platform: Tapestry 4 beta 5
>>
>> Problem Description:
>>
>> Persistent properties on a page declared as the home-page are not
>> persisted on the first set, but revert back to their initial values.
>>
>> On subsequent sets the properties are persisted.
>>
>> If the page is not declared as home, the first persistent property set
>> works as expected.
>>
>> Sample code is available; questions, comments, solutions are welcomed.
>
>
> --------------------------------------------------------------------- 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]