JSF Primefaces c:foreach issue with ajaxlistner - jsf

I need to solve this issue.
I am using jsf primefaces with c:foreach here is my code. but this code is not running.
<p:tab id="catagoryTab" title="#{hardvalue['tutor.reg.tab2']}">
<p:panel header="#{hardvalue['tutor.reg.tab2']}" id="rowCreator">
<h:outputLabel value="#{hardvalue['tutor.reg.selectStmt']}"></h:outputLabel>
<h:panelGrid columns="3" style="width:100%;">
<p:outputLabel value="#{hardvalue['tutor.reg.category.table.collection']}"/>
<p:outputLabel value="#{hardvalue['tutor.reg.category.table.level']}"/>
<p:outputLabel value="#{hardvalue['tutor.reg.category.table.subject']}"/>
</h:panelGrid>
<c:forEach begin="0" end="#{Registerbean.size -1}" varStatus="loop" var="row">
<h:panelGrid columns="3"
style="width:100%; border: 1px solid #d4f1ff; border-radius: 3px 3px 3px 3px; background:#F7FDFF 50% 50% repeat-x ;">
<p:selectOneMenu
value="#{Registerbean.selectedtutorialType[loop.index]}"
style="font-size:15px !important; width:100px;">
<p:ajax process="#this" update="levellist1_#{loop.index}, levellist2_#{loop.index}, subjectlist_#{loop.index}" event="change"
listener="#{Registerbean.updateRecords(loop.index)}" />
<f:selectItem itemLabel="#{hardvalue['tutor.tutorial']}"
itemValue="tutorial" />
<f:selectItem itemLabel="#{hardvalue['tutor.conversaion']}"
itemValue="conversation" />
<f:selectItem itemLabel="#{hardvalue['tutor.music']}"
itemValue="music" />
<f:selectItem itemLabel="#{hardvalue['tutor.other']}"
itemValue="other" />
</p:selectOneMenu>
<h:panelGrid columns="3" >
<p:selectOneMenu style="width:230px" id="levellist1_#{loop.index}" value="#{Registerbean.selectedtutorialLevelFrom[loop.index]}"
>
<f:selectItems value="#{Registerbean.levellist}" />
</p:selectOneMenu>
<p:outputLabel value=" #{hardvalue['tutor.reg.to']} " />
<p:selectOneMenu style="width:230px" id="levellist2_#{loop.index}" value="#{Registerbean.selectedtutorialLevelTo[loop.index]}"
>
<f:selectItems value="#{Registerbean.levellist}" />
</p:selectOneMenu>
</h:panelGrid>
<p:selectOneMenu id="subjectlist_#{loop.index}" value="#{Registerbean.selectedtutorialSubject[loop.index]}"
style="width:230px;"
label="#{hardvalue['tutorsearch.select']}" filter="true" filterMatchMode="startsWith"
panelStyle="width:383px">
<f:selectItems value="#{Registerbean.subjectslist}" />
</p:selectOneMenu>
</h:panelGrid>
</c:forEach>
<p:commandButton id="moreButton" value="#{hardvalue['tutor.reg.addmore']}" update="rowCreator" process="#this" actionListener="#{Registerbean.addNewRow}" />
</p:panel>
</p:tab>
The above code is a tab in wizard. So I need to move on the next page after this one.
But I am not able to get the values as it do not let me assign to the array variables using indexes. Here is my backingbean
bean name: #ManagedBean(name="Registerbean")
private Tutor tutor= new Tutor();
private String[] selectedtutorialType= new String[size];
private String[] selectedtutorialLevelFrom= new String[size];
private String[] selectedtutorialLevelTo= new String[size];
private String[] selectedtutorialSubject= new String[size];
public void addNewRow(){
System.out.println("In add row");
size++;
selectedtutorialSubject=selectedtutorialLevelTo= selectedtutorialLevelFrom=selectedtutorialType=new String[size];
}
Here is my flowlistner through which I am just checking about the values of this tab. flowListener="#{Registerbean.onFlowProcess}"
public String onFlowProcess(FlowEvent event) {
System.out.println("tab id is:"+event.getOldStep());
if(event.getOldStep().equalsIgnoreCase("catagoryTab")){
for(int i=0;i<selectedtutorialType.length;i++){
System.out.println("selectedtutorialType : "+selectedtutorialType[i]);
System.out.println("selectedtutorialLevelFrom : "+selectedtutorialLevelFrom[i]);
System.out.println("selectedtutorialLevelTo : "+selectedtutorialLevelTo[i]);
System.out.println("selectedtutorialSubject : "+selectedtutorialSubject[i]);
}
}
return event.getNewStep();
}
What I want is : I want to draw components. on add row A component line will be added here. first one of the component's value changes, it reflacts the values of other two in that row only. but I is not doing the same. As the next button of p:wizard is not allowing me to move upword.
for updates it uses this function of backing bean.
public void updateRecords(int index) {
System.out.println("In update records: "+index);
levellist = new ArrayList<String>();
if (selectedtutorialType[index].equals("tutorial")) {
subjectslist = Arrays.asList(tutorialSubject);
levellist = Arrays.asList(tutorialLevel);
System.out.println("tutorial selection done..");
return;
} else if (selectedtutorialType[index].equals("conversation")) {
subjectslist = Arrays.asList(conversationSubject);
levellist = Arrays.asList(conversationLevel);
System.out.println("Conversation selection done..");
return;
} else if (selectedtutorialType[index].equals("music")) {
subjectslist = Arrays.asList(musicSubject);
levellist = Arrays.asList(musicLevel);
System.out.println("Music selection done..");
return;
} else {
subjectslist = Arrays.asList(otherSubject);
levellist = Arrays.asList(otherLevel);
System.out.println("Other selection done..");
return;
}
}
What to do. Plz help. Any other detail for this, if I am missing, let me know.
Thanks

