[ http://issues.apache.org/struts/browse/STR-2438?page=all ]
David Evans resolved STR-2438:
------------------------------
Resolution: Fixed
> Validator plugin with DefaultForm doesn't work
> ----------------------------------------------
>
> Key: STR-2438
> URL: http://issues.apache.org/struts/browse/STR-2438
> Project: Struts Action 1
> Type: Bug
> Components: Action
> Versions: Unknown
> Environment: Operating System: Windows XP
> Platform: PC
> Reporter: Saju
> Assignee: David Evans
>
> Following is the code snippet from the DefaultForm class.
> public class DefaultForm extends ValidatorForm {
> protected final Log log = LogFactory.getLog(getClass());
> private Map dto = new HashMap();
> /**
> * Sets a value into dtoMap. This value can be refered by Struts HTML tags
> * with <code>dto(<field name>)</code> syntax.
> */
> public void setDto(String key, Object val) {
> dto.put(key, val);
> }
> /**
> * Gets a value from dtoMap.
> */
> public Object getDto(String key) {
> return dto.get(key);
> }
> /**
> * Returns dtoMap
> */
> public Map getDtoMap() {
> return dto;
> }
> public void reset(ActionMapping arg0, HttpServletRequest arg1) {
> super.reset(arg0, arg1);
> dto.clear();
> }
> /**
> * Validates entries of dtoMap by Strut's validator.
> *
> * @see org.apache.struts.action.ActionForm#validate
> (org.apache.struts.action.ActionMapping,
> javax.servlet.http.HttpServletRequest)
> */
> public ActionErrors validate(
> ActionMapping mapping,
> HttpServletRequest request) {
>
> ServletContext application = getServlet().getServletContext();
> ActionErrors errors = new ActionErrors();
>
>
>
> Validator validator =
> Resources.initValidator(
> mapping.getAttribute(),
> dto,
> application,
> request,
> errors,
> page);
> try {
> validatorResults = validator.validate();
>
> } catch (ValidatorException e) {
> log.error(e.getMessage(), e);
> }
>
> return errors;
> }
> But the validation is not working. It doesn't give any error but the
> validation doesn't work also.
> Following are the config's file details
> struts-config.xml:
> <struts-config>
> <form-beans>
> <form-bean name="loginForm" type="com.DefaultForm"/>
> </form-beans>
>
> <global-exceptions>
> </global-exceptions>
> <global-forwards>
> </global-forwards>
> <action-mappings>
> <action path="/loginAction" type="com.DefaultAction"
> name = "loginForm" scope="request" input="/resources/jsp/login.jsp"
> validate="true">
>
> <forward name="success" path="/resources/jsp/Welcome.jsp" />
> <forward name="error" path="/resources/jsp/login.jsp" />
> </action>
> </action-mappings>
> <message-resources null="false"
> parameter="resources.prop.ApplicationResources"/>
> <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
> <set-property property="pathnames"
> value="validator-rules.xml,
> validation.xml" />
> </plug-in>
> </struts-config>
> validation.xml:
> <form-validation>
> <formset>
> <form name="loginForm">
> <field property="loginUserId" depends="required">
> <arg0 key="label.userID"/>
> </field>
> <field property="loginPassword" depends="required">
> <arg0 key="label.password"/>
> </field>
> </form>
> </formset>
> </form-validation>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]