You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ahingsaka samsenesena <as...@sharengo.org> on 2009/03/26 11:43:34 UTC
Component with a persist attribute inside a loop
Hi,
I'm trying to use my own component inside a loop and I have a problem
when there is a "persist" annotation on attributes.
I want to loop with my component named "test" in a page like this :
<t:zone t:id="refreshZone"/>
<t:loop source="0..2" value="testId">
<t:test usage="${usage}"/>
</t:loop>
The component contains a string attribute "usageValue" that will be
displayed in the refreshZone.
This attribute comes from the parameter "usage". I put my value on the
setupRender method.
The class of the component is like this :
public class Test {
@Parameter
private String usage;
@Persist
@Property
private String usageValue;
@Inject
private Block refreshBlock;
boolean setupRender(MarkupWriter writer) {
this.usageValue = usage;
return true;
}
Object onActionFromClick() {
return refreshBlock;
}
}
And the tml :
<t:block t:id="refreshBlock">
${usageValue}
</t:block>
<t:actionlink t:id="click" t:zone="refreshZone">Click
me</t:actionlink><br/>
The controller is quite simple and returns an usage for a given number
public class ContentTest {
@Property
private int testId;
public String getUsage() {
if (testId == 0) {
return "pix";
} else if (testId == 1) {
return "zoom";
} else if (testId == 2) {
return "thumb";
} else
return "";
}
}
Here is the problem : when i click on the link. The value displayed is
always "thumb" !
I should have "pix" displayed with the first link, "zoom" with the
second ...
I tried to put an id, but the behaviour is the same :
<t:loop source="0..2" value="testId">
<t:test t:id="testId" usage="${usage}"/>
</t:loop>
And if I don't use the loop, there is no problem :
<t:zone t:id="refreshZone"/>
<t:test usage="literal:pix">
</t:test>
<t:test usage="literal:zoom">
</t:test>
<t:test usage="literal:thumb">
</t:test>
If I use these lines, i have the right behaviour.
What's going on ?
Ahingsaka SAMSENESENA
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org