aliright - i'll check that out,  anyone else reading this thread - there is
a .zip file attached in the message:
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html

Waz.
=)

-----Original Message-----
From: Torsten Terp [mailto:[EMAIL PROTECTED]]
Sent: 24 July 2001 17:57
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implement in an indexed tag ?


Hi,

You need 3 methods, a getter and a setter for the Vector (or other
arraytype object) and a getter for single object in your arraytype
object, i.e., getObject(int inx){ return myVector.elementAt(inx) }
Just like on the webpage mentioned. 

the setters needed should be defined on the object your are returning
in the getObject method. That is, what happens when the form fild data
is passed to the form object is:
getObject(inx).setProperty(someProperty). 

Dave Hay posted a very usefull example (source) in a post with subject: 
Re: Long Story short, posted on 2001.07.19!! You should check that out!

^terp

-----Original Message-----
From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 5:03 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implement in an indexed tag ?


In the indexed tags write up at
http://www.husted.com/about/struts/indexed-tags.htm, it only mentions the
two types of get methods required in the action form. It doesn't mention the
setters that are required. It looks like the getParameterList() method is
only used by the iterate tag. To populate the form on submit the only setter
needed is:

public void setParameter(int index, Parameter p){...};

In your case that means:

public void setParameter(int index, FieldMapping f) {...};

You probably don't need:
public void setFieldMappings(java.util.Vector newFieldMappings) {
fieldMappings = newFieldMappings;
}
unless you use it in your action to populate the form object before
displaying the form jsp.

I am about to try this myself so this is just a guess.

Hal

-----Original Message-----
From: Warwick Boote [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 9:09 AM
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;
}
}

Reply via email to