struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Abdul Qayyum <>
Subject struts2 - <s:testfield exception for long type
Date Mon, 08 Jun 2009 21:36:02 GMT
I am doing a simple CURD using Struts 2 and Hibernatge3. I am using a Long
type in my bean for a property as
     private Long priceMrp;

Since this property has a Long type, its getter and setter correspondingly
use Long type in the model bean.

 public Long getPriceMrp() {
        return this.priceMrp;

    public void setPriceMrp(Long priceMrp) {
        this.priceMrpPerPiece = priceMrp;

In my action I am creating a private object for this model with getter and
setter and using <s:textfield to pass input to these fields.

<s:textfield required="true" requiredposition="left" maxLength="10"
label="MRP" name="price.priceMrp" title="Enter price "/>

While evaluating the framework is expecting getter and setter to be using
String and since it does not find them an ognl expression is being thrown as

setting value
ognl.MethodFailedException: Method "setPriceMrpPerPiece" failed for object [java.lang.NoSuchMethodException:
 at ognl.OgnlRuntime.callAppropriateMethod(

I want to know if there is any standard way to solve this problem in Struts
2. What is the best way to address this problem.

Should i create the property priceMrp in my action and have it use "String"
type then do the assignment myself like
price.setpriceMrp( Long.valueOf("strPriceValue"); //is this approach valid

Please suggest. Thanks in Advance
Abdul Sagri

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