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

Reply via email to