Its very recently that I have begun playing around with
struts and I have been trying to get my head around this for sometime now and I am almost begining to think that its not possible.
What I want to do is pre-populate a Struts form and then call a
jsp which uses the struts-el tags to display the form.
I have a form with 2 fields - a select field and a radio button field. The select field has a list of 'network' options the user can select from and the radio button field has 2 views that the user can again choose from.
I have 2 urls (/selectNetwork and /submitNetwork) - one which displays the form and the other which the form is submitted to. This is what I have come up with.
Struts-config.xml
-----------------
In the form view url's (/networkSelect) Action class, I manually create a NetworkForm object, populate the attributes and set it in request scope with the same name (networkForm) as defined in the form bean definitions in the xml above. The jsp picks up the form and displays the values correctly.
However in the submit url (/submitNetwork) Action class, the ActionForm passed into the execute method is null. I would expect that the framework would reuse the NetworkForm object (or create a new one) and populate the fields from the request. Is this because I manually created the form object in the previous request and botched up the framework processing (though I cant fugure out why it should be so)?
Alternatively could I have included the form in the 'view' url too and set the scope to session? I dislike having to do so since this really is not a session object and is necessary only for 2 requests. Also if I do that, I am at a loss how to include validation in here. The problem is I dont want the validate method to kick in for the view (which is another reason why I dint map the form object to the view url).
I appreciate your patience in reading this post and would be grateful for any suggestions/comments.
Thanks,
Ram.