Related

selected value in p:selectOneMenu was lost

Good day!
I'm using JSF 2.1 Primefaces 4.0 Glassfish 3.2.1
In my Form.xhtml, I have this code.
<h:form id="modDlgFormc">
<p:dialog id="modIDc" header="Criteria Info"
showEffect="fade" hideEffect="fade" modal="true"
resizable="false" widgetVar="modDlgc" closable="false"
position="center" visible ="#{Fame.modVisiblec}">
<p:messages id="pmsgCrit" closable="true"/>
<h:panelGrid id="criteriapGrid" columns="1">
<h:panelGrid id="critLabelId" columns="2">
<p:selectOneMenu id="fieldNameId" value="#
{Fame.fieldName}" var="fieldSelect">
<f:selectItem itemLabel="Select Field Name"
itemValue="" />
<f:selectItems value="#{Fame.fieldNameMap}" />
<p:ajax event="change" update="fieldNameId
operandId" listener="#{Fame.fieldNameChange}"/>
</p:selectOneMenu>
<p:selectOneMenu id="operandId" value="#{Fame.operator}" >
<f:selectItem itemLabel="Select Operand" itemValue="" />
<f:selectItems value="#{Fame.operandMap}" />
<p:ajax event="change" update="operandId valueId"
listener="#{Fame.operandChange}" />
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid id="valueId" columns="2">
<c:if test="#{Fame.showValue == 'txt'}">
<h:outputLabel for="inputVal" value="Value : " style="font-weight: bolder"/>
<p:inputText id="inputVal" size="30" value="#{Fame.value}"/>
<c:if test="#{Fame.operator == 'Is Between'}">
<h:outputText value=""/>
<p:inputText size="30" value="#{Fame.value2}"/>
</c:if>
</c:if>
<c:if test="#{Fame.showValue == 'cal'}">
<h:outputLabel for="fromDateId" value="From : " style="font-weight: bolder"/>
<p:calendar id="fromDateId" value="#{Fame.date}" showButtonPanel="true" maxdate="#{Fame.maxDate}"/>
<c:if test="#{Fame.operator == 'Is Between'}">
<h:outputLabel for="toDateId" value="To : " style="font-weight: bolder"/>
<p:calendar id="toDateId" value="#{Fame.date2}" showButtonPanel="true" maxdate="#{Fame.maxDate}"/>
</c:if>
</c:if>
<c:if test="#{Fame.showValue == 'upload'}">
<h:outputText value=""/>
<p:commandButton value="UPLOAD" onclick="uconfirmation.show()" type="button" />
</c:if>
</h:panelGrid>
<h:panelGrid id="critBtnId" columns="4">
<p:commandButton id="addBtn" value="ADD" actionListener="#{Fame.saveCriteria}" update=":modDlgFormc:modIDc" rendered="#{empty Fame.editMode}" />
<p:commandButton value="SAVE" actionListener="#{Fame.updateCriteria}" update=":modDlgFormc:modIDc" rendered="#{not empty Fame.editMode}"/>
<p:commandButton value="CANCEL" actionListener="#{Fame.cancelCriteria}" update=":modDlgFormc" rendered="#{not empty Fame.editMode}"/>
<p:commandButton id="mCancelButtonc" value="CLOSE" update=":modDlgFormc:modIDc :wbookForm" actionListener="#{Fame.closealldialogsopen}"/>
</h:panelGrid>
<br/>
</h:panelGrid>
<center>
<h:panelGrid id="critDTable" columns="1">
<p:dataTable id="criteriaTbl" var="criteria" value="#{Fame.createdCriteria}" paginator="true" rows="5" rowIndexVar="rowIndex" paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
currentPageReportTemplate="{totalRecords} record(s) in {totalPages} page(s)">
<p:column headerText="WORKSHEET NAME">
#{criteria.wsheetName}
</p:column>
<p:column headerText="FIELD NAME">
#{criteria.fieldName}
</p:column>
<p:column headerText="OPERATOR">
#{criteria.operator}
</p:column>
<p:column headerText="VALUE">
#{criteria.value}
</p:column>
<p:column headerText="UPDATE">
<p:panelGrid>
<p:row>
<p:column style="vertical-align: top;border: none">
<p:commandButton actionListener="#{Fame.editCri(rowIndex)}" style="width:30px;text-align:center;border:none;background-color:transparent;" icon="ui-icon-pencil" update=":modDlgFormc" />
<p:commandButton actionListener="#{Fame.deleteCri(rowIndex)}" style="width:30px;text-align:center;border:none;background-color:transparent;" icon="ui-icon-close" update=":modDlgFormc" />
</p:column>
</p:row>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:panelGrid>
</center>
</p:dialog>
</h:form>
My Main code
#ManagedBean(name = "Fame")
#SessionScoped
private FameCriteriaDAOImpl fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
private ArrayList<FameCriteriaBean> createdCriteria = new ArrayList();
public void saveCriteria() {
fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
try {
if (this.validate() == true) {
//String wsheetId = fameManagementDP.getWsheetId(group_Id, workbookName);
FameCriteriaBean bean = new FameCriteriaBean();
bean.setWsheetId(this.worksheetId);
bean.setFieldName(this.fieldName);
bean.setOperator(this.operator);
bean.setValue(this.value);
String actionStr = "inserted";
fameCriteriaDAOImpl.save(bean);
}
} catch (SQLException sqlEx) {
sqlEx.printStackTrace();
error(converter.getConvertedError(sqlEx.getMessage()));
} finally {
this.initialize();
this.initializeCreatedCriteria();
this.resetCriteria();
}
}
My Bean code.
public class FameCriteriaBean {
private String wsheetName = "";
private String wsheetId = "";
private String fieldName = "";
private String operator = "";
private String value = "";
public FameCriteriaBean(){
}
/**
* #return the fieldName
*/
public String getFieldName() {
return fieldName;
}
/**
* #param fieldName the fieldName to set
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* #return the operator
*/
public String getOperator() {
return operator;
}
/**
* #param operator the operator to set
*/
public void setOperator(String operator) {
this.operator = operator;
}
/**
* #return the value
*/
public String getValue() {
return value;
}
/**
* #param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
/**
* #return the wsheetId
*/
public String getWsheetId() {
return wsheetId;
}
/**
* #param wsheetId the wsheetId to set
*/
public void setWsheetId(String wsheetId) {
this.wsheetId = wsheetId;
}
/**
* #return the wsheetName
*/
public String getWsheetName() {
return wsheetName;
}
/**
* #param wsheetName the wsheetName to set
*/
public void setWsheetName(String wsheetName) {
this.wsheetName = wsheetName;
}
}
Below is the scenario.
I choose a fieldName then the lists of operand was loaded. This is correct.
I click the button ADD, then a p:message appear that there is no operand selected. This is correct.
I had noticed that the fieldname value that I was selected when error appears was gone.
My question is how not to refresh the value of fieldNameId so that I can use it after an error is displayed in p:message.
I'm using SessionScoped for my java class because I'm using p:wizard in Form.xhtml.
Please help me to solve this.
Thank you and More Power! :)
What I did is this.
Please see updated Main class
#ManagedBean(name = "Fame")
#SessionScoped
private FameCriteriaDAOImpl fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
private ArrayList<FameCriteriaBean> createdCriteria = new ArrayList();
public void saveCriteria() {
fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
if (!this.validate()) {
return;
}
try {
FameCriteriaBean bean = new FameCriteriaBean();
bean.setWsheetId(this.worksheetId);
bean.setFieldName(this.fieldName);
bean.setOperator(this.operator);
bean.setValue(this.value);
String actionStr = "inserted";
fameCriteriaDAOImpl.save(bean);
} catch (SQLException sqlEx) {
sqlEx.printStackTrace();
error(converter.getConvertedError(sqlEx.getMessage()));
} finally {
this.initialize();
this.initializeCreatedCriteria();
this.resetCriteria();
}
}

