Karthik.Nar, I made the change below to Result.java. It seems to work, but is this optimal? Is there a way for the component to automatically find out it's "parent page" to bind the value without using a "double" bucket brigade and/or without using component injection. I'm new to Tapestry still, so might not understand even what i'm talking about! Is this the best practice? Thank you for your advice.
Result.java ------------------- package uk.co.gd.dao; import org.apache.tapestry.annotations.InjectComponent; import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; import org.apache.tapestry.html.BasePage; public abstract class Result extends BasePage implements PageBeginRenderListener { @InjectComponent("searchComponent") public abstract SearchComponent getSearchComponent(); public abstract void setSearchText(String searchText); public abstract String getSearchText(); public void pageBeginRender(PageEvent event) { if (event.getRequestCycle().isRewinding()) { System.out.println("in pagebeginrender but rewinding"); return; } System.out.println("in pagebeginrender not rewinding"); ((SearchComponent) getSearchComponent()).setSearchText(getSearchText()); } } karthik.nar wrote: > > you are setting the searchText on the Result page and not on the > SearchComponent in the result page. > > since you have the searchText on the Result page you need to now > "transfer" > it to the SearchComponent in the result page. > > you can consider setting the searchText of the SearchComponent in the > pageBeginRender method of Result.java > > On 10/31/06, Gurps <[EMAIL PROTECTED]> wrote: >> >> >> I have 2 pages. A Home.html and a Result.html. >> I have 1 component (SearchComponent) which is to be SHARED across both >> pages. The component is a simple textfield. >> >> When submitting a value in the first page, it then goes to the result >> page. >> However the component don't remember it's value the first time. On >> subsequent submits it remembers it (probably because you stay on the >> reult >> page behind the scenes). >> >> Does anyone have any idea what to do? Much appreciated. Here is the >> simple >> code: >> >> Home.java >> ------------------- >> package uk.co.gd.dao; >> >> import org.apache.tapestry.html.BasePage; >> >> public abstract class Home extends BasePage { >> } >> >> >> Home.page >> ------------------- >> <?xml version="1.0" encoding="UTF-8"?> >> <!DOCTYPE page-specification PUBLIC "-//Apache Software >> Foundation//Tapestry >> Specification 4.0//EN" >> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> >> >> <page-specification class="uk.co.gd.dao.Home"> >> <component id="searchComponent" type="SearchComponent" /> >> </page-specification> >> >> >> Home.html >> -------------------- >> <html> >> <body> >> <span jwcid="searchComponent" /> >> </body> >> </html> >> >> >> Result.java >> -------------------- >> package uk.co.gd.dao; >> >> import org.apache.tapestry.html.BasePage; >> >> public abstract class Result extends BasePage { >> public abstract void setSearchText(String searchText); >> } >> >> >> >> Result.page >> ---------------------- >> <?xml version="1.0" encoding="UTF-8"?> >> <!DOCTYPE page-specification PUBLIC "-//Apache Software >> Foundation//Tapestry >> Specification 4.0//EN" >> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> >> >> <page-specification class="uk.co.gd.dao.Result"> >> <component id="searchComponent" type="SearchComponent" /> >> </page-specification> >> >> >> Result.html >> -------------------- >> <html> >> <body> >> you entered: <span jwcid="searchComponent" /> >> </body> >> </html> >> >> >> SearchComponent.java >> --------------------------------- >> package uk.co.gd.dao; >> >> import org.apache.tapestry.BaseComponent; >> import org.apache.tapestry.IPage; >> import org.apache.tapestry.IRequestCycle; >> import org.apache.tapestry.annotations.InitialValue; >> import org.apache.tapestry.annotations.InjectPage; >> >> public abstract class SearchComponent extends BaseComponent { >> >> @InjectPage("Result") >> public abstract Result getResultPage(); >> >> @InitialValue("literal:") >> public abstract String getSearchText(); >> >> public IPage onOk(IRequestCycle cycle) { >> System.out.println(new java.util.Date() + ": over here >> SearchComponent: " >> + getSearchText()); >> >> if (cycle.isRewinding()) >> System.out.println(new java.util.Date() + ": over >> here SearchComponent: >> rewinding"); >> else >> System.out.println(new java.util.Date() + ": over >> here SearchComponent: >> not rewinding"); >> >> Result resultPage = getResultPage(); >> resultPage.setSearchText(getSearchText()); >> return resultPage; >> } >> } >> >> >> SearchComponent.jwc >> -------------------------------- >> <?xml version="1.0" encoding="UTF-8"?> >> <!DOCTYPE component-specification PUBLIC "-//Apache Software >> Foundation//Tapestry Specification 4.0//EN" >> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> >> >> <component-specification class="uk.co.gd.dao.SearchComponent"> >> >> <component id="searchForm" type="Form"> >> <binding name="listener" value="listener:onOk" /> >> </component> >> >> <component id="searchText" type="TextField"> >> <binding name="value" value="searchText" /> >> </component> >> >> </component-specification> >> >> >> SearchComponent.html >> -------------------------------- >> <html> >> <body jwcid="$content$"> >> <form jwcid="searchForm" style="display: inline"> >> <input type="text" size="20" jwcid="searchText" >> /> >> <input type="submit" style="background-color: >> #ebebeb" value="Go!" /> >> </form> >> </body> >> </html> >> >> -- >> View this message in context: >> http://www.nabble.com/Component-won%27t-remember-value-tf2547494.html#a7099616 >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Thanks, Karthik > > -- View this message in context: http://www.nabble.com/Component-won%27t-remember-value-tf2547494.html#a7133898 Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]