Thanks for helping

here is the strutsProduct.xml ::


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>

<struts>
<package name="PRODUCT" extends="custom-default">

        <action name="EditOption" method="editOption"
class="ttc.action.ProductAction">
            <result name="success" type="redirectAction">
            <param name="parse">true</param>
            <param name="actionName">InfoProduct</param>
            <param name="id">${idProduct}</param>
            </result>
            <result name="error">/pages/error/role.jsp</result>
            <result name="input">/pages/product/infoOption.jsp</result>
        </action>

        <action name="InfoOption" method="optionAction"
class="ttc.action.ProductAction">
            <result name="success">/pages/product/infoOption.jsp</result>
            <result name="error">/pages/error/role.jsp</result>
        </action>

        <action name="InfoProduct" method="findProduct"
class="ttc.action.ProductAction">
            <result name="success">/pages/product/infoProduct.jsp</result>
            <result name="error">/pages/error/role.jsp</result>
        </action>

</package>
</struts>


here is the form ::


<s:form action="EditOption" method="POST" enctype="multipart/form-data"
id="EditProductForm" theme="simple">
    <table width="550px;">
<tr><td>Title : </td><td><s:textfield name="titleOption"/></td></tr>
 <tr><td>Description : </td><td><s:textarea
name="descriptionOption""/></td></tr>
<tr><td>Price : </td><td><s:textfield name="priceOption""/></td></tr>
</table>
</s:form>


here is the action into ProductAction ::


public String editOption() {

      ProductOption opt = new ProductOption();

     opt.setTitle(this.titleOption);
      opt.setDescription(this.descriptionOption);
     opt.setPrice(this.priceOption);
      this.serviceFactory.getOptionService().save(opt);

     return execute();
    }

I get the field priceOption into editOption() in ProductAction, priceOption
is a float type.
In debug, i get this error : ognl.NoConversionPossible.
If i want this working, i have to send priceOption into a string in
editOption() and parse into a float, then i can set the attribute and save
the option.
The model Product has a float type for price.


On Fri, Jul 2, 2010 at 3:28 AM, Ken <ken.mcwilli...@aerose.com> wrote:

> Please provide a trimmed down version of the form, the action bean and
> the struts.xml file (if there is one) showing the issue.
>
>
> On Thu, 2010-07-01 at 15:04 +0800, Stephane Cosmeur wrote:
>
> > Hello struts users
> >
> > We are facing a strange problem. We submit a form with textfields which
> > contain some float numbers.
> > When the entity is loaded the numbers appears in the textfield like this
> :
> > x.x
> > But when we submit the form, it is the input result which is returned. If
> we
> > change the numbers like this : x,x the form is accepted.
> > According to our research, it would be a problem of conversion type in
> > ognl.
> >
> > We are working on Struts 2.0.3, and we tried Struts 2.1.8.1 and the
> problem
> > persisted.
> >
> > Any help would be greatly accepted !
> >
> > Regards
>
>
>
>
>
>
>
>
>
>


-- 
Stéphane Cosmeur

Reply via email to