File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes drop down box keeps going back to the first item Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "drop down box keeps going back to the first item" Watch "drop down box keeps going back to the first item" New topic
Author

drop down box keeps going back to the first item

Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Hi,

First off, this is my first post, so hi!
Secondly, if I am posting this in the wrong section, I'm sorry.


Here's my problem. I'm working with a netbeans 5.5.1, jdk 1.5, tomcat 5.5.1.7. I'm not a fan of netbeans so far, but i'm working with a Visual Toolkit.

I have a dropdownlist. The dropdown list is bound to a collectionModel. When the user selects a value from the dropdown list, a table is populated from a differnt collection model. Now, I'm getting the table to change properly without a problem (except on load, but i can fix that). My problem is that the combo box always reverts back to the first item. If i select the third item in the box, I want that item to remain in the box and have the table change.

I've right clicked on the box and selected Auto-Submit on change, which is what i want.

My confusion, is the code here is similar to another page where I do a very similar thing, and that works fine.

Any help would be appricated. I'm sort of flying blind with this JSF/JSP stuff a.t.m.

I've only modified two methods. I populate the Collection Model that the drop down box gets it's data from on my previous page (and it lives in the sessionBean)

public void prerender() {
try {
getSessionBean1().getShelfCollectionModel1().clear();

ItemModel cm = new ItemModel();
cm.setParentItemInstId(Long.parseLong(dropDown1.getValue().toString()));

QueryModel qm = new QueryModel();
qm.addQueryEntry(cm);

getSessionBean1().getItemCollectionModel1().query(qm);


}
catch (Exception e){}

}

public void dropDown1_processValueChange(ValueChangeEvent event)
{
// TODO: Replace with your code
try {
getSessionBean1().getItemCollectionModel1().clear();

ItemModel cm = new ItemModel();
cm.setParentItemInstId(Long.parseLong(dropDown1.getValue().toString()));

QueryModel qm = new QueryModel();
qm.addQueryEntry(cm);

getSessionBean1().getItemCollectionModel1().query(qm);


}
catch (Exception e){}

}
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Hmm.. quiet. IS there more information I should be providing?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: drop down box keeps going back to the first item
 
Similar Threads
Help With HQL Query
Sun Java Studio Creator : dropdown value ..
JSF Newbie: sending params to data provider from text field
How to retain selected content after post on same page
dynamic dropdown