You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2005/04/25 21:11:57 UTC

DO NOT REPLY [Bug 34606] New: - Validator plugin with DefaultForm doesn't work

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34606>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34606

           Summary: Validator plugin with DefaultForm doesn't work
           Product: Struts
           Version: Unknown
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P1
         Component: Validator Framework
        AssignedTo: dev@struts.apache.org
        ReportedBy: replytosas@yahoo.com


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>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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