[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot get Struts validation to work...help!

Posted on 2006-05-30
6
Medium Priority
?
431 Views
Last Modified: 2013-11-24
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
Comment
Question by:ls_hamlet
  • 3
5 Comments
 

Author Comment

by:ls_hamlet
ID: 16793750
Increasing the points because I need assistance as quickly as possible.  Thanks!
0
 
LVL 2

Expert Comment

by:topher1120
ID: 16795613
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
 

Author Comment

by:ls_hamlet
ID: 16799846
Thanks for your correction...it didn't solve my problem, but I thank you for your input.
0
 

Author Comment

by:ls_hamlet
ID: 16801833
Solved it myself...the jakarta-oro.jar file was not being included in my war file for deployment.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 16835014
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question