File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How do you handle the auto-population of collection of data from dynamic pages? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How do you handle the auto-population of collection of data from dynamic pages?" Watch "How do you handle the auto-population of collection of data from dynamic pages?" New topic
Author

How do you handle the auto-population of collection of data from dynamic pages?

john lazeraski
Ranch Hand

Joined: Nov 14, 2011
Posts: 76
Hi all,

I have a few pages where in my JSP pages I loop through a List<SomeType> and for each, I build up a set of <s:..> elements. Typically I do something like:

<s:select list="states" name="pageBean.stateSelections[<%= cntr %>].selectionId">....</s:select>.

I am wondering if this is the correct way to handle the form generation.. in my action class that the form submits to, I have a variable, PageBean, that has a property Collection<State> stateSelections. Each State object has a selectionId property in it. I am having some difficulties in getting this to work, so wanted to make sure this is the right way.

Thanks.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Do you mean pre population? Are you doing this in struts 2 ?

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
john lazeraski
Ranch Hand

Joined: Nov 14, 2011
Posts: 76
If pre population is when the form submits and struts figures out the nested objects within the action class using reflection to set the form fields onto objects, then yes. Yes, this is using Struts 2.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

If you want to populate some data before submitting your action you should use Preparable interceptor Which will take care populating the data.

Refer the following link http://struts.apache.org/2.0.14/docs/prepare-interceptor.html
john lazeraski
Ranch Hand

Joined: Nov 14, 2011
Posts: 76
You know, I am using annotations for all my actions and such.. and I can't seem to find a good reference or tutorial that shows how to mix and match the interceptor stack configuration with annotations. I never quite fully got the whole interceptor stack thing and how to make use of it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you handle the auto-population of collection of data from dynamic pages?