Select One Menu returning Null value in the Backing bean?

I need to return the selected value to the bean for further processing but its returning null value .
<h:form>
<h:panelGrid columns="1">
<p:outputLabel id="state" value="State Name"></p:outputLabel>
<p:selectOneMenu id="statemenu" style="width:300px;"
value="#{MenuBean.state}">
<f:selectItem itemLabel="Select One"></f:selectItem>
<f:selectItems value="#{MenuBean.stateList}"></f:selectItems>
<p:ajax listener="#{MenuBean.stateChange}" update="dist"
process="#this" immediate="true"></p:ajax>
</p:selectOneMenu>
<br></br>
<p:outputLabel value="District"></p:outputLabel>
<p:selectOneMenu id="dist" style="width:300px;"
value="#{MenuBean.district}">
<f:selectItem itemLabel="Select One"></f:selectItem>
<f:selectItems value="#{MenuBean.districtList}"></f:selectItems>
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid style="position:relative; left:165px" columns="2"
cellpadding="2" cellspacing="2">
<p:commandButton value="Reset"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px; font-weight: normal'></p:commandButton>
<p:commandButton value="Submit" immediate="true"
action="#{MenuBean.getValues}"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 14px; font-weight: normal'></p:commandButton>
</h:panelGrid>
</h:form>
and the backing beaning is
private String state;
private String district;
private Map<String,String> StateList = new HashMap<String,String> ();;
private Map<String,String> DistrictList = new HashMap<String,String>();
public MenuBean() {
System.out.println("Entering the Constructor");
StateList = DBConnector.StateList();
// DistrictList = DBConnector.DistrictList();
}
public void stateChange() {
DistrictList = DBConnector.DistrictList();
}
public void getValues() {
System.out.println("getting the values");
System.out.println(getState());
System.out.println(getDistrict());
}
I have edited the code snippet i guess it will give you a insight on it .
Change your method stateChange to :
public void stateChange(AjaxBehaviorEvent event) {
setState(event.getComponent().getAttributes().get("value"));
DistrictList = DBConnector.DistrictList();
}
And change <f:selectItems value="#{MenuBean.stateList}"></f:selectItems> to <f:selectItems value="#{MenuBean.stateList}" var="state" itemValue="state.id" itemLabel="state.id"/>
So after you posted full xhtml I see the reason why it is not working.
you have on the page <p:commandButton value="Submit" immediate="true". You have immediate attribute which means no values from inputs or dropdowns will be set to you beans. Immediate attribute forces jsf to skip all phases except invoke application and render response. To read more about jsf phases read this post
You need to remove this attribute from submit button and it should start working. Also according to this post in primefaces update="#form". So your button will look like this:
<p:commandButton value="Submit" update="#form" action="#{MenuBean.getValues}"

