Your code snippet does it. All is well.
-----Original Message-----
From: Tom Davies [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 13, 2002 11:31 PM
To: [EMAIL PROTECTED]
Subject: Re: [Tapestry-developer] request for help with rewind]
Phil wrote:
> I would like to at least have the option to have the
> IDirectListener called before rendering, whether this
> is implemented directly or virtually (through a rewind).
> For us, it is a reasonably common pattern for a page to contain
> a ForEach with embedded Direct components that change
> the state of the underlying object that the containing
> Page represents. What happens now is that the Page
> gets rerendered, with the old data, then the data
> gets updated. So you don't see the effect of the
> update. It just seems unnatural to have the IDirectListener
> run _after_ rendering.
I'm not sure exactly what behaviour you are seeing.
I've appended a simple single-page example which has a series of Direct
components inside a Foreach. The direct listener changes the state of
the page, which then refreshes.
Please tell me if this does what you want, or if I've misunderstood
something.
Tom
TestPage.java
--------------------------------------
import com.primix.tapestry.BasePage;
import com.primix.tapestry.IRequestCycle;
public class TestPage extends BasePage
{
private String value;
private String i;
public void setValue(String value)
{
this.value = value;
}
public void setI(String i)
{
this.i = i;
}
public String getI()
{
return i;
}
public String getValue()
{
if (value == null) // is this the best way to set a default?
{
value ="Empty";
this.fireObservedChange("value",value);
}
return value;
}
public void direct(String[] context, IRequestCycle cycle)
{
setValue(context[0]);
this.fireObservedChange("value",value);
}
public String[] getValueArray()
{
return new String[] {"Red", "Green", "Blue"};
}
public void detach()
{
value = null;
super.detach();
}
}
TestPage.jwc
--------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE specification PUBLIC
"-//Howard Ship//Tapestry Specification 1.1//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_1.dtd">
<specification class="TestPage">
<component id="value" type="Insert">
<binding name="value" property-path="value"/>
</component>
<component id="for" type="Foreach">
<binding name="source" property-path="valueArray"/>
<binding name="value" property-path="i"/>
</component>
<component id="direct" type="Direct">
<binding name="listener" property-path="listeners.direct"/>
<binding name="context" property-path="i"/>
</component>
<component id="label" type="Insert">
<binding name="value" property-path="i"/>
</component>
</specification>
TestPage.html
----------------------------------------------------
<span jwcid="value">Value goes Here</span><br><br>
<span jwcid="for">
<a href=""#"" jwcid="direct"><span jwcid="label">Label</span></a>
</span>
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer
