Re: Components inside For component
Hello all and very thnak you for your reply, My level in this framework is beginer (and my english too, sorry). I go to explain me a litle bit more concise. I have a bean User that have a List of Rol object, in Java this is: public class User { private List rols = new ArrayList(); } With a For component I list all items in rols property, the code can be like this: public abstract class UserPage extends BasePage implements PageBeginRenderListener { @Persist public abstract User getUser(); public abstract void setUser(User user); } ... del With this code I try to set every element of Rol List with the PropertySelect component but this state is not saved, I add and delete items from Rol list but every time I make a submit (to add items, delete items or make the page submit to save the data) the List have all items that I have add but all are without state (default constructor values). Perhaps I have forgot something, I don't know what but I understand that user property is persistent and Rol list too (is part of the User class) and RolsModel returns Rols object to set the state but this not work. What can I do? Very Thank You. P.D. Perhaps palette component is better option but at this point of learning this framework I need to understand all posibilities but Very Thank You Jesse Kuhnert, it is a good advice. El lun, 30-10-2006 a las 22:41 +0100, Christian Haselbach escribió: > On Mon, Oct 30, 2006 at 08:46:41PM +, pipothebit wrote: > > I add rols and delete (throught index property of For component) but my > > rol values are not set during post, and when i go to save it to database > > all items of rols List are empty (state is not saved). > > I do not really understand what you are doing, but there are different > ways to manipulate state according to elements in a For loop. > > Assuming you render something like a button for each element, you > could use the current value (assigned via value) or the index > (assigned via index parameter) to associate the rendered button > with the element, so you know for which element the button has been > pressed. > > Another way, if things are more complicated, is to use hand tailored > setters and getters which take into account what the current element > in the loop is, backed by a persisted property. > > Lets say you have a property elementChecked (a set) and iterate > with the For component over elements: > > ... > > > In this component you have a checkbox accessing a property elementCheck. > For this property define the getter and setter as follows: > public boolean isElementCheck() { >this.getElementChecked().contains(getElement()); > } > public void setElementCheck(boolean checked); > if (checked) { > this.getElementChecked().add(getElement()); > } else { > this.getElementChecked().remove(getElement()); > } > } > > Well, elementChecked does not need to be persistent, if you do not need > it after the rewind. > > Regards, > Christian > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y m�viles desde 1 c�ntimo por minuto. http://es.voice.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Components inside For component
On Mon, Oct 30, 2006 at 08:46:41PM +, pipothebit wrote: > I add rols and delete (throught index property of For component) but my > rol values are not set during post, and when i go to save it to database > all items of rols List are empty (state is not saved). I do not really understand what you are doing, but there are different ways to manipulate state according to elements in a For loop. Assuming you render something like a button for each element, you could use the current value (assigned via value) or the index (assigned via index parameter) to associate the rendered button with the element, so you know for which element the button has been pressed. Another way, if things are more complicated, is to use hand tailored setters and getters which take into account what the current element in the loop is, backed by a persisted property. Lets say you have a property elementChecked (a set) and iterate with the For component over elements: ... In this component you have a checkbox accessing a property elementCheck. For this property define the getter and setter as follows: public boolean isElementCheck() { this.getElementChecked().contains(getElement()); } public void setElementCheck(boolean checked); if (checked) { this.getElementChecked().add(getElement()); } else { this.getElementChecked().remove(getElement()); } } Well, elementChecked does not need to be persistent, if you do not need it after the rewind. Regards, Christian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Components inside For component
Sorry if this isn't helpful, but that particular scenario sounds like the kind of thing that would be made much easier if you just used the Palette component: http://tapestry.apache.org/tapestry4.1/tapestry-contrib/componentreference/palette.html On 10/30/06, pipothebit <[EMAIL PROTECTED]> wrote: Hello, I have a User entity, that entity can have many Rols (every rol is an object). To do this I have a For component that iterates over rols of User entity(it is declared as List()), and I select it thought PropertySelection component. I add rols and delete (throught index property of For component) but my rol values are not set during post, and when i go to save it to database all items of rols List are empty (state is not saved). What can I do to save the state of every item inside a For component? Very Thank You. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jesse Kuhnert Tapestry/Dojo/(and a dash of TestNG), team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
Components inside For component
Hello, I have a User entity, that entity can have many Rols (every rol is an object). To do this I have a For component that iterates over rols of User entity(it is declared as List()), and I select it thought PropertySelection component. I add rols and delete (throught index property of For component) but my rol values are not set during post, and when i go to save it to database all items of rols List are empty (state is not saved). What can I do to save the state of every item inside a For component? Very Thank You. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]