Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
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)


©2008 junlu.com - Jax Systems, LLC, U.S.A.