Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection-backed radio button in Struts 2

 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is it that when a form with a collection-backed radio button gets submitted that Struts 2 calls the getter for the list?

For instance:


The code above calls "getPriorityList()" when I submit the form. I really only need the getter called when the form is being built.


I'm using Struts 2, version 2.2.1.1 and my action is both ModelDriven and Preparable.


Thanks in advance.
 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just checking in. Does anyone know the answer to this?
 
Manuel Schenkhuizen
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
being built? AJAX?
 
Rupesh Mhatre
Ranch Hand
Posts: 35
Eclipse IDE Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to ParameterInterceptor in struts 2 which puts the request parameters on ValueStack so that OGNL can pull data.
 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manuel Schenkhuizen wrote:being built? AJAX?


Not with AJAX. Because I am using a collection-backed radio button, the Collection which backs it is provides the data. So, the form is being "built" before it is displayed.

Rupesh Mhatre wrote:Thanks to ParameterInterceptor in struts 2 which puts the request parameters on ValueStack so that OGNL can pull data.


Yes, but the point of the original question is... Why does it NEED to call the getter method when you SUBMIT the form? It just needs to call the setter method (in my example, "setPriority").
 
Rupesh Mhatre
Ranch Hand
Posts: 35
Eclipse IDE Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes in case of model driven only getModel method gets exposed. In this case we do create object of our domain model and struts2 interceptors only need to get the data from ValueStack. Hope this will resolve this query.
 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rupesh Mhatre wrote:Yes in case of model driven only getModel method gets exposed.


I mentioned in the original message that I was using ModelDriven. I'm not having a problem with that aspect of it.

Is there anyone else who understands what I'm asking? If not, I can try to explain it a different way.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic