Skip to content

Mis en ligne par admin - 23 janvier 2014 - Web Applications

Primefaces: an OrderList including inputs

There is no way of putting inputs inside a PrimeFaces (orderList is not a UIData component). Therefore, the solution to do it is through… dataTable !

Here is a meaningful example:

<h:panelGroup id="panelGroup">
<p:dataTable styleClass="ui-datatable-sortable" value="#{myBean.values}" var="layer" converter="#{myBean.converter}" id="myTable">
      <p:selectBooleanCheckbox id="checkBox" value="#{layer.shown}" >
              <p:ajax update="checkBox"/>
 <p:remoteCommand name="reorderTable" action="#{myBean.reorderTable}" update="panelGroup"/>
                  <script type="text/javascript">
                  $(".ui-datatable-sortable tbody").sortable(
                             update: function(event, ui) {
                                var x = ui["item"].parent().children().map(
                                   function() {
                                      return $(this).attr("data-ri");
                                reorderTable([{name: 'newOrder', value: x}]);

And in the Managed Bean (where XXX is the Array Object class):

public void reorderTable() {
       String newOrder = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("newOrder");
       String[] noArr = newOrder.split(",");

       List<XXX> n = new ArrayList<XXX>();
       for ( String s : noArr ) {
          n.add( this.getValues().get( Integer.parseInt(s)) );

Articles similaires

Les articles suivants abordent des thèmes communs.


Partagez vos remarques.

Il n'y a pas de commentaires pour cet article.

Add a Comment

Fill in the form and submit.