wood burning stoves*
The moose likes Struts and the fly likes Combo box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Combo box" Watch "Combo box" New topic
Author

Combo box

Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Hi All,


I have one JSP page in which I have one combo box containing search criteria and one text box containing the search value.
When search is performed by clicking some button , the control passes to action which again comes back to the same JSP page.
I want the search criteria that I had chosen to be shown as the first one in the combo, but it shows diff one.
Within action i have tried to set the value on the form
such that
form.setXXXXX(search criteria )
but it does not seem to work.

Any help would be appreciated.

Thanks
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Make sure your jsp's select tags are the struts version.

What you described should work. Post some code if you're still having probs.

In fact, you should not even need to do setXXX from the Action because struts will reuse the same ActionForm; this is true even if ActionForm is in request scope because your submission/redisplay occurs in a single request.


A good workman is known by his tools.
Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Hi,
Thanks for reply.
Below is the code snippet.
html:select property="selectedValue" value="Select to search" name="getAllInstancesForm"
html ption value="Installation Key"
html ption value="Instance Key"
html ption value="Host Name"
html ption value="Service Name"
html ption value="Version"
html ption value="Status"
html:select



html:text property="searchValue" size="40" name=getAllInstancesForm
html:button property="button" value="Search" onblick=searchInstanceFunction()


The problem is I select the option as status or anything else,then when
I come back I always get Installation Key.

Thanks... .
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Buggi Sandhu:
The problem is I select the option as status or anything else,then when I come back I always get Installation Key.

What is the scope of the action? If it's request, it may not find the updated formbean. Please test the code by putting the scope to be session, so as to retain the formbean and let us know.

Another approach could be to persist the data and retrive again.

Thanks and Regards,
Kinjal Sonpal
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Actually I think the problem is the value attribute of the select element.

Create an html ption with value="Select to search" and you'll see what I mean.

To correct the problem, remove the value attribute from the select element.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Combo box
 
Similar Threads
Struts combo box
Unable to fetch values
I passed SCJD :)
skip value in logic: iterate
how to retrive a value from a check box on one page to another page containing a com