BeanUtils.copyProperties(formBean, javaBean) not converting String dates to java.util.Date dates

2002-10-18 Thread Clayson, Jim
Hi,

Struts1.1b2: BeanUtils.copyProperties(formBean, javaBean) not converting
String properties into Dates:

I am trying to figure out what is wrong with what I am doing. I have a form
bean with date string properties (from and to) which I would like to copy
into a javabean class. When I print out some debug statements, I can see the
string values i.e. 04/09/2002 and 19/09/2002, but the same properties (which
are named the same and have identicale getters and setters) in the javaBean
class show null after I do:

BeanUtils.copyProperties(formBean, javaBean);


Can anyone help me out?

Jim



The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).

The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




help please: Validator basic use

2002-10-18 Thread Clayson, Jim
Hi I am attempting to use the date validation provided by the framework - I
am using struts1.1b2.

I think I must be missing something fairly fundamental but maybe someone
will be able to confirm what that is. The problem is when I enter garbage
into the form's date fields and submit them, I get no errors. How does one
usually display the errors when using the validator framework.

I have my validator-rules.xml and validation.xml config files in my
application's web-inf dir.

Their relevent contents are as follows:

validator-rules.xml

  

 
 

  

 and validation.xml:

   
  
 
 
 
 
 
 
  
  

I have my action's validate attribute set to "true".

Are the above setup correctly?

Thanks
Jim




The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).

The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: help please: Validator basic use

2002-10-18 Thread Clayson, Jim
Hi,

I eventually got it to work. I had not seen the example struts-validator.war
and when I did some comparisons, I found that I was misinterpreting the way
in which the form validation was defined in validation.xml.

Its working now - thanks for the input!

Jim

-Original Message-
From: Padma Ginnaram [mailto:padma.ginnaram@;s1.com]
Sent: 17 October 2002 22:43
To: 'Struts Users Mailing List'
Subject: RE: help please: Validator basic use


Try applying a simple validator like required to one of your form fields, if
it does not work verify the following.

1. name used in the validation resource file matches the name in your action
mapping
2. validate set to true in your action mapping
3. your form extends ValidatorActionForm, and if you have any custom
validation in your form, you  don't ignore the errors returned by
super.validate.

If the problem is only with date validator, are you entering this garbage
after you enter a valid date?

The date validator that comes with struts1.1 uses a short pattern (M/d/YY
for en_US) if you do not explicitly pass a valid date. It does not do strict
parsing by default unless you specify pattern using the variable
datePatternStrict.

If you want to implement strict date parsing with out having to specify this
pattern, write your own pluggable validator and check for the parse position

DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);   
df.setLenient(false);  
  
ParsePosition pos = new ParsePosition(0);
Object obj = df.parseObject(value, pos);
if (pos.getIndex() == 0)
  throw new ParseException("Unparseable value: \"" + value + "\"" ,
pos.getErrorIndex());
if (pos.getIndex() < value.length())
  throw new ParseException("Unparseable value: \"" + value + "\"" ,
              pos.getIndex());

-Original Message-
From: Clayson, Jim [mailto:Jim.Clayson@;centrica.co.uk]
Sent: Thursday, October 17, 2002 9:05 AM
To: '[EMAIL PROTECTED]'
Subject: help please: Validator basic use


Hi I am attempting to use the date validation provided by the framework - I
am using struts1.1b2.

I think I must be missing something fairly fundamental but maybe someone
will be able to confirm what that is. The problem is when I enter garbage
into the form's date fields and submit them, I get no errors. How does one
usually display the errors when using the validator framework.

I have my validator-rules.xml and validation.xml config files in my
application's web-inf dir.

Their relevent contents are as follows:

validator-rules.xml

  

 
 

  

 and validation.xml:

   
  
 
 
 
 
 
 
  
  

I have my action's validate attribute set to "true".

Are the above setup correctly?

Thanks
Jim




The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).

The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>