On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Where do I register such a convertor?  Simply add this code to my Action or do 
I have to add this somewhere else?

I've figured out what my problem was, but now sth else pops up.  I have a field 
with type java.util.ArrayList.  When I enter the form, the precedent Action 
fills the form.  On screen, the ArrayList is correctly processed.  Now, when I 
submit the form, all those values are gone.

I added <html:hidden property="txtFieldForArrayList" /> to my JSP, but it turns 
out that was the problem for the previous error.  When I remove that field from my JSP, 
everything works correctly for the first time, but the second time I enter the page, this 
ArrayList is gone.

What am I doing wrong here?

Is the ArrayList gone or empty? Presumably just empty - since
DynaActionForm's should re-create the list even in request scope. You
could change the form to be session scope - or you need to add some
"lazy list" type behaviour

 http://wiki.apache.org/struts/StrutsCatalogLazyList
 http://wiki.apache.org/struts/LazyList

If you use one of the "lazy" ActionForm flavours it does this for you:

 
http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes

Niall

-----Original Message-----
From: Niall Pemberton [mailto:[EMAIL PROTECTED]
Sent: maandag 12 maart 2007 14:49
To: Struts Users Mailing List
Subject: Re: DynaValidatorForm with java.util.Date

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Why does sql.Date work?

Because BeanUtils (at the moment) comes with a registered converter
for jav.sql.Date - but not for java.util.Date. If you want it to
handle String-->java.util.Date you need to register a Converter for
it:

  Converter dateConverter = new MyDateConverter();
  ConvertUtils.register(dateConverter, java.util.Date.class);

Your date converter will need to implement the following interface:

  http://tinyurl.com/2h459j

The section 4.3.1 you refer to below tells you which types are
supported "out of the box".

Niall

> And the apache-site states that it's actually possible to use for instance 
java.util.ArrayList.  How do you do that? 
http://struts.apache.org/1.3.5/userGuide/building_controller.html, see section 
4.3.1.

> -----Original Message-----
> From: Hubert Rabago [mailto:[EMAIL PROTECTED]
> Sent: maandag 12 maart 2007 14:06
> To: Struts Users Mailing List
> Subject: Re: DynaValidatorForm with java.util.Date
>
> The fields of action forms, including DynaValidatorForms are populated
> from request parameters, and these values are all in String variables.
>  I suggest using a String variable for the dyna validator form field
> as well, and just parsing it to get the java.util.Date equivalent when
> you use it in your Action classes.
>
> Hubert
>
> On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > And the 3rd mail.  Is it possible to use an object that's different from 
java.lang.* as type for the dynavalidatorform?  I think that's what causing the issue 
here.  If it's not possible, then I'm in deep .... :)
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: maandag 12 maart 2007 10:26
> > To: user@struts.apache.org
> > Subject: RE: DynaValidatorForm with java.util.Date
> >
> > Ok, I did some tests and debugging and this is the result:
> >
> > The errormsg is "Cannot assign value of type 'java.lang.String' to property 
'txtFieldName' of type 'java.util.Date'".
> >
> > I fill that field with following code: modifyForm.set("txtFieldName",new 
Date());
> >
> > So the object I'm assigning to that field is a Date-object, but for some 
reason it is converted to a String.
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: maandag 12 maart 2007 9:40
> > To: user@struts.apache.org
> > Subject: DynaValidatorForm with java.util.Date
> >
> > Hi
> >
> > I have a form in which a Date is displayed, using fmt.  It's static text, 
so no user input is required.  The problem is the following.  When the validation of 
that form fails, you return to that form.  Actually, it should return to that form, 
but you're redirected to the error page.
> >
> > This is the error:
> > 2448020 12 03 09:29 [http-8080-Processor24] ERROR 
org.apache.struts.util.RequestUtils  - javax.servlet.ServletException: 
BeanUtils.populate
> >
> > javax.servlet.ServletException: BeanUtils.populate
> >
> > The form bean exists of a field, which is hidden, of the type 
java.util.Date.  This is filled by the action, with the correct date.  When I look at 
the source of the page, the date is actually filled in, so that's not the problem.
> >
> > I assume there's a problem with assigning the java.util.Date-type to a 
field in a DynaValidatorForm, but I'm not sure that's what causing the problem.  
There's also no validation on that field.
> >
> > Struts-config:
> > <form-bean name="ModifyUserForm" 
type="org.apache.struts.validator.DynaValidatorForm">
> >     <form-property name="txtTokenStatus" type="java.util.Date" />
> > </form-bean>
> >
> > Does anybody know how to have a Date-field in your form, in a way you can 
assign it to a textfield and make sure you can also pass it to fmt:formatDate.
> >
> > Tia
> >
> > Grtz
> >
> > Bjorn
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information.  If you have received it in error, 
please notify the sender immediately and delete the original.  Any other use of 
the email by you is prohibited.
>
> ---------------------------------------------------------------------
> 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]



This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information.  If you have received it in 
error, please notify the sender immediately and delete the original.  Any other 
use of the email by you is prohibited.

---------------------------------------------------------------------
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]

Reply via email to