I don't know if you can change the size if you set in ion the form
property tag. If you dont know if you'll have 12 then leave that out..
Also scope the form bean to session if you're changing the size like
this.
If you're not changing the size then it should work as things stand.
Cheers Mark
On Tuesday, September 9, 2003, at 06:00 PM, Michael Muller wrote:
The following article seems to differ in approach from how the posters
to this forum implement indexed properties in struts:
http://www.developer.com/java/other/article.php/2233591
In this article, the author uses a DynaActionForm which automatically
builds an array of normal beans. By normal, I mean that the beans
have methods like this:
String getFoo()
void setFoo(String foo)
rather than this, as is often advocated in this forum:
String getFoo(int index)
void setFoo(String foo, int index)
I prefer the former approach except for one minor factor: it doesn't
seem to work. :(
Struts seems to be creating me a valid form. I say this becuase I have
an iterator on my form that displays the right number of rows of text
boxes, and they all have names like mybean[0].foo. Furthermore, if I
change the property attribute of my html:text tag to bar, I get
an
exception when I render the page that there is no bar property.
So things seem to be working well, up to this point, but in the
implementation of the action, my form bean doesn't have any values set.
They're not even blank; they're null. I stuck a println in a setter
method -- it's not even being called.
I can, however, see the values in the request parameters if I print
them
out in the implementation of the action.
Help! Actual code follows.
Thanks in advance,
-- Mike
STRUTS-CONFIG.XML
form-bean name=shipmentFormBean
type=org.apache.struts.action.DynaActionForm
form-property name=action
type=java.lang.String /
form-property name=shipments
type=com.interactivate.cachandler.ShipmentFormBean[]
size=12 /
/form-bean
action path=/data-upload/Shipments
name=shipmentFormBean
forward=shipments.page
scope=request
validate=false
roles=data-upl /
action path=/data-upload/SubmitShipments
type=com.interactivate.cachandler.SubmitShipmentsAction
name=shipmentFormBean
scope=request
validate=true
input=shipments.page
roles=data-upl /
SHIPMENTFORMBEAN.JAVA --
public class ShipmentFormBean
{
private String mDestination;
private String mSize;
private String mVariety;
private String mQuantity;
private String mPrice;
private String mZipCode;
// YANKED A BUNCH OF GETTERS/SETTERS
public String getSize()
{
return mSize;
}
public void setSize(String size)
{
System.out.println(### setting size to + size);
mSize = size;
}
}
SHIPMENTS.JSP
html:form action=/data-upload/SubmitShipments.do
logic:iterate
id=shipment
name=shipmentFormBean
property=shipments
%-- lots of jsp code and html yanked --%
html:select
name=shipment
property=size
indexed=true
option value=70 70 /option
option value=84 84 /option
/html:select
html:select
name=shipment
property=destination
indexed=true
option value= selectedSelect a city/option
option value=- /option
jsp:include page=destinations.jsp /
/html:select
html:text
name=shipment
property=zipCode
indexed=true
size=10
maxlength=5 /
/logic:iterate
/html:form
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]