Adam
On 04/05/2004 07:44 PM Niall Pemberton wrote:
With your configuration validator will forward to /PrepaidAccountInfo.do if validation errors are found - because thats what you set up as the "input" in your "/prepaid" action mapping - is that not happening?
Niall
----- Original Message ----- From: "Skip Hollowell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 05, 2004 6:14 PM
Subject: Problem with DynaValidatorForm
OK, I have a lot of things going on in my app, and something is cancelling out my Validation, and I don't know what. I load the PrepaidAccoundInfo.do action, and the Tiles based page loads properly. I am able to submit the form on this page, and it loads the prepaid.do action just fine, and r emembers the bean info and redisplays it properly, but the data is not validated. I can omit any of the required fields, and the AccountNum can be entered as anything, not just an int.
I have tryed renaming some of my paths, but they all appear to be correct. Is the SAIF Intereceptor causing the problem? My next test will be to remove it, but I was wondering if anyone had incorporated all of these things together before.
- DynaValidatorForm (I need to validate my user entered data, and I am using lots of forms throughout the system) - SAIF (I Want to be able to perform some common logic on all the actions, for user authentication and authroization type functionality mainly. Tabs and actions will be available based upon what rights the user has) - Tiles for easy page creation (tabBar, header, body, footer)
Thoughts? Help? Possible alternatatives? All would be greatly appreciated.
Skip Hollowell
struts-config.xml: ========================================================= <form-beans > <form-bean name="registerForm"
type="skipdaddy.struts.form.RegisterForm">
</form-bean> <form-bean name="prepaidDynaValidatorForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="parmVRUCode" type="java.lang.String" /> <form-property name="parmAccountNum" type="java.lang.String" /> <form-property name="parmDnis" type="java.lang.String" /> </form-bean> </form-beans>
<global-forwards > <forward name="PrepaidAccountInfo" path="/PrepaidAccountInfo.do" /> </global-forwards>
<action-mappings > <action path="/prepaid" type="skipdaddy.struts.action.PrepaidDynaAction" name="prepaidDynaValidatorForm" input="/PrepaidAccountInfo.do" scope="session" validate="true" > <forward name="success" path="/PrepaidAccountInfo.do" /> <forward name="failure" path="/failure.html" /> </action>
<action path="/PrepaidAccountInfo" type="org.apache.struts.actions.ForwardAction" parameter=".prepaid.accountInfoLayout" />
</action-mappings>
<plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> <set-property property="moduleAware" value="true" /> <set-property property="definitions-parser-validate" value="true" /> </plug-in> <!-- end comment if struts1.0.x -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml" /> <set-property property="definitions-debug" value="1" /> </plug-in>
<plug-in className="net.sf.struts.saif.SAIFPlugin"> <set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" /> </plug-in>
validation.xml: ============================== <formset> <form name="prepaidDynaValidatorForm"> <field property="parmVRUCode" depends="required"> <arg0 key="prepaid-vru.displayname"/> </field> <field property="parmAccountNum" depends="required,integer"> <arg0 key="prepaid-pin.displayname"/> </field> <field property="parmDnis" depends="required,integer"> <arg0 key="prepaid-dnis.displayname"/> </field> </form> </formset>
header.jsp (part of my tile) ============================================= <table id="getaccnt" align="center" width="95%"> <html:form action="/prepaid" focus="parmAccountNum"> <html:hidden property="parmAction" value="hld"/> <tr> <td id="staticVrucode" align="right">VRUCode </td> <td align="left"><html:text property="parmVRUCode" size="10" maxlength="10"/></td> <td> </td> </tr>
PrepaidDynaAction.java: ================================================ /Created by MyEclipse Struts // XSL source (default):
platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_2.6.200/xslt/
JavaClass.xsl
package skipdaddy.struts.action;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.tiles.actions.TilesAction; import org.apache.struts.validator.DynaValidatorForm;
/** * MyEclipse Struts * Creation date: 01-13-2004 * */ public class PrepaidDynaAction extends TilesAction {
// --------------------------------------------------------- Instance Variables
// --------------------------------------------------------- Methods
/** * Method execute * @param ActionMapping mapping * @param ActionForm form * @param HttpServletRequest request * @param HttpServletResponse response * @return ActionForward * @throws Exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //String parmAccountNum = prepaidForm.getParmAccountNum(); // String parmDnis = prepaidForm.getParmDnis(); //String parmVruCode = prepaidForm.getParmVRUCode();
DynaValidatorForm prepaidDynaValidatorForm = (DynaValidatorForm)form; System.out.println(prepaidDynaValidatorForm.toString()); String parmAccountNum = request.getParameter("parmAccountNum"); String parmDnis = request.getParameter("parmDnis"); String parmVruCode = request.getParameter("parmVRUCode");
System.out.println( "Entering the ActionForward in PrepaidAction" + request.getParameter("parmAccountNum")); if (parmAccountNum.equals(parmAccountNum)) { System.out.println("PrepaidAction: SUCCESS"); return mapping.findForward("success"); } else { System.out.println("PrepaidAction: FAILURE"); return mapping.findForward("failure"); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- struts 1.2 + tomcat 5.0.19 + java 1.4.2 Linux 2.4.20 Debian
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]