struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paweł Wielgus <poulw...@gmail.com>
Subject Re: struts2 - <s:testfield exception for long type
Date Tue, 09 Jun 2009 07:49:59 GMT
Hi Abdul,
the error log You have shown states that the setPriceMrpPerPiece
method is causing a problem,
so look again in Your app, add some debuging. Converting from/to Long
should work out of the box.

Best greetings,
Paweł Wielgus.


2009/6/8 Abdul Qayyum <qayyum4@gmail.com>:
> Hi,
> 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
> follows:
>
> [#|2009-06-09T02:09:30.504+0530|WARNING|sun-appserver9.1|com.opensymphony.xwork2.ognl.OgnlValueStack|_ThreadID=19;_ThreadName=httpSSLWorkerThread-14859-1;_RequestID=989f204d-78dd-4aae-9835-fddb0969e318;|Error
> setting value
> ognl.MethodFailedException: Method "setPriceMrpPerPiece" failed for object
> com.sagri.app.model.Price@47808b [java.lang.NoSuchMethodException:
> setPriceMrp([Ljava.lang.String;)]
>  at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823)
>
>
> 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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message