I did some more experimenting and ended up using a Border component. However,
how do I set the value of something that is in a border? I tried treating it
like any other component eg:
((Border) getBorder()).setSearchText(getSearchText())
but it didn't work. I think the Border component is treated a little
differently to vanilla components?
karthik.nar wrote:
>
> glad it worked.
>
> i think one of the powers of tapestry is the ability to be able to tap
> into
> lifecycle methods, as also register listeners (like pageBeginRender)
>
> i don't have exact answers to your question "but is this optimal?" - it
> depends on what you want to do. if you want your component to be agnostic
> of the page it is in, then it's better to follow the approach of the page
> injecting the initial value as done below.
>
> you could also configure your component to accept a parameter and set that
> as the initial value of the text field. this parameter could then be
> bound
> to a value on your page.
>
> hth - karthik.
>
>
> On 11/2/06, Gurps <[EMAIL PROTECTED]> wrote:
>>
>>
>> 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());
>> }
>> }
>>
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Component-won%27t-remember-value-tf2547494.html#a7197552
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]