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 Question listshuttle + suggestionBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Question listshuttle + suggestionBox" Watch "Question listshuttle + suggestionBox" New topic
Author

Question listshuttle + suggestionBox

jules poit
Greenhorn

Joined: Oct 06, 2009
Posts: 9
Hi everyone

I have a question
I am using Richfaces the suggestionbox with a listShuttle. Basically what I want to do is when a user selects/clicks on an item in the suggestionBox that this item is selected in my listShuttle (in the sourceValue list). (Let say I have 1000 values -String - in my listShuttle, then the suggestionBox is used to find quickly an item and focus on it in the listShuttle, it is more convenient than using the scroller of the listShuttle ).

What I am doing right know, is using a javascript function on the onselect="selectItem();" event of the suggestionBox, so I have :



I retrieve the good value but I do not know how to "focus" on the element in my list ... I am pretty sure is it simple but I tried, t.select(), t.focus() ... but nothing is working :/

Thanks for your help
jules poit
Greenhorn

Joined: Oct 06, 2009
Posts: 9
Nobody ?
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Please post only on one forum on one site unless you don't receive a response for several days together.
Duplicate post : http://www.jboss.org/index.html?module=bb&op=viewtopic&t=162200

Also be patient while others get a chance to answer your question
jules poit
Greenhorn

Joined: Oct 06, 2009
Posts: 9
Ho, sorry about that,
I did not know both of these forums where related
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Both the forums are not related at all, it's just that some people might be contributing to both the forums
and it might be a waste of their time looking at the same question!
In response to your question , have you looked at the activeItem attribute of listShuttle?


jules poit
Greenhorn

Joined: Oct 06, 2009
Posts: 9
Hum, I can retrieve the active item in the shuttle list :
document.getElementById('chartSettingsForm:parametersListShuttle').component.sourceList.activeItem

So, I looked in the API, and there is a setActiveItem, but I cannot make it work :/
I tried document.getElementById('chartSettingsForm:parametersListShuttle').component.sourceList.setActiveItem('myStringInTheShuttleList'), or .setActiveItem('chartSettingsForm:parametersListShuttle:3') but doesn't seem to work

It seems to be easy :/ There is no example with the activeItem attribute of the shuttle list , and I do not now how to use it to set an active item.
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Ok I have a working example for your problem, list shuttle has a pretty nasty dom !
I have just changed the stylesheet class for the matched row using javscript.
Richfaces defines several style classes that you can use with a list shuttle component(class names can be found in the userguide).

index.jsp


javascript


I tried using the activeItem attribute by using a value expression and then using ajax to set the activeItem, but I was facing some issues.
But this should be a simple workaround.

jules poit
Greenhorn

Joined: Oct 06, 2009
Posts: 9
Thanks for the help

Two "issues" with your code,

The first one is by using the class to highlight the element found in the suggestion box , itdoes not scroll to the position of the element (I have more than 200 elements in my list), but when I scroll to my element, it is highlighted

The second issue is after the highlight of an element, if I select an other element, then the previous found element stays highlighted
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Jules,
I tried it now, and I found another issue different from your issues ! I did not try the scrolling so I can't test that.
However, it does clear the old highlighted element (else in the code takes care of that)
The problem that I found was , it only 'highlights' the element, it does not 'select' it, so the user still has to 'select' it.
I went through the source code for list-shuttle, but have not found time to try anything yet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question listshuttle + suggestionBox
 
Similar Threads
RichFaces - listShuttle
ListShuttle in JSF 2.0
How to pass a javascript variable on a jsp to a servlet
Richfaces listShuttle with TypeAhead?
listShuttle current selected item