DynamicBean can have it's properties typed:
Example:

DynamicBean db = DynamicBeanFactory.create();
db.setCalendar("date", Calendar.getInstance());
db.setLong("idXX", 123);
db.setString("prop", "Hello World");
db.setObject("objPropName", new Object());
db.add("collectionPropName", "Item1"); //this creates a collection.

When form gets populated, all properties are String, but conversions are
done when getting these values.

//populating posted values...
db.setObject("date", "5/2/2004");
db.setObject("idOperator", "19580001");

//getting it from Action
db.getCalendar("date"); //should return a calendar with that date.
db.getLong("idOperator"); //returns a long 19580001

Cheers.
Guillermo.


-----Original Message-----
From: Marco Mistroni [mailto:[EMAIL PROTECTED] 
Sent: Martes, 17 de Febrero de 2004 12:16 p.m.
To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
Subject: RE: Problem Dynamically creating form properties


Hi Guillermo,   
        I have one question: will 'your trick' work also if I have
properties of type, for example, Short, or Integer, or java.sql.Date?

Thanx and regards
        marco

-----Original Message-----
From: Guillermo Meyer [mailto:[EMAIL PROTECTED] 
Sent: 17 February 2004 12:43
To: 'Struts Users Mailing List'
Subject: RE: Problem Dynamically creating form properties

I previuosly posted a mail to this list asking why DynaForms are called
Dynamic if you have to declare them statically in Struts-Config. But
there was no answer :(

We created in our project a DynamicBean (previous DynaBean release and
when Struts 1.1 was no available) and extended ActionForm to be a holder
of DynamicBean (somethind like this: ((DynamicForm)form).getModel()
returns a DynamicBean with all properties.)

So, we add html:text fields to the JSP and these are populated to this
DynamicForm without the need of declaring this property anywhere. And we
have optionall Contract asserter to verify properties in a DynamicBean
when needed (usually when using DynamicBean as a DTO between Actions and
Business delegates)

Cheers.
Guillermo.


-----Original Message-----
From: Bernard Gaughran [mailto:[EMAIL PROTECTED] 
Sent: Martes, 17 de Febrero de 2004 07:11 a.m.
To: [EMAIL PROTECTED]
Subject: Problem Dynamically creating form properties


Can someone PLEASE help?

I need to create a User Interface (in JSP) which
presents the user with a number of input fields. The
number of input fields is not known until run-time
(based on user selections in a previous screens).

The 2 issues I see are:
1. generating the JSP dynamically with the correct
number of properties
2. accessing these form fields in the action class.

Normally, form property definitions need to be
defined at compile time (whether you use Action Forms
or DynaForms)

Ideally, I'd like to use the struts framework to avail
of Validator,etc,etc. Also, I would like to use Struts
Dyna Forms.

Can anyone advise a suitable approach & sample code?

Bernard Gaughran


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido
exclusivamente a las personas direccionadas en el mail y puede contener
informacion (i)de propiedad exclusiva de Interbanking S.A. o (ii)
amparada por el secreto profesional. Cualquier opinion en el contenido,
es exclusiva de su autor y no representa necesariamente la opinion de
Interbanking S.A. El acceso no autorizado, uso, reproduccion, o
divulgacion esta prohibido. Interbanking S.A no asumira responsabilidad
ni obligacion legal alguna por cualquier informacion incorrecta o
alterada contenida en este mensaje. Si usted ha recibido este mensaje
por error, le rogamos tenga la amabilidad de destruirlo inmediatamente
junto con todas las copias del mismo, notificando al remitente. No
debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni
ninguna de sus partes si usted no es el destinatario. Muchas gracias.



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

NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido exclusivamente a las 
personas direccionadas en el mail y puede contener informacion (i)de propiedad 
exclusiva de Interbanking S.A. o (ii) amparada por el secreto profesional. Cualquier 
opinion en el contenido, es exclusiva de su autor y no representa necesariamente la 
opinion de Interbanking S.A. El acceso no autorizado, uso, reproduccion, o divulgacion 
esta prohibido. Interbanking S.A no asumira responsabilidad ni obligacion legal alguna 
por cualquier informacion incorrecta o alterada contenida en este mensaje. Si usted ha 
recibido este mensaje por error, le rogamos tenga la amabilidad de destruirlo 
inmediatamente junto con todas las copias del mismo, notificando al remitente. No 
debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni ninguna de sus 
partes si usted no es el destinatario. Muchas gracias.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to