Hi Thilo, Thanks for this. I tried Thiago's solution and had some problems with it not remembering the values which were set. I'm not entirely sure why that is. I think creating a component is the ideal solution, but it seemed a little overkill at first.
I also noticed on StackOverflow that someone (Lance Java) posted a useful response that I need to try, but I do think it's going to have to go into it's own component and I need to study ajax loops, although being able to add/remove rows isn't entirely necessary for the project at the moment. Thanks, Steve On 20 May 2014 14:21, Thilo Tanner <thilo.tan...@reprisk.com> wrote: > Hi Stephen, > > I strongly encourage you to create a component for your result editor. This > helps encapsulating the editor code, which de-clutter your page class / > template. Tapestry components are very elegant and easy to re-use. > > If the number of values in your ArrayList is constant, you can use Thiago's > approach and use the Loop component to create the text fields. In case the > number of values should be adjustable, I think you're better off using > AjaxFormLoop. > > Best, > Thilo > > ________________________________________ > From: Stephen Nutbrown <steves...@gmail.com> > Sent: Tuesday, May 20, 2014 15:02 > To: Tapestry users > Subject: Re: Displaying an ArrayList of strings in a form using TextFields > > Hi Thilo, > > Thank you for your reply and for taking the time - I really do appreciate it. > > I did come across that first link when I was searching, but the issue > would be that it requires a lot more work for doing something which I > thought would be straight forwards. However, if I do it properly, then > this form can be used in several places in the application. I think > the best way would be for me to create this as a component which > handles everything to do with editing the result object, and pass the > "result" object in, I can name it something along the lines of > "resultEditor". I would then use the ajaxloop within the component. > That way whenever I want to show the result objects details and allow > it to be edited (this could be used in a few places), I can just use > this component which will be responsible for updating the result > object. > > I just wanted to check with you that doing that seems like a sensible > way forwards? > > As for the cheapo idea, although I do like it, unfortunately the text > fields may want changing to text areas (as they may not be short) so > if they risk going on to two lines then it becomes a bit of a > nightmare for users seeing where the end of lines really are. > > If you think the first way is the way to go, i'll put in the time to > create it as a separate component with an ajax loop in it. It seems > odd that it can't be done in a simpler way, just displaying each > String in the ArrayList as a separate text field/area. > > Thanks, > Steve > > On 20 May 2014 13:35, Thilo Tanner <thilo.tan...@reprisk.com> wrote: >> Hi Stephen, >> >> If you want one separate text field per ArrayList value, I suggest you take >> a look at the FormLoop component: >> >> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1 >> >> (The JumpStart sample app is a very good starting point to learn about T5 >> components) >> >> The component allows you to add and remove rows dynamically. If you store >> your values in the database, you either have to replace all values after the >> submit or you should keep track of the changes using a holder object: >> >> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloopwithholders1 >> >> Depending on your use case, you can also go for a cheapo solution and create >> a text area for your values. When you render the form, you fill it with one >> value per line and after the submit you split the user input line-by-line. >> >> Please feel free to ask, if you have questions concerning the FormLoop. >> >> Best, >> Thilo >> >> >> ________________________________________ >> From: Stephen Nutbrown <steves...@gmail.com> >> Sent: Tuesday, May 20, 2014 14:14 >> To: Tapestry users >> Subject: Displaying an ArrayList of strings in a form using TextFields >> >> Hello, >> >> I also posted this on StackOverflow (SO), but it seems that the forum >> is more active for these questions than SO. I'd really appreciate any >> help. Here is the SO question, and the problem below (the same as it >> is on SO). >> >> http://stackoverflow.com/questions/23756438/tapestry-5-edit-arraylist-of-strings >> >> >> I have a Result object (named result), and inside that object is an >> arraylist of strings (named action), as well as some other values. >> >> I can make a text area to edit values of the Result object like this: >> >> <input t:type="TextArea" t:id="feedback" t:value="result.someValue" /> >> >> This works fine. However, I would like to show a text field for each >> of the Strings in the ArrayList within the result object >> >> I can create a loop like this: >> >> <t:loop t:source="result.action" t:value="currentAction" >> index="indexProp" t:formstate="ITERATION"> >> ${currentAction} >> </t:loop> >> >> This will show me on the screen all of the actions (that is great, >> half way there). However I want these to be editable using a >> TextField. >> >> I have tried several things, none of which have worked how I wanted. >> However, to help explain and as an example of what I have tried, this >> is what I have: >> >> >> <t:loop t:source="result.action" t:value="currentAction" >> index="indexProp" t:formstate="ITERATION"> >> <input t:type="TextField" t:value="result.action.indexProp"/> >> </t:loop> >> >> This won't work because (as far as I know), this is the same as >> getResult().getAction.getIndexProp. So I tried >> >> <input t:type="TextField" t:value="result.action.${indexProp}"/> >> >> >> This doesn't work either, although it shows the correct number of >> TextFields, it does not link them up properly (they just say inside >> them "result.action.0" and "result.action.1". >> >> >> Any help is much appreciated. >> >> --------------------------------------------------------------------- >> 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 >> > > --------------------------------------------------------------------- > 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org