This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Combobox question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Combobox question." Watch "Combobox question." New topic
Author

Combobox question.

Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
Hi!
I was wondering if it's possible to make a combobox where you write your own text in the dropdown list.

Ex. The code below creates a textfield aswell as a dropdown list,
I want to be able to write my option in the dropdown lists textfield instead of the one which is generated above the dropdown list.



This is what the <s:combobox/> will look like:


This is how I want it to look:



Is it possible?
If so, how?

Thanks in advance,
Alia
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The autocompleter Dojo tag does this.
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
Right thank you!
I can't get it to work properly though.
I've tried the following code snippets. (Along with several others that didn't turn into anything)


This code turns into a regular textfield, I've tried it without the %{} , same thing, just a textfield.


This code turns into a regular <s:select/> with the values from the ArrayList in it.

The list I'm trying to populate the autocompleter with, is an ArrayList<String>.

Appreciate the help
Alia
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you include the <sx:head> tag in your pages <head> element?
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
Yes I did.

Here's the complete .jsp


I tried both <sx:head/> and the one I use above.
Thanks
Alia
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Any JavaScript errors on the page or in Firebug? Have you tried it with the "debug" attribute in <sx:head>? Have you confirmed that the network traffic meets with your expectations from the tag usage?
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
No there are no java script errors, I just tried with the debug attribute and it shows the following message: "FATAL exception raised: Could not load 'dojo.debug'; last tried '__package__.js'
DEBUG: DEPRECATED: dojo.io replaced by dojo.io.* -- will be removed in version: 0.5"

What do you mean by:
Have you confirmed that the network traffic meets with your expectations from the tag usage?


I've tried the autocompleter out by writing something in the box then pressing save, and the value gets inserted into the database, just as I've expected. And I'm sure it recieves the list since it shows the list as a select if I use the following code:



/Alia
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Wait, you're trying to use an autocompleter as a non-Ajax component? I don't know if you can do that.
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
Well not intentionally. What is it I've forgotten to write in the jsp code that makes it into a non-ajax try?
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
I managed to fix it, apparently I had to change

to


Thanks for your help!
Regards
Alia
 
jQuery in Action, 2nd edition
 
subject: Combobox question.