Primefaces, Menuitem ActionListener on Right Click

i'm having some questions here. I will appreciate all of your helps.
I'm making some dynamic multilevel menu in primefaces, and i did it. There are parents, sub menus, and the menu items.
I want to give some CRUD action for each component via context menu, so I can edit the value/text for each level just with right-click.
I make the menu with bean called MenussBean.java, and you can see it below (just the correspond code).
public Submenu subMenus(Submenu parentMenus,String i, int id)
{
if(i==""&&parentMenus==null)
{
subList = menusdao.getRootMenu();
for(int a=0;a<subList.size();a++){
parentMenus = new Submenu();
parentMenus.setLabel(subList.get(a).getMenu());
model.addSubmenu(parentMenus);
i=subList.get(a).getMenu();
subMen = null;
id = a+1;
subList2 = subKategori(id);
for(Menus k:subList2){
if(String.valueOf(parentMenus.getLabel().toString()).equals(i)){
subMen = new Submenu();
subMen.setId("_"+k.getId());
subMen.setLabel(k.getMenu());
parentMenus.getChildren().add(subMen);
subMenus(subMen,k.getMenu(),k.getId());
}
}
}
}else{
subMen = null;
subList2 = subKategori(id);
for(Menus k:subList2){
if(String.valueOf(parentMenus.getLabel().toString()).equals(i)){
subList3=subKategori(k.getId());
if(subList3.size()==0)
{
UIParameter uiParam = new UIParameter();
UIParameter menuParam = new UIParameter();
UIParameter idParentParam = new UIParameter();
uiParam.setName("idParam");
uiParam.setValue(k.getId());
menuParam.setName("menuParam");
menuParam.setValue(k.getMenu());
idParentParam.setName("idParentParam");
idParentParam.setValue(k.getId_parent());
MenuItem mi = new MenuItem();
mi.setId("_"+k.getId());
Application app = FacesContext.getCurrentInstance().getApplication();
MethodExpression methodExpr = app.getExpressionFactory().createMethodExpression
(FacesContext.getCurrentInstance().getELContext(), "#{menussBean.onItemClick}", null ,new Class[]{ javax.faces.event.ActionEvent.class});
mi.addActionListener(new MethodExpressionActionListener(methodExpr));
mi.setOncomplete("");
mi.setValue(k.getMenu());
mi.setTarget("_self");
mi.setTitle(k.getLink());
mi.setAjax(false);
mi.getChildren().add(uiParam);
mi.getChildren().add(menuParam);
mi.getChildren().add(idParentParam);
mi.setProcess("#all");
parentMenus.getChildren().add(mi);
}
else if (subList3.size()!=0)
{
subMen = new Submenu();
subMen.setId("_"+k.getId());
subMen.setLabel(k.getMenu());
parentMenus.getChildren().add(subMen);
subMenus(subMen,k.getMenu(),k.getId());
}
}
}
}
return parentMenus;
}
public List<Menus> subKategori(int i)
{
arayList=new ArrayList<Menus>();
for(Menus k:getList()){
if(k.getId_parent()==i){
arayList.add(k);
}
}
return arayList;
}
public static List<Menus> getList() {
return list;
}
This is the value-getter method:
public void onItemClick() {
FacesContext context = FacesContext.getCurrentInstance();
idItem = context.getExternalContext().getRequestParameterMap().get("idParam");
menuItem = context.getExternalContext().getRequestParameterMap().get("menuParam");
idParentItem = context.getExternalContext().getRequestParameterMap().get("idParentParam");
}
And I want to use context menu to give the CRUD operations, so the user can right-click on the component he wants to edit. Here is my xhtml files.
<h:form>
<p:panelMenu id="panel" style="width:400px;font-size:12px"
model="#{menussBean.model}" var="detail" selectionMode="single" ajax="true"
widgetVar = "panelMen" styleClass="myMeineClass">
</p:panelMenu>
<p:contextMenu for="panel" style="font-size:12px">
<p:menuitem value="View" icon="ui-icon-search"
oncomplete="menuDialog.show()" update="display">
<f:param name="id_barangbaru" value="#{detail}" />
</p:menuitem>
<p:menuitem value="Add" icon="ui-icon-plus" />
<p:menuitem value="Edit" icon="ui-icon-pencil" />
<p:menuitem value="Delete" icon="ui-icon-close" />
</p:contextMenu>
<p:dialog header="Menu Detail" widgetVar="menuDialog"
resizable="false" width="200" showEffect="clip" hideEffect="fold"
id="dialog" appendToBody="true" modal="true">
<h:panelGrid id="display" columns="2" cellpadding="4" style="font-size:12px">
<h:outputText value="ID:" />
<h:outputText value="#{menussBean.idItem}"
style="font-weight:bold" />
<h:outputText value="Label:" />
<h:outputText value="#{menussBean.menuItem}"
style="font-weight:bold" />
<h:outputText value="Parent:" />
<h:outputText value="#{menussBean.idParentItem}"
style="font-weight:bold" />
</h:panelGrid>
</p:dialog>
</h:form>
Right now, I'm still getting the value into the context menu output text, but it needs to be left-clicked first. I need to pass the value directly just with right-click.
So, how can I get the value with actionListener with right-click? Please help...
I want to show the screenshot but I'm new here, so I haven't got any reputation.

