struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From panti...@firstenergycorp.com
Subject Looking for a tutorial or complete example of using DynaValidatorForm
Date Sun, 09 Apr 2006 03:09:52 GMT
Hello,

I have been using Struts for awhile but it was a very old (1.02) version.
Just finished upgrading my apps to Struts 1.2.7 and would like to take
advantage of the DynaValidatorForm.

I've found several articles on it and many examples. However, I haven't
found one that includes a complete example app and I am having trouble
getting it to work properly with the pieces I have.

Basically, what I want to do is create the form dynamically in the
struts-config.xml file, define the error messages in a properties file and
define the validations in a validator.xml file.

Here is what I have so far. When I try to to run my "dyna.jsp" I get a
"javax.servlet.jsp.JspException: null" error. I'v'e put breakpoints in my
action class but it never gets that far.

Any help would be greatly appreciated.

***STRUTS-CONFIG.XML
<struts-config>
<form-beans>
 <form-bean name="dynaForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="customer" type="java.lang.String"/>
    <form-property name="email" type="java.lang.String"/>
  </form-bean>
</form-beans>
<action-mappings>
  <action path="/dynaTest" type="com.firstenergycorp.dzp.DynaTester"
    name="dynaForm"
    validate="true"
    scope="request"
    input="/dyna.jsp">
    <forward name="/success" path="/thank_you.html"/>
  </action>
</action-mappings>
<message-resources parameter="application"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
  <set-property property="pathnames"
      value="/WEB-INF/validator-rules.xml,/WEB-INF/validator.xml"/>
</plug-in>
</struts-config>

***WEB.XML
<web-app>
    <display-name>WEB APP</display-name>
    <description>WEB APP description</description>
     <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet
</servlet-class>
        <init-param>
            <param-name>application</param-name>
            <param-value>ApplicationResources</param-value>
        </init-param>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>validate</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
     <servlet>
        <servlet-name>dyna.jsp</servlet-name>
        <jsp-file>/dyna.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
</web-app>


***VALIDATOR.XML
<form-validation>
<formset>
<form name="dynaForm">
  <field property="customer" depends="required">
    <msg name="required" key="error.customer"/>
  </field>
</form>
</formset>
</form-validation>

***DYNA.JSP
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<body>
<html:form action = "/dynaTest">
Customer Name:*<html:text property="customer" /><br><br>
      email:*<html:text property="email" /><br><br>
<html:submit>Submit</html:submit>
</html:form>
</body>
</html>



-----------------------------------------
The information contained in this message is intended only for the
personal and confidential use of the recipient(s) named above. If
the reader of this message is not the intended recipient or an
agent responsible for delivering it to the intended recipient, you
are hereby notified that you have received this document in error
and that any review, dissemination, distribution, or copying of
this message is strictly prohibited. If you have received this
communication in error, please notify us immediately, and delete
the original message.


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


Mime
View raw message