Link to home
Start Free TrialLog in
Avatar of jaggernat
jaggernat

asked on

problem with struts validation

hi experts,

I am using struts in Jbuilder 2005 with weblogic application server.
For some reason my field validations are not getting enabled.

My JSP page----------

<html:form action="/incidentManagement.do?method=saveIncidentType" method="post">
<html:errors/>

<table width="100%" border="0" cellspacing="1" cellpadding="0">
                            <html:text styleClass="formstyle" property="submittingOrganization" size="20"/>
                          </table>
</html:form>

MY STRUTS CONFIG--------

<action name="incidentsBn" path="/incidentManagement" parameter="method" validate="true"
            input="/WEB-INF/pages/commandcenter/incidents/heprCCCAddIncident.jsp"   type="gov.njdhss.hippocrates.commandcenter.action.incidents.IncidentsAction">

            <forward name="listIncidents"
                   path="/incidentManagement.do?method=listIncidents" />
            <forward name="listIncidentsPg"
                   path="/WEB-INF/pages/commandcenter/incidents/heprCCCListIncidents.jsp" />
            <forward name="findIncidentsPg"
                   path="/WEB-INF/pages/commandcenter/incidents/heprCCCFindIncidents.jsp" />
            <forward name="listFoundIncidentsPg"
                    path="/WEB-INF/pages/commandcenter/incidents/heprCCCFoundIncidents.jsp" />
            <forward name="updateIncidentsPg"
                   path="/WEB-INF/pages/commandcenter/incidents/heprCCCUpdateIncident.jsp" />
            <forward name="errorIncidents"
                   path="/WEB-INF/pages/commandcenter/incidents/heprCCCErrorIncident.jsp" />
            <forward name="incidentConfirmationPg"
                   path="/WEB-INF/pages/commandcenter/incidents/heprCCCIncidentConfirmation.jsp" />
            <forward name="createIncidentsLocationPg"
                  path="/WEB-INF/pages/commandcenter/incidents/heprCCCAddIncident.jsp" />
            <forward name="createIncidentsPg"
                  path="/WEB-INF/pages/commandcenter/incidents/heprCCCAddIncident.jsp" />
      </action>


 <form-bean name="incidentsBn" dynamic="true"
              type="gov.njdhss.hippocrates.commandcenter.action.incidents.IncidentsFormBean"/>


MY VALIDATION.XML fILE------------

<form name="incidentsBn">


<field property="submittingOrganization" depends="required">
<arg0 key="submittingOrganization.msg"/>
</field>


</form>


AND MY APPLICATION RESOURCEs
#Errors messages
errors.required={0} is Required.
submittingOrganization.msg = Submitting Organization




any help would be greatly appreciated

thanks ,
J
Avatar of Acton Wang
Acton Wang
Flag of United States of America image

did you put the following in your struts-config.xml ?


      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
      </plug-in>
Also, make sure your formbean extends ValidatorForm.

Acton
Avatar of jaggernat
jaggernat

ASKER

yes i did put the plug-in

also , this is my dtd info in validatio.xml file .
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

>>>>>Also, make sure your formbean extends ValidatorForm

 does validation framework not work with Action Forms?
>> does validation framework not work with Action Forms?

     In order to trigger the validation, you need to extends ValidatorForm.
ValidatorForm is a subtype of Action Form which provides you validation capability.

If you just extend normal ActionForm, validation function will be turned on automactically.

see this:
http://www.oracle.com/technology/oramag/oracle/04-jan/o14dev_struts.html
i cannot use ValidaorForm now. we have completed 50% of the project using Actionform. Is there any other alternative

ASKER CERTIFIED SOLUTION
Avatar of Acton Wang
Acton Wang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>>only incidentsFormBean has to be changed

so does that mean i have to avoid using IncidentsformBean(action form) and put all the fields in struts config under <form-bean name=IndcidentformBean type="...DynavalidatorForm"..> tag