Hi Richard
Here are the summarized bits
public ArrayList getColours() { return colourList; }
public void setColours(ArrayList colourList) {
this.colourList = colourList;
}//
ProductForm theForm = (ProductForm) form;
theForm.setColours(colourList); ...
<html:select property="colours" multiple="true">
<html:options collection="colours" property="foo" />
</html:select>Everything works (the select menus select the correct values etc, but then when i submit i get the bean utils illegal argument exception.
This worked pretty much in the same way before. Hopefully I'm just missing something simple.
here are my mappings also.
Cheers mark
<action path="/admin/product/view" type="com.boxstuff.shop.admin.ViewProductAction" name="productEditForm" validate="false" scope="session" attribute="productEditForm">
<forward name="success" redirect="false" path="admin.product.view"/>
</action>
<action path="/admin/product/save" type="com.boxstuff.shop.admin.SaveProductAction" name="productEditForm" validate="false" scope="session" input="admin.product.view" attribute="productEditForm">
<forward name="success" path="admin.product.view" redirect="false"/>
</action>
// // ProductForm.java // murphynye // // Created by Mark Lowe on Wed Dec 03 2003. // Copyright (c) 2003 BoxStuff Ltd. All rights reserved. // package com.boxstuff.shop.admin;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.apache.struts.upload.MultipartRequestHandler;
import org.apache.struts.util.MessageResources;
import org.apache.struts.validator.Resources;
import java.util.ArrayList;
import java.math.BigDecimal;
import java.io.ByteArrayInputStream;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.util.Locale;
import java.util.Properties;
import com.boxstuff.struts.StockItemBean;
import java.util.HashMap;
public class ProductForm extends ActionForm {
private String id;
private String name;
private String code;
private Integer deptId;
private Integer catId;
private String desc;
private Integer stockLevelWarn;
private String buyPrice;
private String sellPrice;
private Integer sizeRangeId;
private ArrayList sizeList;
private ArrayList imageList;
private Integer stockWarning;
private Integer fabricId;
private String fabric;
private String department;
private String category;
private ArrayList colourList;
private FormFile imageFile;
private Integer imageType;
private Integer imageColour;
private HashMap stockItemQuantities = new HashMap();
private String salePrice;
public ProductForm() {
this.imageList = new ArrayList();
this.colourList = new ArrayList();
this.sizeList = new ArrayList();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/** name */
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/** code */
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
/** deptId */
public Integer getDepartmentId() {
return deptId;
}
public void setDepartmentId(Integer deptId) {
this.deptId = deptId;
}
/** catId */
public Integer getCategoryId() {
return catId;
}
public void setCategoryId(Integer catId) {
this.catId = catId;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
/** desc */
public String getDescription() {
return desc;
}
public void setDescription(String desc) {
this.desc = desc;
}
/** imageList */
public Object[] getImages() {
return imageList.toArray();
}
public void setImages(ArrayList imageList) {
this.imageList = imageList;
}
public FormFile getImage() {
return imageFile;
}
public void setImage(FormFile imageFile) {
this.imageFile = imageFile;
}
/** sizeRangeId */
public Integer getSizeRange() {
return sizeRangeId;
}
public void setSizeRange(Integer sizeRangeId) {
this.sizeRangeId = sizeRangeId;
}
/** sellPrice */
public String getSellPrice() {
return sellPrice;
}
public void setSellPrice(String sellPrice) {
this.sellPrice = sellPrice;
}
/** buyPrice */
public String getBuyPrice() {
return buyPrice;
}
public void setBuyPrice(String buyPrice) {
this.buyPrice = buyPrice;
}
/** salePrice */
public String getSalePrice() {
return salePrice;
}
public void setSalePrice(String salePrice) {
this.salePrice = salePrice;
}
/** stock warning level */
public Integer getStockWarning() {
return stockWarning;
}
public void setStockWarning(Integer stockWarning) {
this.stockWarning = stockWarning;
}
/* fabric */
public Integer getFabricId() {
return fabricId;
}
public void setFabricId(Integer fabricId) {
this.fabricId = fabricId;
}
public String getFabric() {
return fabric;
}
public void setFabric(String fabric) {
this.fabric = fabric;
}
public ArrayList getColours() {
return colourList;
}
public void setColours(ArrayList colourList) {
this.colourList = colourList;
}
/*
public Object getColour(int i) {
return colourList.get(i);
}
public void setColour(int i,Object colour) {
this.colourList.add(i,colour);
}
*/
public ArrayList getSizes() {
return sizeList;
}
public void setSizes(ArrayList sizeList) {
this.sizeList = sizeList;
}
/*
public Object getSize(int i) {
return sizeList.get(i);
}
public void setSize(int i, Object size) {
this.sizeList.add(i,size);
}
*/
public Integer getImageType() {
return imageType;
}
public void setImageType(Integer imageType) {
this.imageType = imageType;
}
public Integer getImageColour() {
return imageColour;
}
public void setImageColour(Integer imageColour) {
this.imageColour = imageColour;
}
public String getQuantity(String key) {
return stockItemQuantities.get(key).toString();
}
public void setQuantity(String key,String value) {
this.stockItemQuantities.put(key,value);
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
ActionErrors errors = null;
MessageResources mr = Resources.getMessageResources(request);
Locale locale = Resources.getLocale(request);
int imageType = getImageType().intValue();
String imageWidthKey = "product.image.type."+
Integer.toString(imageType) +".width";
String imageHeightKey = "product.image.type."+
Integer.toString(imageType) +".height";
System.out.println(imageWidthKey);
System.out.println(imageHeightKey);
String imageWidth =
Resources.getMessage(mr,locale,imageWidthKey);
String imageHeight =
Resources.getMessage(mr,locale,imageHeightKey);
int w = Integer.parseInt( imageWidth );
int h = Integer.parseInt( imageHeight );
try {
byte[] image = getImage().getFileData();
ByteArrayInputStream stream = new ByteArrayInputStream(image);
BufferedImage img = ImageIO.read(stream);
if(w != img.getWidth() && h != img.getHeight()) {
errors = new ActionErrors();
errors.add("image",new ActionError("product.image.error"));
System.out.println("BAD IMAGE!!!");
} else {
System.out.println("GOOD IMAGE!!!");
}
} catch(Exception e) {
e.printStackTrace();
}
return errors;
}
}
On 13 Jan 2004, at 17:31, Richard Hightower wrote:
I have an idea, but would like to see your html:form and ActionForm before I
ruin my reputation with a bad mojo answer.
Send them directly to me and copy this list.
Rick Hightower Developer
Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting -- http://www.arc-mind.com/consulting.htm#StrutsMentoring
-----Original Message----- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 13, 2004 7:18 AM To: Struts Users Mailing List Subject: Bothersome BeanUtils.populate exception
beanUtils keeps getting its knickers in a twist when i submit a form with 2 select menus with multiple values. I've had this working before with the same version of struts and commons. Its not the action as the exception is thrown before i get that far, when i remove the menus the form submits fine.
I have form properties of type arrayList. I;d expect this exception if i were to be using unsupported types but I've been setting the values with String and the form properties are also of type string.
I have trouble believing that bean utils has an issue with converting Object to String when the values are copied.
The exception is a typical beanutils chocolate fire guard exception. If i weren't using strings i'd understand but i am.
Any insights welcomed.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja v
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso r
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUt i
ls.java:1789)
at
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUt i
ls.java:1684)
at
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.ja v
a:1713)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

