• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

Cannot get Struts validation to work...help!

Can someone tell me what I'm doing wrong?  

-----here is my validation.xml-----

<form-validation>
    <formset>
        <form name="profileUpdateForm">
      <field property="profileData" depends="required">
        <arg0 key="errors.required"/>
      </field>            
       </form>
    </formset>          
</form-validation>

-----END validation.xml-----

------portion(s) of struts-config.xml-------
...

<form-bean name="profileUpdateForm"        type="org.apache.struts.validator.DynaValidatorActionForm">
         <form-property name="prevPo"                    type="java.lang.String"   initial=""/>
        <form-property name="po"                    type="java.lang.String"   initial=""/>
        <form-property name="profileId"           type="java.lang.String[]"/>
        <form-property name="displayLabel"    type="java.lang.String[]"/>        
        <form-property name="profileDataId"        type="java.lang.String[]" initial=""/>
        <form-property name="prevProfileData" type="java.lang.String[]" initial=""/>        
        <form-property name="profileData"     type="java.lang.String[]" initial=""/>                
   </form-bean>

...

<action name="profileUpdateForm" path="/createProfile"
                type="com.sas.mis.ediInterface.actions.ProcessProfileAction" parameter="dispatch"
                input="/profileEdit.jsp" scope="request" validate="true">
            <forward name="success" path="/profilesearch.jsp"/>           
  </action>  

...

<!--  Validator plugin -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
          <set-property
            property="pathnames"
           value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

------ END portion(s) of struts-config.xml-------

------jsp-------

<%@ page import="java.util.Vector, org.apache.struts.util.LabelValueBean"%>
<%@ taglib uri="/WEB-INF/tld/struts-html-el.tld" prefix="html-el"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>


<logic:notPresent name="results">
      <logic:redirect forward="timeout"/>
</logic:notPresent>
<tiles:insert definition="profilesearchresults.layout">
      <tiles:put name="title">
            <bean:message key="title.profileedit" />
      </tiles:put>
      <tiles:put name="tablewidth" value="100%"/>
      <html-el:javascript formName="profileUpdateForm" method="validateForm" dynamicJavascript="true" staticJavascript="true"/>                  
      <tiles:put name="body" type="string">
            
          <tiles:insert definition="errors" flush="false"/>
                             
            <c:choose>
                  <c:when test="${requestScope.createNew}">
                        <c:set var='dispatchValue' value='createNew'/>                        
                  </c:when>
                  <c:otherwise>
                        <c:set var='dispatchValue' value='editData'/>
                  </c:otherwise>
            </c:choose>
            <c:set var='customerName' value='${requestScope.custName}'/>
            <c:set var='customerNumber' value='${requestScope.custNum}'/>            
            <html-el:form action="/createProfile?dispatch=${dispatchValue}&custNum=${customerNumber}&custName=${customerName}">
            
            <html-el:errors/>
                  <table border="1" cellspacing="0" cellpadding="4" width="60%" rules="none">
                  <thead class="headerRow">
                <tr><td><c:out value="Company: "/></td>
                        <td><c:out value="${customerName}"/></td></tr>                              
                  <tr><td><c:out value="Customer Number: "/></td>
                        <td><c:out value="${customerNumber}"/></td></tr>
                  </thead>
                  <tr><td colspan="2"></td></tr>
                  <tr><td><c:out value="Purchase Order"/></td>
                        <c:choose>
                              <c:when test="${empty requestScope.poNum}">
                                    <td><html-el:text property="po"/></td>
                              </c:when>
                              <c:otherwise>
                                    <td>
                                    <c:choose>
                                          <c:when test="${empty requestScope.prevPoNum}">
                                                <html-el:hidden property="prevPo" value="${requestScope.poNum}"/>                                                      
                                          </c:when>
                                          <c:otherwise>
                                                <html-el:hidden property="prevPo" value="${requestScope.prevPoNum}"/>                                                
                                          </c:otherwise>
                                    </c:choose>
                                          <html-el:text property="po" value="${requestScope.poNum}"/>                                          
                                    </td>
                              </c:otherwise>                              
                        </c:choose>
                  </tr>
                  <c:forEach items="${results}" var="profile" varStatus="pIndex">                                                      
                        <tr><td><c:out value="${profile.displayLabel}"/><html-el:hidden property="displayLabel" value="${profile.displayLabel}"/>
                              </td>
                              <td><html-el:hidden property="profileId" value="${profile.profileId}"/>
                              <c:choose>
                              <c:when test="${requestScope.createNew}">
                                    <c:choose>
                                    <c:when test="${requestScope.errNew}">
                                          <c:forEach items="${profile.ediCustData}" var="data" varStatus="dIndex">                                                                              
                                                <html-el:text property="profileData" value="${data.value}"/>
                                          </c:forEach>
                                    </c:when>
                                    <c:otherwise>
                                          <html-el:text property="profileData" value=""/>
                                    </c:otherwise>
                                    </c:choose>                                    
                              </c:when>
                              <c:otherwise>
                                    <c:forEach items="${profile.ediCustData}" var="data" varStatus="dIndex">
                                          <html-el:hidden property="profileDataId" value="${data.profileDataId}"/>
                                          <html-el:hidden property="prevProfileData" value="${data.value}"/>                              
                                          <html-el:text property="profileData" value="${data.value}"/>
                                    </c:forEach>      
                              </c:otherwise>
                              </c:choose>
                        </td></tr>                                                            
                  </c:forEach>                                          
            </table>
            <table class="profileEdit">
                  <tr><td colspan="3"></td>
                        <td>
                        <html-el:button value="Cancel" property="Cancel" onclick="return history.go(-1);"/>      
                        <html-el:submit value="Save"  styleClass="Button" onclick="return validateForm(this);"/></td></tr>                                          
            </table>      
      </html-el:form>
      
    </tiles:put>
</tiles:insert>
------END jsp-------

I apologize for this post being so long, but I wanted to ensure the experts had the appropriate amount of information to answer my question.  My validation simply just doesn't happen.  If I can't get this to work, I'll have to write java classes for my forms and perform the validation that way.  Thanks in advance.
0
ls_hamlet
Asked:
ls_hamlet
  • 3
1 Solution
 
ls_hamletAuthor Commented:
Increasing the points because I need assistance as quickly as possible.  Thanks!
0
 
topher1120Commented:
I haven't dealt with validating arrays, so I'm not sure if you need the "indexed" attribute on the form or not and couldn't find any good documentation on when to use that attribute.  One thing I did notice is <arg0 key="errors.required"/> should actually be a label key for the value or the value itself.  For example: <arg0 key="Profile Data" resource="false" />.  errors.required is the default error message key for the "required" validator.  If you wanted to change the actual message, then you should use <msg />.  
0
 
ls_hamletAuthor Commented:
Thanks for your correction...it didn't solve my problem, but I thank you for your input.
0
 
ls_hamletAuthor Commented:
Solved it myself...the jakarta-oro.jar file was not being included in my war file for deployment.
0
 
PashaModCommented:
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now