You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sa...@roularta.be on 2009/07/16 15:47:05 UTC

integer values in struts forms

Hi,
 
I have made a struts form:
<s:form action="addProduct" method="POST" >
Name nl<s:textfield name="productNameNl" />
price: <s:textfield name="productPrice" value=""/>
</s:form>

and the mapped actionclassmethod addProduct with:

public String addProduct(){
Product p = new Product(productNameNl, productPrice);
ProductDA.getInstance().addProduct(p);
return SUCCESS;
}

public void setProductNameNl(String productNameNl) {
this.productNameNl = productNameNl;
}

public String getProductNameNl() {
return productNameNl;
}

public void setProductPrice(double productPrice) {
this.productPrice = productPrice;
}

public double getProductPrice() {
return productPrice;
}

 

When I run my jsp with that form, everything goes well when I enter for
example 3 or 5 in the pricebox.

But when I enter 0 (not the letter O, but zero), 0,0 or a letter i get
the error message:

/-- Encapsulated exception ------------\

java.lang.NoSuchMethodException: setProductPrice([Ljava.lang.String;)

 

Why doesn't it recognize a zero as a double, but as a string?

I think with a validation xml the problem with the letters will be
solved?

 

Any help would be appreciated!

 

Thx,

Sandy