I use Struts 1.0 and Tomcat 3.2.3

I looked at your validator example again and began to see that numeric fields
in form are defined in String.
I deduce the problem is in my design. My Meter bean has meter1 of type 'int'
The getMeter1 returns 'int' and setMeter1 has 'int' in signature.

It works without valdiation (as in struts-exercise-taglib) so I didnt think it
could cause problem with Validator.

Am I right?

SooAun

David Winterfeldt wrote:

> What version of struts are you using?  Struts 1.0?
> Also what servlet container and version are you using?
>
> David
>
> --- Ho Soo Aun <[EMAIL PROTECTED]> wrote:
> > Had I missed any step?
> > Been trying to implement David's Struts Validator
> > for quite a while.
> >
> > Every time I access a editmeter.jsp through an
> > action which populate the
> > fields.
> > Tomcat 3.2.2 console show  "Validator::validate()
> > reflection - null"
> > twice
> > Enter char in int field (to be validate) is saved as
> > '0'. No validation
> > was done.
> > There was no other error message on browser or log
> > file.
> >
> > # 1  Got Struts_Validator-20010702.jar in
> > WEB-INF/lib
> >
> > # 2  Got jakarta-regexp-1.2.jar in WEB-INF/lib
> >
> > # 3  Set this in web.xml
> > <servlet>
> >     <servlet-name>validator</servlet-name>
> >
> >
> <servlet-class>com.wintecinc.struts.action.ValidatorServlet</servlet-class>
> >
> >     <init-param>
> >       <param-name>config</param-name>
> >
> > <param-value>/WEB-INF/validation.xml</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>debug</param-name>
> >       <param-value>2</param-value>
> >     </init-param>
> >     <load-on-startup>2</load-on-startup>
> >   </servlet>
> > # 4  In struts-config.xml
> >  <action path="/editmetererror"
> >    type="sg.com.trek.mims5.meter.MeterAction"
> >    name="meterForm"
> >    input="editmeter.jsp"
> >    scope="request"
> >    validate="true">
> >   <forward name="success"  path="/editmeter.jsp"/>
> >  </action>
> >
> > # 5 In addition to <global> setting in
> > validation.xml
> > #    add a form and one to test
> >    <formset>
> >     <form name="meterForm">
> >      <field property="meter.meter1"
> >       depends="required,integer">
> >       <arg0 key="meterForm.integer.displayname"/>
> >      </field>
> >     </form>
> >    </formset>
> >
> > # 6 In editmeter.jsp
> > <html:form action="/editmetererror" name="meterForm"
> > type="sg.com.trek.mims5.meter.MeterForm"
> > focus="copierid"
> > onsubmit="return validateMeterForm(this);">
> > ...
> > <td align="right" nowrap><bean:message
> > key="meter.label.meter1"/>:</td>
> > <td align="left">&nbsp;<html:text name="meterForm"
> > property="meter.meter1" size="7"
> > maxlength="7"/></td>
> > <td>&nbsp;</td>
> > </tr>
> > ...
> > <td align="right" colspan="2">&nbsp;<html:submit
> > property="action"
> > value="Update"
> >
> onclick="bCancel=false;">ENTER</html:submit>&nbsp;<html:cancel
> > onclick="bCancel=true;javascript:window.close()"
> > value="Cancel">CANCEL</html:cancel></td>
> >
> > # 7 In Meterform.java
> > import com.wintecinc.struts.action.ValidatorForm;
> >
> > import sg.com.trek.mims5.business.Meter;
> >
> > public final class MeterForm extends ValidatorForm
> > implements
> > Serializable {
> >
> >  private String action = "Edit";
> >  /**
> >   * Member variable declaration
> >   */
> >  private Meter meter = null;
> >
> >  public Meter getMeter() {
> >   if ( meter == null) {
> >    meter = new Meter();
> >   }
> >   return meter;
> >  }
> > ......
> >
> > # 8 Getter and setter for field meter1 are in Meter
> > bean
> >
> >
> > Any one help
> >
> >
> > Soo Aun
> >
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/

Reply via email to