Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
john lazeraski
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean pre population? Are you doing this in struts 2 ?
 
john lazeraski
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic