Re: Struts 2: map-backed bean

2008-03-05 Thread Laurie Harper

Yes, ParameterAware is the interface if you want HTTP request parameters.

L.

Cheng Wei Lee wrote:

Should I be implementing ParameterAware interface instead since the
RequestAware gives me attributes instead of parameters from the form?

On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:


If you implement the RequestAware interface, the map will contain all
the form values.

/Ian

--
Ian Roughley
From Down  Around, Inc.
Consulting * Agile Process * Open Source
Advanced Struts2 Workshop, April 28-30, Sunnyvale CA
web: http://www.fdar.com - email: [EMAIL PROTECTED]



Cheng Wei Lee wrote:

In Struts 1, we could use map-backed form beans to deal with dynamic

forms,

is there something equal in Struts 2?



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



Re: Struts 2: map-backed bean

2008-03-04 Thread Ian Roughley
If you implement the RequestAware interface, the map will contain all 
the form values.


/Ian

--
Ian Roughley

From Down  Around, Inc.

Consulting * Agile Process * Open Source
Advanced Struts2 Workshop, April 28-30, Sunnyvale CA
web: http://www.fdar.com - email: [EMAIL PROTECTED]



Cheng Wei Lee wrote:

In Struts 1, we could use map-backed form beans to deal with dynamic forms,
is there something equal in Struts 2?

  


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



Re: Struts 2: map-backed bean

2008-03-04 Thread Cheng Wei Lee
Suppose I use JavaScript to allow user to dynamically adds the number of
textboxes in the form, then submit. Would implementing RequestAware help? Do
I have to create the variables and getters/setters in advance at the action
class?

On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:

 If you implement the RequestAware interface, the map will contain all
 the form values.

 /Ian

 --
 Ian Roughley
 From Down  Around, Inc.
 Consulting * Agile Process * Open Source
 Advanced Struts2 Workshop, April 28-30, Sunnyvale CA
 web: http://www.fdar.com - email: [EMAIL PROTECTED]



 Cheng Wei Lee wrote:
  In Struts 1, we could use map-backed form beans to deal with dynamic
 forms,
  is there something equal in Struts 2?
 
 

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




Re: Struts 2: map-backed bean

2008-03-04 Thread Cheng Wei Lee
Ok, silly me, the setRequest method would set all request parameters into
the map, which I could then extract and use the values. Thanks for pointing
out this. Should have read the APIs more carefully.

On Wed, Mar 5, 2008 at 1:22 AM, Cheng Wei Lee [EMAIL PROTECTED] wrote:

 Suppose I use JavaScript to allow user to dynamically adds the number of
 textboxes in the form, then submit. Would implementing RequestAware help? Do
 I have to create the variables and getters/setters in advance at the action
 class?


 On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:

  If you implement the RequestAware interface, the map will contain all
  the form values.
 
  /Ian
 
  --
  Ian Roughley
  From Down  Around, Inc.
  Consulting * Agile Process * Open Source
  Advanced Struts2 Workshop, April 28-30, Sunnyvale CA
  web: http://www.fdar.com - email: [EMAIL PROTECTED]
 
 
 
  Cheng Wei Lee wrote:
   In Struts 1, we could use map-backed form beans to deal with dynamic
  forms,
   is there something equal in Struts 2?
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



Re: Struts 2: map-backed bean

2008-03-04 Thread Dave Newton
--- Cheng Wei Lee [EMAIL PROTECTED] wrote:
 Suppose I use JavaScript to allow user to dynamically adds the number of
 textboxes in the form, then submit. Would implementing RequestAware help?
 Do I have to create the variables and getters/setters in advance at the 
 action class?

You may also use array notation in situations like this, particularly when
it's a collection of identical types, like Strings, or a Person object,
etc. It can save a lot of boring code.

Dave

 On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:
  If you implement the RequestAware interface, the map will contain all
  the form values.
 
  Cheng Wei Lee wrote:
   In Struts 1, we could use map-backed form beans to deal with dynamic
  forms, is there something equal in Struts 2?


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



