I have tried with your modifications but now, when i click on the links, the value displayed is always "pix".
Le jeudi 26 mars 2009 à 15:12 +0100, Otho a écrit : > a) You don't need to copy the value from the parameter to the property. > b) There is no need to persist it. > > @Parameter > @Property > private String usage; > > <t:block t:id="refreshBlock"> > ${usage} > </t:block> > > 2009/3/26 ahingsaka samsenesena <asamsenes...@sharengo.org> > > > 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 of the page 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-unsubscr...@tapestry.apache.org > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org