You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pranav <me...@yahoo.com> on 2008/04/24 03:01:34 UTC
Problem with Validation framework
Hi All,
I am having a problem with validation framework. This is the first time I am trying to use struts2 validation. Here's different code pieces that I have.
######## UserLookupAction-validation.xml
<validators>
<field name="memberId">
<field-validator type="requiredstring">
<message>You must enter a value for Member ID.</message>
</field-validator>
<field-validator type="stringlength">
<param name="maxLength">20</param>
<message>
Member ID cannot contain more than 20 characters
</message>
</field-validator>
</field>
</validators>
########### finduser.jsp
<s:head theme="ajax"/>
<body>
<s:form
id='MemberInputForm'
action='LookupUser'
method='post'
theme="ajax"
validate="true">
<table>
<tr>
<td>Find user record by Member ID: </td>
<td><input type='text' name='memberId' value=''></td>
<td><s:submit value="Find User" theme="ajax" targets="userDetailsDiv" onLoadJS="initializeAppDropdowns(data, type)"/></td>
</tr>
</table>
</s:form>
<div id='userDetailsDiv' style="border: 1px solid #FF9900"><b>initial content</b></div>
</body>
########## struts.xml
<action name="LookupUser" class="com.intuit.sbfw.action.mc.UserLookupAction">
<result name="input">/html/finduser.jsp</result>
<result>/html/finduserResult.jsp</result>
</action>
Notes:
1) My package extends from struts-default and so I am using the defaultStack.
2) My Action class UserLookupAction extends from ActionSupport class.
Questions:
1) I am not seeing any validation error even when i leave the memberId as blank. The log file does not say anything at all. Is it because I am using theme as "ajax"?
2) I see this message when I invoke my very first action: INFO [ActionValidatorManagerFactory] Detected AnnotationActionValidatorManager, initializing it...
Does this mean that I have to use Annotation only to configure the validation rules and I cannot use the xml approach?
3) What could be wrong with my setup so that my validation classes are not working?
Thanks
Pranav
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with Validation framework
Posted by Lukasz Lenart <lu...@googlemail.com>.
> <action name="LookupUser"
> class="com.intuit.sbfw.action.mc.UserLookupAction">
UserLookupAction-validation.xml is in the same path as class above?
> 2) I see this message when I invoke my very first action: INFO
> [ActionValidatorManagerFactory] Detected AnnotationActionValidatorManager,
> initializing it...
> Does this mean that I have to use Annotation only to configure the
> validation rules and I cannot use the xml approach?
No, you can, but you can also use in the same time xml base validation
> 3) What could be wrong with my setup so that my validation classes are not
> working?
>
Check if xml file is in the same path when you deploy your application. Do
you use maven2?
Regards
--
Lukasz
http://www.linkedin.com/in/lukaszlenart
RE: Problem with Validation framework
Posted by Sanjeewa Saman <sa...@mubasher.net>.
HI
I hope that this will help you
http://struts2issues.blogspot.com/
BR,
sanj
-----Original Message-----
From: Pranav [mailto:mehta_pranav@yahoo.com]
Sent: Thursday, April 24, 2008 6:32 AM
To: user@struts.apache.org
Subject: Problem with Validation framework
Hi All,
I am having a problem with validation framework. This is the first time I am
trying to use struts2 validation. Here's different code pieces that I have.
######## UserLookupAction-validation.xml
<validators>
<field name="memberId">
<field-validator type="requiredstring">
<message>You must enter a value for Member ID.</message>
</field-validator>
<field-validator type="stringlength">
<param name="maxLength">20</param>
<message>
Member ID cannot contain more than 20 characters
</message>
</field-validator>
</field>
</validators>
########### finduser.jsp
<s:head theme="ajax"/>
<body>
<s:form
id='MemberInputForm'
action='LookupUser'
method='post'
theme="ajax"
validate="true">
<table>
<tr>
<td>Find user record by Member ID: </td>
<td><input type='text' name='memberId' value=''></td>
<td><s:submit value="Find User" theme="ajax"
targets="userDetailsDiv" onLoadJS="initializeAppDropdowns(data,
type)"/></td>
</tr>
</table>
</s:form>
<div id='userDetailsDiv' style="border: 1px solid #FF9900"><b>initial
content</b></div>
</body>
########## struts.xml
<action name="LookupUser"
class="com.intuit.sbfw.action.mc.UserLookupAction">
<result name="input">/html/finduser.jsp</result>
<result>/html/finduserResult.jsp</result>
</action>
Notes:
1) My package extends from struts-default and so I am using the
defaultStack.
2) My Action class UserLookupAction extends from ActionSupport class.
Questions:
1) I am not seeing any validation error even when i leave the memberId as
blank. The log file does not say anything at all. Is it because I am using
theme as "ajax"?
2) I see this message when I invoke my very first action: INFO
[ActionValidatorManagerFactory] Detected AnnotationActionValidatorManager,
initializing it...
Does this mean that I have to use Annotation only to configure the
validation rules and I cannot use the xml approach?
3) What could be wrong with my setup so that my validation classes are not
working?
Thanks
Pranav
____________________________________________________________________________
________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org