Re: Struts 2: map-backed bean

2008-03-04 Thread Cheng Wei Lee
What I was thinking of doing, is to prefix the components at the JSP such
that I can pick them up at action classes by iterating. Suppose I've 5
textfields that makes up a Person object, and the user dynamically adds 5
Persons at the JSP and submits, what I would do at my action class is to
loop through, and create a Person object through each set of 5 textfields.

What do you think of my approach? Or there's a better or more elegant way of
doing things?

Thanks!

On Wed, Mar 5, 2008 at 1:58 AM, Dave Newton [EMAIL PROTECTED] wrote:

 --- Cheng Wei Lee [EMAIL PROTECTED] wrote:
  Suppose I use JavaScript to allow user to dynamically adds the number of
  textboxes in the form, then submit. Would implementing RequestAware
 help?
  Do I have to create the variables and getters/setters in advance at the
  action class?

 You may also use array notation in situations like this, particularly when
 it's a collection of identical types, like Strings, or a Person object,
 etc. It can save a lot of boring code.

 Dave

  On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:
   If you implement the RequestAware interface, the map will contain all
   the form values.
  
   Cheng Wei Lee wrote:
In Struts 1, we could use map-backed form beans to deal with dynamic
   forms, is there something equal in Struts 2?


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




Re: Struts 2: map-backed bean

2008-03-04 Thread Dave Newton
--- Cheng Wei Lee [EMAIL PROTECTED] wrote:
 What I was thinking of doing, is to prefix the components at the JSP such
 that I can pick them up at action classes by iterating. Suppose I've 5
 textfields that makes up a Person object, and the user dynamically adds 5
 Persons at the JSP and submits, what I would do at my action class is to
 loop through, and create a Person object through each set of 5 textfields.
 
 What do you think of my approach? Or there's a better or more elegant way
 of doing things?

Type conversion [1].

Nutshell version--

Form:
people[0].name, people[0].email...
people[1].name, people[1].email...

Action:
ListPerson _people;

The framework does the conversion for you.

Dave

[1] http://struts.apache.org/2.x/docs/type-conversion.html


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



Re: Struts 2: map-backed bean

2008-03-04 Thread Cheng Wei Lee
Thanks!

On Wed, Mar 5, 2008 at 2:08 AM, Dave Newton [EMAIL PROTECTED] wrote:

 --- Cheng Wei Lee [EMAIL PROTECTED] wrote:
  What I was thinking of doing, is to prefix the components at the JSP
 such
  that I can pick them up at action classes by iterating. Suppose I've 5
  textfields that makes up a Person object, and the user dynamically adds
 5
  Persons at the JSP and submits, what I would do at my action class is to
  loop through, and create a Person object through each set of 5
 textfields.
 
  What do you think of my approach? Or there's a better or more elegant
 way
  of doing things?

 Type conversion [1].

 Nutshell version--

 Form:
 people[0].name, people[0].email...
 people[1].name, people[1].email...

 Action:
 ListPerson _people;

 The framework does the conversion for you.

 Dave

 [1] http://struts.apache.org/2.x/docs/type-conversion.html


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




Re: Struts 2: map-backed bean

2008-03-04 Thread Cheng Wei Lee
Should I be implementing ParameterAware interface instead since the
RequestAware gives me attributes instead of parameters from the form?

On Wed, Mar 5, 2008 at 1:15 AM, Ian Roughley [EMAIL PROTECTED] wrote:

 If you implement the RequestAware interface, the map will contain all
 the form values.

 /Ian

 --
 Ian Roughley
 From Down  Around, Inc.
 Consulting * Agile Process * Open Source
 Advanced Struts2 Workshop, April 28-30, Sunnyvale CA
 web: http://www.fdar.com - email: [EMAIL PROTECTED]



 Cheng Wei Lee wrote:
  In Struts 1, we could use map-backed form beans to deal with dynamic
 forms,
  is there something equal in Struts 2?
 
 

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