-
dynamic drop down with Struts (3 messages)
- Posted by: Thomas Olsen
- Posted on: March 22 2007 18:28 EDT
Hi, I'm having a problem with some basic struts. I'm trying populate a html drop down menu with where the collection, types, is added to the request object via an Action, which then forwards onto the jsp including the above tags. The collection is generated from a method in a model, which requires a parameter held in the session variable. My problem is that I can't figure out how to populate the drop down, such that when the form is submitted and an error is return from the ActionFrom validate method, the form in the jsp keeps it values and the selection from the drop down is kept. I have tried a couple of things. 1. to use an action that populates the request object with the collection, but when the form is submitted and an error is return the collection no longer exist in the request. 2. to add a method to my ActionForm such that it returns the collection, however, I rely on a session veriable to create collection, I can't seem to get at the from a method within the ActionForm object. Is there an easy solution that I'm complety overlooking? Thanks Thomas O.Threaded Messages (3)
- Re: dynamic drop down with Struts by Mike Spiridonov on March 22 2007 22:43 EDT
- Re: dynamic drop down with Struts by Jeryl Cook on March 26 2007 13:21 EDT
- Re: dynamic drop down with Struts by Mike Spiridonov on March 29 2007 11:38 EDT
- Re: dynamic drop down with Struts by Jeryl Cook on March 26 2007 13:21 EDT
-
Re: dynamic drop down with Struts[ Go to top ]
- Posted by: Mike Spiridonov
- Posted on: March 22 2007 22:43 EDT
- in response to Thomas Olsen
I think you would better keep your types collection in your ActionForm and use instead of . In Action's execute method (or whatever name is used for the method which renders the page) just populate your ActionForm's types field with proper collection. -
Re: dynamic drop down with Struts[ Go to top ]
- Posted by: Jeryl Cook
- Posted on: March 26 2007 13:21 EDT
- in response to Mike Spiridonov
i disagree with adding the collection to the Form, which is suppose to be the "Model" with only setters/getters and a validate method, that validates syntax only! -
Re: dynamic drop down with Struts[ Go to top ]
- Posted by: Mike Spiridonov
- Posted on: March 29 2007 11:38 EDT
- in response to Jeryl Cook
I am under impression that forms are claimed to perform a function of transfer objects between model and view as well. let me check some struts docs...Note: While ActionForm beans often have properties that correspond to properties in your Model beans, the form beans themselves should be considered a Controller component. As such, they are able to transfer data between the Model and View layers.