Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

struts validator not working

843838Aug 9 2005 — edited Sep 18 2008
Hi,
I am using Struts/JSP for a database web app. I list out a table of items and edit them. I'm using the validator plug-in to validate edit of items.. but when I click on edit.. nothing happens and it goes back to the table of items.. Any suggestions?
my code is as follows..
struts-config.xml
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
<struts-config>
    <!-- Form Bean Definitions -->
    <form-beans>
        <form-bean name="editForm" type="com.zz.yy.displayBean"/> 
    </form-beans>
    <!--  Action Mapping Definitions  -->
    <action-mappings>
        <action path="/requestDispatcher"         	
            type="com.zz.yy.RequestDispatcherAction"
            name="editForm"
            scope="request"
            validate="true"
            >
            <forward name="showtable"
                    path="/showtablejsp"/>
            <forward name="editrow" 
            	path="/editrow.jsp"/>
            <forward name="failure"
                    path="/failure.jsp"/>
        </action>
    </action-mappings>
    <!-- message resources -->
    <message-resources
        parameter="resources_en_US"
        null="false" />
    <!-- validator -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
                                              /WEB-INF/validation.xml"/>
    </plug-in>
</struts-config>
validation.xml
<form-validation>
    <formset>
        <form name="editForm">
            <field property="userid"
                depends="required">
                <arg0 key="userid.display"/>
            </field>
        </form>
    </formset>    
</form-validation>
validator-rules.xml that i am using is the same as the default.

editrow.jsp
   
<%@ taglib uri="struts/bean-el" prefix="bean" %>
<%@ taglib uri="struts/html-el" prefix="html" %>
<%@ taglib uri="struts/logic-el" prefix="logic" %>
<html>
<head>
</head>
<body>
    <logic:messagesPresent>
        <span id="errorsHeader"><bean:message key="errors.validation.header"/></span>
        <html:messages id="error">
          <li><c:out value="${error}"/></li>
        </html:messages>
        <hr>
    </logic:messagesPresent>

<html:form action="/requestDispatcher" focus="symbol" method="post">
    <table>
	<tr>
	    <td><bean:message key="userid.label"/></td>
	    <td><html:text name="editForm" property="userid"/></td>
	</tr>
    </table>
    <html:submit><bean:message key="edit.title"/></html:submit>
    </html:form>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2008
Added on Aug 9 2005
8 comments
3,844 views