Render p:selectManyCheckbox with 10 columns

I developed an interface JEE / JSF for some statistics.
I created checkbox to select references that the user wishes to display, but the trouble is that I use to generate the checkbox Arraylist based on data from my database.
And I can not position them as I want. I wish that after 10 checkbox, others generates directly to the line etc. ..
I have this result
And i wish i could do this
MTBFBEAN
private List<String> selectedReference = new ArrayList<String>();
private List<String> listReference = new ArrayList<String>();
private Boolean afficher = false; // Déclaration du bool pour le rendered de
// ma vue dans MTBF
#SuppressWarnings("deprecation")
public StatisticsBeanMTBF() {
this.beginDate = new Date(2001, 00, 01);
List<ProductConfModel> listtmp = this.moduleGlobal.getProductConfModels(2);
for (ProductConfModel pcm : listtmp) {
this.listReference.add(pcm.getReference());
}
}
public void mTBFByType() {
this.afficher = true;
this.listMTBF = new ArrayList<StatistiquesMTBF>();
List<StatistiquesMTBF> suspense = this.moduleGlobal.getMTBFByType(nbHeure, nbJour, NS, DAE, beginDate, endDate);
for (StatistiquesMTBF smtbf : suspense) {
for (String s : this.selectedReference) {
if (smtbf.getReference().equals(s)) {
this.listMTBF.add(smtbf);
}
JSF XHTML
<h:outputText value="Date début :* " />
<p:calendar value="#{statisticsBeanMTBF.beginDate}"
navigator="true" required="true" />
<h:outputText value="Date fin:* " />
<p:calendar value="#{statisticsBeanMTBF.endDate}" navigator="true"
required="true" />
</h:panelGrid>
<h:panelGrid columns="1">
<h:outputText value="Selectionner votre référence : " />
<p:selectManyCheckbox id="grid" columns="5"
value="#{statisticsBeanMTBF.selectedReference}">
<f:selectItems value="#{statisticsBeanMTBF.listReference}" />
</p:selectManyCheckbox>
</h:panelGrid>
<p:separator />
If anyone can help me it would be nice.
Thank you !
I get this outcome using:
<h:panelGroup layout="block" styleClass="selection">
<p:selectManyCheckbox layout="pageDirection" value="#{selection.selection}">
</h:panelGroup>
and setting each <tr>:
.selection tr {
float: left;
width: 33%;
}
In your case set it to 10% and outer container to width: 100%.
It looks like that:
You should add layout="grid" to your p:selectManyCheckbox according to this example. Like this :
<p:selectManyCheckbox id="grid" layout="grid" columns="5" value="#{statisticsBeanMTBF.selectedReference}">
<f:selectItems value="#{statisticsBeanMTBF.listReference}" />
</p:selectManyCheckbox>
EDIT :
A fast search in PrimeFaces documentations show that columns was added in the version 4.0. If you doesn't have this version or can't upgrade, you'll need to do it the old way with some CSS.

JSF - PrimeFaces , How to get the value of a booleanCheckbox / booleanButton in a list

I have a jsf page that I can't update the value of some checkboxes in a list of userDamain objects, in fact this is a part of my jsf page :
<h:outputText value="USER's rights list: "></h:outputText>
<p:dataTable id="userss" var="userr" value="#{userMB.userListe}">
<p:column>
<f:facet name="header"><h:outputText value="FirstName" /></f:facet>
<h:outputText value="#{userr.firstName}" />
</p:column>
<p:column>
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="Basic Usage: " />
<p:selectBooleanCheckbox value="#{userr.deletee}" immediate="true" actionListener="#{userr.deletee}" />
</h:panelGrid>
<p:commandButton value="Submit" update="display" oncomplete="dlg.show()" />
<p:dialog header="Selected Values" modal="true" showEffect="fade" hideEffect="fade" widgetVar="dlg">
<h:panelGrid columns="1" id="display">
<h:outputText value="Value 1: #{userr.deletee}" />
</h:panelGrid>
</p:dialog>
</p:column>
when I click on the boolean button 'Submit', the value of the userr.deletee is always false ( the default value ) and it's not updated anyway, I tried to use the Listner and actionListener in the booleanButton but it doesn't work, I also tried the postValidate event, so if someone has any idea of that, I would be graceful.
this is a part of my managed bean:
private List<UserDomain> userListe ;
public List<UserDomain> getUserListe() {
return this.userListe;
}
public void loadUserListe(){
this.userListe = new ArrayList<UserDomain>();
this.userListe.addAll(getUserServicee().getAll());
}
public void setUserListe(List<UserDomain> userListe) {
this.userListe = userListe;
}
a part of the userDomain bean:
...
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
#Transient
private boolean deletee;
public boolean isDeletee() {
return deletee;
}
public void setDeletee(boolean deletee) {
this.deletee = deletee;
}
I found out a solution which seems logic to me, I added to my checkbox an ajax behavior to execute a method and an attribute which called in this method to get the whole userDomain object, so on I can get the user.deletee value, here is a part of the code I m talking about:
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="Delete Right: " />
<p:selectBooleanCheckbox value="#{userr.deletee}">
<f:ajax execute="#this" listener="#{userMB.saveUserRights}" />
<f:attribute name="user" value="#{userr}" />
</p:selectBooleanCheckbox>
</h:panelGrid>
I hope this will be helpful for you

Resources