This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Collection-backed radio button in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Collection-backed radio button in Struts 2" Watch "Collection-backed radio button in Struts 2" New topic
Author

Collection-backed radio button in Struts 2

Kev Adams
Greenhorn

Joined: Oct 27, 2009
Posts: 23
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

Joined: Oct 27, 2009
Posts: 23
Just checking in. Does anyone know the answer to this?
Manuel Schenkhuizen
Greenhorn

Joined: Apr 20, 2011
Posts: 14
being built? AJAX?
Rupesh Mhatre
Ranch Hand

Joined: Apr 29, 2011
Posts: 35

Thanks to ParameterInterceptor in struts 2 which puts the request parameters on ValueStack so that OGNL can pull data.
Kev Adams
Greenhorn

Joined: Oct 27, 2009
Posts: 23
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

Joined: Apr 29, 2011
Posts: 35

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

Joined: Oct 27, 2009
Posts: 23
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collection-backed radio button in Struts 2
 
Similar Threads
UnChecking a single radio button
struts2 list of radio buttons
Grid using Struts
Getting Data from Struts ActionForm to a JSP
Iterator and multibox