-
1. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 18, 2012 9:30 AM (in response to giuliano.rap)Sorry by the highlights.
-
2. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
sivaprasad9394 Jun 18, 2012 9:37 AM (in response to giuliano.rap)Please check with Jquey to implement this concept in richfaces.
Check this link for your reference.
Jquery picklist plugin
-
3. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 18, 2012 9:42 AM (in response to sivaprasad9394)Wich link? :]
Thanks! -
5. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 18, 2012 9:51 AM (in response to sivaprasad9394)Thank you very much, I will take a look on it and come back here.
-
6. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
mcmurdosound Jun 18, 2012 3:12 PM (in response to giuliano.rap)Which Version of Richfaces are you using?
You could send the event data to the backing bean. For example with an a4j:support and / or a4j:jsFunction. By submitting the keycode, you could change the selecting of the listShuttle accordingly.
- You'll need to get the listShuttle UIComponent from the FacesContext.
- The get the current Selection (if such a thing exists and works)
- move the selection to the item matching the keycode / char.
- reRender the Listshuttle
- reset focus to the listShuttle to be able to press the next key again
Just some ideas.
-
7. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
mcmurdosound Jun 19, 2012 4:51 AM (in response to mcmurdosound)1 of 1 people found this helpfulThis one seems to work:
@RequestParameter // org.jboss.seam.annotations.web
private String eventKeycode;
public void demoListener(javax.faces.event.ActionEvent event) {
log.debug("----- event #0", event);
log.debug("---- keycode ---- #0", eventKeycode);
FacesContext ctx = FacesContext.getCurrentInstance();
UIComponent component =
ctx.getViewRoot().findComponent("idForm:idListShuttle"); // find the listshuttle
log.debug("---- component ---- #0", component);
if (component instanceof HtmlListShuttle) {
HtmlListShuttle ls = (HtmlListShuttle) component;
Set sourceSelection = ls.getSourceSelection();
Object sourceValue = ls.getSourceValue();
sourceSelection.clear();
sourceSelection.add(((List) sourceValue).get(0)); // just set to the first elem in list
log.debug("sourceselection #0", sourceSelection);
log.debug("sourceValue #0", sourceValue);
AjaxContext ajax = AjaxContext.getCurrentInstance();
ajax.addComponentToAjaxRender(ls); // rerender Listshuttle
}
}
<rich:listShuttle id="idListShuttle" sourceValue="#{myItems}"
...
<a4j:support event="onkeypress" onsubmit="listShuttleKeypressed(event.which);" oncomplete="console.log(event.which);"/>
</rich:listShuttle>
<a4j:jsFunction name="listShuttleKeypressed" actionListener="#{myManager.demoListener}">
<a4j:actionparam name="eventKeycode"/>
</a4j:jsFunction>
I'm not sure how this would work without jboss seam and / or with richfaces 4.x
-
8. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 19, 2012 6:15 AM (in response to mcmurdosound)Thanks Christian, it was really helpful!
I just changed a thing: I am using the method setSourceSelection from HtmlListShuttle instead of getSourceSelection.
The only thing now is to set the focus on the select item, so the user can press another key and change the selection again. Any idea?
Thank you guys!
-
9. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 19, 2012 8:28 AM (in response to giuliano.rap)I found a way to set the focus on the selected item (maybe it's not so good programming): with the attribute data from a4j:jsFunction I get the number of the selected item and then I get the element by id and call the click method. Like this:
<a:jsFunction name="keyHandlerJS"
action="#{userdefWizard.testHandler()}" data="#{userdefWizard.elementCounter}"
oncomplete="var id = 'wizardGenericForm:includedStepContent:ls_concernList:'.concat(data);
document.getElementById(id).click();"
eventsQueue="foo"
ignoreDupResponses="true" />
What do you think guys?
It's the only way I found...Besides that, I need to know if the user is selecting from the source or the target. Any ideas?
Thanks!!
-
10. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 20, 2012 2:49 AM (in response to giuliano.rap)I need to think in something else because it doesn't work well. When we move the item from/to source and target, the item carries its id.
-
11. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 20, 2012 3:13 AM (in response to giuliano.rap)I found a solution to re-update the rowIndex at https://community.jboss.org/message/597767
So now I just need to know if the user is selecting from the source or the target. Any idea?Thanks!
-
12. Re: ListShuttle - "jump" to an entry with the first letter matching with the key pressed
giuliano.rap Jun 25, 2012 5:21 AM (in response to giuliano.rap)Does anyone know how the activeItem works?
Apparently, it stores the item "clicked" by the user, but the item from the target list has more priority than the source list. For example, once the user clicked on some item from target list, the activeItem stores always this value, doesn't matter if the user clicks on the source list later. Am I right?
I don't know if I understood right.Thanks