You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/03/17 21:15:43 UTC

validating user entered values

in strutsconfig.xml  the form bean attribute has
<form-property name="newBalance" type="java.lang.String"/>


Prepare jsp action
Form1.set("newBalance", "100000");



In jsp I have
<fmt:formatNumber value="${Form1.map.newBalance}" type="currency" 
currencySymbol="" var="newBal"/>
<html:text name="Form1" property="newBalance" value="${newBal}" />

Validator.xml has
<field property="newBalance" depends="double">
                <msg name="double" key="notvalid"/>
</field>


The Dispatch action has
DynaValidatorForm frm = (DynaValidatorForm)form;

        ActionMessages messages = (ActionMessages)frm.validate( mapping, 
request );


when I try to submit  the page/jsp getting Exception
javax.servlet.ServletException: javax.servlet.jsp.JspException: In 
&lt;formatNumber&gt;, value attribute can not be parsed into 
java.lang.Number: "100,000.00"

I understand that the String is entered i.e formbean has String value but 
validating if it's double value.

How to handle such data? user entering in String but have to validate if 
it's double?

Thanks.

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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


Re: validating user entered values

Posted by Niall Pemberton <ni...@gmail.com>.
On 3/17/06, fea jabi <zy...@hotmail.com> wrote:
> in strutsconfig.xml  the form bean attribute has
> <form-property name="newBalance" type="java.lang.String"/>
>
> Prepare jsp action
> Form1.set("newBalance", "100000");
>
> In jsp I have
> <fmt:formatNumber value="${Form1.map.newBalance}" type="currency"
> currencySymbol="" var="newBal"/>
> <html:text name="Form1" property="newBalance" value="${newBal}" />
>
> Validator.xml has
> <field property="newBalance" depends="double">
>                <msg name="double" key="notvalid"/>
> </field>
>
>
> The Dispatch action has
> DynaValidatorForm frm = (DynaValidatorForm)form;
>
>        ActionMessages messages = (ActionMessages)frm.validate( mapping,
> request );
>
>
> when I try to submit  the page/jsp getting Exception
> javax.servlet.ServletException: javax.servlet.jsp.JspException: In
> <formatNumber>, value attribute can not be parsed into
> java.lang.Number: "100,000.00"
>
> I understand that the String is entered i.e formbean has String value but
> validating if it's double value.
>
> How to handle such data? user entering in String but have to validate if
> it's double?

The problem seems to be that your using NumberFormat to try and format
a property thats a String (rather than a Number). Its not even getting
to do any sort of validation - just blowing up trying to display your
page.

If your form property is a String then you need to handle the
formatting before you populate the value to your form.

Niall

> Thanks.

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


RE: validating user entered values

Posted by fea jabi <zy...@hotmail.com>.
can someone help me with this? Thanks.


>From: "fea jabi" <zy...@hotmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: user@struts.apache.org
>Subject: validating user entered values
>Date: Fri, 17 Mar 2006 15:15:43 -0500
>
>in strutsconfig.xml  the form bean attribute has
><form-property name="newBalance" type="java.lang.String"/>
>
>
>Prepare jsp action
>Form1.set("newBalance", "100000");
>
>
>
>In jsp I have
><fmt:formatNumber value="${Form1.map.newBalance}" type="currency" 
>currencySymbol="" var="newBal"/>
><html:text name="Form1" property="newBalance" value="${newBal}" />
>
>Validator.xml has
><field property="newBalance" depends="double">
>                <msg name="double" key="notvalid"/>
></field>
>
>
>The Dispatch action has
>DynaValidatorForm frm = (DynaValidatorForm)form;
>
>        ActionMessages messages = (ActionMessages)frm.validate( mapping, 
>request );
>
>
>when I try to submit  the page/jsp getting Exception
>javax.servlet.ServletException: javax.servlet.jsp.JspException: In 
>&lt;formatNumber&gt;, value attribute can not be parsed into 
>java.lang.Number: "100,000.00"
>
>I understand that the String is entered i.e formbean has String value but 
>validating if it's double value.
>
>How to handle such data? user entering in String but have to validate if 
>it's double?
>
>Thanks.
>
>_________________________________________________________________
>Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
>Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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