I am trying to figure out to set a default value using html ptions.
Here is my struts-config.xml
So, from displayTable.jsp , I am forwarding my request to display1.jsp where I need to default select a code. I have forms and actions associated with both jsp's. So, in the action associated with displayTable.jsp, I set the status cd for the next form(which I need to set the default) but since I do, mapping.findForward, it doesn't seem to be making much sense doing it. The actual form associated with the display1.jsp, where I need the default, seems to be too late to do anything. Would Request dispacther be a better idea ? I hope somebody can make some sense out of what I am saying. I appreciate anybody's help. Thanks.
One possible solution might be to set the default in the form bean's reset() method, or possibly in the bean's constructor. That way, no matter which action precedes it, the default will always be set. Since reset() get's called before struts populates the properties of the form bean, it will be overriden by whatever the user enters. [ March 23, 2005: Message edited by: Merrill Higginson ]
I think I am looking to do the same thing, not sure. I have one action that is looking to pass values to a second action where the dropdowns will default to values from the formbean.
here is the tag that I am using:
how can I tell it to look at the reportForm bean and if the value dialdCntryCode matches the option this should be the one that is selected?
Joined: Sep 08, 2004
Wow ! That worked. Thank you so much, Merrill!!
Joined: Feb 15, 2005
Either in the action that forwards to the jsp, or in the reset() method of the form, simply call reportForm.setDialdCntryCode(). When the JSP is displayed, struts will automatcially make the comparison, and put "selected" in the appropriate option.
Joined: Mar 10, 2005
thanks Merril, you were correct, and I found that my problem was actually do to another error dealing with the fact that one getter method was actually returning the string in upper case. When it found that these did not match it set it to it's default and I had my problem. You did give me a better idea of how this pulls together though, and I'm sure that will come in handy in the future.