Here is a hacked version of the code posted by David Hay previously.  The
code here will compile and run - a Vector is populated then displayed.
After a post, the vector is retrieved from the form and then System.out is
used to show its size.

This should help others that are having problems with indexed tags.  You'll
need to point your browser to somthing that looks like
http://localhost/struts/ShowParameters.do once you've copied all the files
into the correct locations.

There were two issues with the way i was trying to do it, firstly it seems that unless 
the scope of the form is set to session (or not specified) it doesn't work and 
secondly because i was using a different id for the name in the logic:iterate / 
html:text tags (when i set them to
"parameter" it worked).

<logic:iterate id="parameter" name="FieldsMapForm" property="parameterList">
  <html:text name="parameter" property="attributeCode" indexed="true"/> <br>
</logic:iterate>


    <action    path="/mapping"
               type="com.eurobenefits.dta.presentation.FieldsMapAction"
               scope="session"
               name="FieldsMapForm"
               validate="false">
           <forward   name="viewmappings" path="/DefineFieldMappings.jsp"/>
    </action> 

Waz.
=)

-----Original Message-----
From: Warwick Boote [mailto:[EMAIL PROTECTED]]
Sent: 24 July 2001 14:09
To: [EMAIL PROTECTED]
Subject: what setters do i implement in an indexed tag ?


I've created a page using indexed tags (neat stuff!). 
Here is what is currently working for me: 
o If i populate the form's vector, values from that vector are displayed in
the jsp 
Here is what it not working: 
o when the form is posted back, the vector is null (in the struts perform()
method) 
I suspect i haven't implemented some sort of setter within the form but i
can't find an example as to what method should be implemented.  I've tried
ArrayList and using parameterList instead with no different result.
Thanks, 
Waz. 
=) 
Here are some code snippits for help: 
---jsp--- 
<logic:iterate id="mappings" name="FieldsMapForm" property="fieldMappings">
<html:text name="mappings" property="attributeCode" indexed="true"/> <br>
</logic:iterate>
---Form--- 
public class FieldsMapForm extends ActionForm { 
private String fileColCount;
private java.util.Vector fieldMappings = new java.util.Vector();
private String action; 
public String getFileColCount() {
return fileColCount;
}
public void setFileColCount(String newFileColCount) {
fileColCount = newFileColCount;
}
public void setFieldMappings(java.util.Vector newFieldMappings) {
fieldMappings = newFieldMappings;
}
public java.util.Vector getFieldMappings() {
return fieldMappings;
} 
public FieldMapping getParameter(int index) {
return (FieldMapping)fieldMappings.elementAt(index);
} 
public void setAction(String newAction) {
action = newAction;
}
public String getAction() {
return action;
} 
public void reset(ActionMapping mapping, HttpServletRequest request) {
fileColCount = null;
fieldMappings = new java.util.Vector();
action = null;
}
} 
---The vector contains these:--- 
public class FieldMapping implements Serializable { 
private Integer fieldNumber;
private String attributeCode; 
public void setFieldNumber(Integer newFieldNumber) {
fieldNumber = newFieldNumber;
}
public Integer getFieldNumber() {
return fieldNumber;
}
public void setAttributeCode(String newAttributeCode) {
attributeCode = newAttributeCode;
}
public String getAttributeCode() {
return attributeCode;
} 
} 
 <<indexed_eg_rwb.zip>> 

indexed_eg_rwb.zip

Reply via email to