New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectCheckboxMenu: Order of selected items not kept #8119
Comments
Please provide an executable example using the PrimeFaces Test project. It will help me debug the issue |
Reproducer: The values are just submitted in the form in the order they are in the DOM currently. |
cc @ltlBeBoy not sure if you want to look at this one too. |
@melloware Yes, I will take a look at. |
Maybe a hidden input with the selection order would do the job. |
Yep we need some sort of JS |
OK changing the core component was too much of a nightmare and not worth it. So I added <p:ajax event="itemSelect" listener="#{checkboxView.onItemSelect}"/>
<p:ajax event="itemUnselect" listener="#{checkboxView.onItemUnselect}"/> So now that you have an itemSelect and unselect you can track the order the items were clicked using AJAX. public void onItemSelect(SelectEvent event) {
FacesMessage msg = new FacesMessage();
msg.setSummary("Item selected: " + event.getObject().toString());
msg.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void onItemUnselect(UnselectEvent event) {
FacesMessage msg = new FacesMessage();
msg.setSummary("Item unselected: " + event.getObject().toString());
msg.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext.getCurrentInstance().addMessage(null, msg);
} |
Greetings,
When using selectCheckboxMenu component (with attribute multiple="true"), after each item selection, the order of selected items in Collection resets exactly to order of the items in collection, thats used as available items to choose (in this case f:selectItems component)
E.g. use collection List 1,2,3,4, users chooses items in this order 4,3,2, but the result is stored as 2,3,4. I am situation, where I need exactly the order of items that was chosen by the user. Now I need to use workaround with ajax request event="change" and manually sort those elements in viewBean.
Could this be a new feature (new attribute keepOrder or something? Or is it a bug?
Thanks!
Environment
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Sequence of the elements user choose should be stored in order, thats displayed on screen.
The text was updated successfully, but these errors were encountered: