Re: Validator::validate() reflection - null

2001-08-21 Thread Ho Soo Aun

Thanks David,
The error comes from the definitions in global tag of my  validation.xml.
I could have copied them from one of samples which i tried.
Replaced them from the example in 20010702 and it works as expected

SooAun

David Winterfeldt wrote:

 I didn't think it would cause a problem.  I'll look
 over it again.  If a field is of type int, you don't
 need to validate to see if it is an int.  Also if you
 have a field defined as an int, then you don't know if
 someone entered something bad because you will always
 get the default value of the field.  So on the
 ActionForm level it is good to preserve the user's
 input so if it fails validation you can return the
 value the user entered so it can be corrected.  So an
 ActionForm normally uses Strings except for
 checkboxes, radio buttons, and select boxes where you
 know the user can't enter anything bad.  Then you can
 have a bean with all the correct types (int, Date,
 etc.), and convert the ActionForm's values to the
 other bean.  There are a couple of transformation
 packages posted to help with doing this type of
 conversion between objects.  Here is the link.

 http://www.husted.com/about/struts/resources.htm

 David

 --- Ho Soo Aun [EMAIL PROTECTED] wrote:
  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-namevalidator/servlet-name
   
   
  
 
 servlet-classcom.wintecinc.struts.action.ValidatorServlet/servlet-class
   
init-param
  param-nameconfig/param-name
   
   
  param-value/WEB-INF/validation.xml/param-value
/init-param
init-param
  param-namedebug/param-name
  param-value2/param-value
/init-param
load-on-startup2/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 nowrapbean:message
key=meter.label.meter1/:/td
td align=leftnbsp;html:text
  name=meterForm
property=meter.meter1 size=7
maxlength=7//td
tdnbsp;/td
/tr
...
td align=right colspan=2nbsp;html:submit
property=action
value=Update
   
  
 
 onclick=bCancel=false;ENTER/html:submitnbsp;html:cancel
onclick=bCancel=true;javascript:window.close()
value=CancelCANCEL/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/
 

 

Re: Validator::validate() reflection - null

2001-08-20 Thread David Winterfeldt

I didn't think it would cause a problem.  I'll look
over it again.  If a field is of type int, you don't
need to validate to see if it is an int.  Also if you
have a field defined as an int, then you don't know if
someone entered something bad because you will always
get the default value of the field.  So on the
ActionForm level it is good to preserve the user's
input so if it fails validation you can return the
value the user entered so it can be corrected.  So an
ActionForm normally uses Strings except for
checkboxes, radio buttons, and select boxes where you
know the user can't enter anything bad.  Then you can
have a bean with all the correct types (int, Date,
etc.), and convert the ActionForm's values to the
other bean.  There are a couple of transformation
packages posted to help with doing this type of
conversion between objects.  Here is the link.

http://www.husted.com/about/struts/resources.htm

David

--- Ho Soo Aun [EMAIL PROTECTED] wrote:
 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-namevalidator/servlet-name
  
  
 

servlet-classcom.wintecinc.struts.action.ValidatorServlet/servlet-class
  
   init-param
 param-nameconfig/param-name
  
  
 param-value/WEB-INF/validation.xml/param-value
   /init-param
   init-param
 param-namedebug/param-name
 param-value2/param-value
   /init-param
   load-on-startup2/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 nowrapbean:message
   key=meter.label.meter1/:/td
   td align=leftnbsp;html:text
 name=meterForm
   property=meter.meter1 size=7
   maxlength=7//td
   tdnbsp;/td
   /tr
   ...
   td align=right colspan=2nbsp;html:submit
   property=action
   value=Update
  
 

onclick=bCancel=false;ENTER/html:submitnbsp;html:cancel
   onclick=bCancel=true;javascript:window.close()
   value=CancelCANCEL/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/
 


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



Re: Validator::validate() reflection - null

2001-08-19 Thread Ho Soo Aun

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-namevalidator/servlet-name
 
 
 servlet-classcom.wintecinc.struts.action.ValidatorServlet/servlet-class
 
  init-param
param-nameconfig/param-name
 
  param-value/WEB-INF/validation.xml/param-value
  /init-param
  init-param
param-namedebug/param-name
param-value2/param-value
  /init-param
  load-on-startup2/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 nowrapbean:message
  key=meter.label.meter1/:/td
  td align=leftnbsp;html:text name=meterForm
  property=meter.meter1 size=7
  maxlength=7//td
  tdnbsp;/td
  /tr
  ...
  td align=right colspan=2nbsp;html:submit
  property=action
  value=Update
 
 onclick=bCancel=false;ENTER/html:submitnbsp;html:cancel
  onclick=bCancel=true;javascript:window.close()
  value=CancelCANCEL/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/




Re: Validator::validate() reflection - null

2001-08-17 Thread David Winterfeldt

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-namevalidator/servlet-name
 

servlet-classcom.wintecinc.struts.action.ValidatorServlet/servlet-class
 
 init-param
   param-nameconfig/param-name
  
 param-value/WEB-INF/validation.xml/param-value
 /init-param
 init-param
   param-namedebug/param-name
   param-value2/param-value
 /init-param
 load-on-startup2/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 nowrapbean:message
 key=meter.label.meter1/:/td
 td align=leftnbsp;html:text name=meterForm
 property=meter.meter1 size=7
 maxlength=7//td
 tdnbsp;/td
 /tr
 ...
 td align=right colspan=2nbsp;html:submit
 property=action
 value=Update

onclick=bCancel=false;ENTER/html:submitnbsp;html:cancel
 onclick=bCancel=true;javascript:window.close()
 value=CancelCANCEL/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/



Re: Validator::validate() reflection - null

2001-08-17 Thread Sanjay Choudhary

david,

Struts 1.0.
jakarta-tomcat-3.2.3

-Sanjay



Original Message Follows
From: David Winterfeldt [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: Validator::validate() reflection - null
Date: Fri, 17 Aug 2001 08:16:19 -0700 (PDT)

What version of struts are you using?  Struts 1.0?
Also what servlet container and version are you using?

David



_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp