struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Sandy.Verfai...@roularta.be>
Subject integer values in struts forms
Date Thu, 16 Jul 2009 13:47:05 GMT
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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message