This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

html:option tag and default value

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow ! That worked. Thank you so much, Merrill!!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gran,

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.
 
Gran Roguismo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic