Hi,
you dont have to explicitly add the values to the list in the setter methods, since the framework will do that for you , also you dont have to explicitly provide the index in the property field (name) (even though it will work with explicit indexing as well) . refer the fallowing code for help , make sure you have the getters and setters created in your model or action respectively.

<s:iterator value="trainingSessionDetails"
               id="trainingSessionDetailsL" status="status">
<td><s:textfield name="trainingSessionName" id="sessionNameL" value="%{#trainingSessionDetailsL.sessionName}" size="8"></s:textfield></td>
                   <td><s:textarea name="trainingSessionDescription"
                       id="sessionDescriptionL"
value="%{#trainingSessionDetailsL.sessionDescription}" /></td>
                   <td><s:textfield name="trainingSessionStartDate"
                       id="sessionStartDateL%{#status.index}"
value="%{#trainingSessionDetailsL.sessionStartDate}" size="16" /></td>
                   <td><s:textfield name="trainingSessionEndDate"
                       id="sessionEndDateL%{#status.index}"
value="%{#trainingSessionDetailsL.sessionEndDate}" size="16" /></td>
               </tr>
           </s:iterator>

Shashi

Dear All,  I want to do something like this:
  in my action i create:
  List<String> textFields = new ArrayList<String>();
  and i tried to write set method in 2 ways:
  1. public void setTextFields (List<String> textFields)
  2. public void setTextFields(String text)
  {
    textFields.add(text);
  }

  and in my jsp, i want to get something like this:
  <s:iterator ...>
  <s:textfield name="textFields[%{#status.index}]"/>
  </s:iterator>

  But I found that for both setter methods, there are errors:
  com.opensymphony.xwork2.util.OgnlValueStack  - Caught an exception while
evaluating expression 'test_string[0]' against value stack
  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)

  Can anyone help me on how to create such a dynamic textFields (Considering
action implementation)? Thanks in advance!



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to