  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Multiple selections with an indexed field | Multiple selections with an indexed field 2007-02-05 - By Ray, Marla S
Back I have a somewhat complicated form that I'm trying to create using Struts. I actually have the form working but we need to make an enhancement that makes it even more complicated. I have tried googleing and searching several places to find an example that will help me. I have found examples that solve part of the problem but not all of it.
What I have is a form that has some fixed fields and then a variable number of other fields. I'm using the iterate tag and the indexId to display each of the variable fields. It looks like:
<logic:iterate id="field" name="infoDatas" type="InfoData" indexId="fieldIndex"> .... </logic:iterate>
Within my iterate I display each field. Some fields are displayed as text input and some are displayed as selection lists. The selection list display looks like:
<html:select property="<%=\"theValues[\"+fieldIndex+\"]\"%>"> <bean:define id="theSelectionList" name="field" property="infoType.selectionList" /> <html:options collection="theSelectionList" property="value" labelProperty="value" /> </html:select>
In my Form I have theValues defined as a String array:
private String[] theValues = {};
And I have all the proper getters and setters:
public String[] getTheValues() { return theValues; } public String getTheValues(int whichone) { if (whichone > theValues.length-1 (See http://gth-1.ora-code.com)) { return " "; } else { return theValues[whichone]; } } public void setTheValues(String[] theValues) { this.theValues = theValues; } public void setTheValues (int whichone, String theValue) { if (theValues.length == 0) { this.theValues = new String[whichone+1]; } else if (whichone > theValues.length-1 (See http://gth-1.ora-code.com)) { String[] newValues = new String[whichone+1]; for (int i=0; i<theValues.length; i++) { newValues[i] = theValues[i]; } this.theValues = newValues; } this.theValues[whichone] = theValue; }
Now we need to allow the user to select multiple values for some of the selection lists. I'm thinking I need an array of String arrays or something like that so I can still use the indexId but get it to allow for multiple values but I can't find any examples of what I need and I'm having a mental block making the jump in logic.
If someone can help me with an example or something to get me past my mental block I would really appreciate it.
Thanks
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To unsubscribe, e-mail: user-unsubscribe@(protected) For additional commands, e-mail: user-help@(protected)
|
|
 |