Board index JavaServer Faces General datatable selection

datatable selection

Components, Ajax Framework, Utilities and More.

Post 01 Jul 2010, 12:32

Posts: 2
hi dear primefaces users,
i want to use primefaces's datatable for my role's authoies. My update page is show role and its authories. All autroies is listed data table and my role's authoies must be selected. following codes do not work in my scope.

<p:dataTable id="authories" var="authory"  value="#{roleController.authories}"
               rows="10" paginator="true"
                selection="#{roleController.selectedAuthories}" selectionMode="multiple"
            <f:facet name="header">
               <h:outputText value="Authory Name" />
            <h:outputText value="#{}"></h:outputText>

Post 01 Jul 2010, 13:04

Posts: 85
Location: Tunisia
to get the multiple selection work, selectedAuthories must be an array :
Authories[] selectedAuthories;
Ben Khalifa Mouadh
engineering student at National School of Computer Sciences - Tunisia
JSF 2.0, GlassFish v3, PF 2.0.1,Majorra 2.0.2, netBeans 6.8

Post 08 Jul 2010, 22:00

Posts: 2
İ want to do this:
before my page is opened, my authories of role had been selected in roleManagement page. but it doesnt work so.

Post 09 Jul 2010, 09:14

Posts: 240
Location: Belgium
Datatable preselection is not implemented (at least for now)

you can "solve" it by using instead of the selection an extra column with checkboxes,
something like:
<p:dataTable id="authories" var="authory"  value="#{roleController.authories}" rows="10" paginator="true">
            <f:facet name="header">
               <h:outputText value="inRole" />
            <h:selectBooleanCheckbox id="openDossiers" value="#{authory.inRole}">
               <p:ajax event="click" update="authories"/>
            <f:facet name="header">
               <h:outputText value="Authory Name" />
            <h:outputText value="#{}"></h:outputText>
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)

Post 09 Jul 2010, 09:20

Posts: 164
Also you could use JavaScript.

Your DataTable needs a widgetVar. For example:

<p:dataTable widgetVar="yourTable" .... >

Use this JavaScript

yourTable.selectRow(1); //selects row 1
yourTable.selectRow(2); //selects row 2 too
yourTable.selectRow(3); //selects row 3 too
PrimeFaces 3.0, Glassfish 3.1.2, Mojarra 2.1.6,

Post 09 Jul 2010, 11:18

Posts: 17050
Location: Cybertron

Datatable preselection was implemented if it doesn't work please create an issue. We're pushing all datatable related issues to 2.1.1 as it will introduce new powerful datatable soon.

Return to General