JSF Primefaces ajax on p:datatable - ajax

I am using JSF Primefaces for my UI. I have a specific requirement about ajax on p:datatable. This is a sample page of my project:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:comp="http://java.sun.com/jsf/composite/components/">
<ui:define name="content">
<h:form id="form1">
<p:growl id="messages" showDetail="false" />
<p:panel header="Available Rows" style="width: 15%;">
<p:dataTable id="table" value="#{rowBean.rows}" var="row"
widgetVar="50" style="width: 60px;" editable="true">
<p:ajax event="rowEdit" listener="#{rowBean.onEdit}"
update="form1:messages" />
<p:ajax event="rowEditCancel" listener="#{rowBean.onCancel}"
update=":form1:messages" />
<p:column>
<f:facet name="header">
<h:outputText value="Row ID" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{row.id}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{row.id}"
style="width:100%" label="Row ID">
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Row Value" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{row.value}" />
</f:facet>
<f:facet name="input">
<p:inputText disabled="true" value="#{row.value}"
style="width:100%" label="Row Value">
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:panel>
<p:spacer height="5px;"/>
<p:panel id="createPanel" header="Create Row" closable="false" toggleable="true"
collapsed="true" style="width: 15%;">
<p:panelGrid columns="6">
<h:outputLabel for="rowBean" value="Row ID" />
<p:inputText value="#{rowBean.row.id}"
required="true" label="Row ID" style="width:125px" />
<h:outputLabel for="rowBean" value="Row Value" />
<p:inputText value="#{rowBean.row.value}"
required="true" label="Row Value" style="width:125px" />
<f:facet name="footer">
<p:commandButton value="Create" action="#{rowBean.createRow}"
update=":form1" />
</f:facet>
</p:panelGrid>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
Here I have a data table which lists down all the rows created. Each row is having id and value. Value is editable. There is one more panel within the form which creates new rows. Backing bean is pre-populated with all the created rows with #PostConstruct. Backing bean is having other methods to edit, cancel and create. This page is working and given below is the new requirement.
In some cases there can be an error associated with each row. If there is an error attached with a row, then the value text needs to be updated like a link. While clicking on the link, the row ID and a parameter needs to be passed to backing bean. With these params, backing bean fetches the error details and passes it to the page. Then the error message needs to be shown on a pop-up.
Can you tell me how to do this?

On the XHTML side:
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
On the JAVA side, in the function you call when you press the button:
if(error) {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_WARN, "Error",
"Your error message."));
}
PD: This is my first answer, i'm getting used to the post options, i'm sorry if you dont see my message properly ;)

Maybe like this?:
<f:facet name="output">
<h:outputText value="#{row.value}" rendered="#{!row.hasError}" />
<h:commandLink value="#{row.value}" rendered="#{row.hasError}" command="#{row.command(parameters..)}" />
</f:facet>

Related

Using primefaces p:tabView, the refresh of the tabs using p:ajax doesn't work fine. The first time refresh but the next times doesn't refresh

I have a page with a tabView, with 3 tabs, each tab has a tree. The tree of the third tab (DEVICES CATEGORY/TYPE), depends on what I select in the tree of the second tab (CERTIFICATIONS SYSTEM/PROGRAM). I generate the tree of the third tab dynamically when tab changes, using the event "tabChange"
<p:ajax event="tabChange" listener="#{profileMB.onTabChange}" />
When I select an element of the tree of the second tab and I change to the third tab, for the first time, it works OK, but when I return to the second tab and I mark differents nodes of the tree and I change to the third tab, the third tabs doesn't refresh.
The methods of the event it works OK, and generate the tree well.
public void onTabChange(TabChangeEvent event) {
log.debug(Constants.BEGIN);
if(selectedNodesCS!=null && selectedNodesCS.length>0){
rootDeviceCategory =
getDeviceCategoryService().createRootStructure(rootDeviceCategory, null,listCertSystem,listCertProgram);
}
}
I tried using the update in the ajax event "tabChange":
<p:ajax event="tabChange" listener="#{profileMB.onTabChange}" update=":formManagerProfile:tabsProfile:tabDC" />
but the console says:
Can not update component "org.primefaces.component.tabview.Tab" with id "formManagerProfile:tabsProfile:tabDC" without a attached renderer
This is the code of my XHTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:form id="formManagerProfile" style="margin: auto auto">
<h:panelGroup id="displayManager">
<p:panelGrid id="panelUp" style="text-align: left;"
styleClass="panelGridWithoutBorder">
<p:row>
<p:column>
<h:outputText value="#{msg['profile.name']}: " for="profileName" />
</p:column>
<p:column>
<h:inputText id="profileName" value="#{profileMB.profileName}"
maxlength="64" styleClass="width-100x100" />
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputText value="#{msg['profile.profileGroup']}: "
for="profileGroup" />
</p:column>
<p:column>
<p:selectOneMenu id="profileGroup"
value="#{profileMB.profileGroupSelected}"
converter="#{selectOneMenuConverterSelf}">
<f:selectItem itemLabel="" itemValue="#{null}" />
<f:selectItems id="pgSelectedItem"
value="#{profileMB.listProfileGroups}" var="pgItem"
itemValue="#{pgItem}" itemLabel="#{pgItem.name}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:commandButton id="editProfileGroup"
icon="#{msg['icon.update']}"
value="#{msg['button.text.updateProfileGroup']}"
title="#{msg['button.text.updateProfileGroup']}"
actionListener="#{profileMB.managementProfileGroup}"
update=":managerProfileGroupForm :growl"
oncomplete="PF('profileGroupManagerDialogWidget').initPosition();PF('profileGroupManagerDialogWidget').show()" />
</p:column>
</p:row>
</p:panelGrid>
<p:panel styleClass="text_align_left">
<p:commandButton id="saveButtonUp" icon="#{msg['icon.save']}"
value="#{msg['button.text.save']}"
title="#{msg['button.text.save']}"
action="#{profileMB.saveProfile}" update=":growl" />
<p:commandButton id="backButtonUp" icon="#{msg['icon.back']}"
value="#{msg['button.text.back']}"
title="#{msg['button.text.back']}" action="#{profileMB.backAction}"
ajax="false" />
</p:panel>
</h:panelGroup>
<h:panelGroup>
<p:tabView id="tabsProfile" dynamic="true">
<p:ajax event="tabChange" listener="#{profileMB.onTabChange}" />
<p:tab id="tabMenu" title="MENUS">
<p:tree value="#{profileMB.rootAction}" var="elementAction"
selectionMode="checkbox" selection="#{profileMB.selectedNodes}">
<p:treeNode>
<h:outputText value="#{elementAction}" />
</p:treeNode>
</p:tree>
</p:tab>
<p:tab id="tabCS" title="CERTIFICATIONS SYSTEM/PROGRAM">
<p:tree id="TreeCS" value="#{profileMB.rootCertSystem}"
var="elementCS" selectionMode="checkbox"
selection="#{profileMB.selectedNodesCS}">
<!-- <p:ajax event="select" listener="#{profileMB.onClickTreeCS}" /> -->
<!-- <p:ajax event="unselect" listener="#{profileMB.onClickUnSelectTreeCS}" /> -->
<p:ajax async="true" delay="none" immediate="true"
process="TreeCS" event="select" />
<p:ajax async="true" delay="none" immediate="true"
process="TreeCS" event="unselect" />
<p:treeNode>
<h:outputText value="#{elementCS}" />
</p:treeNode>
</p:tree>
</p:tab>
<p:tab id="tabDC" title="DEVICES CATEGORY/TYPE">
<p:tree id="TreeDC" value="#{profileMB.rootDeviceCategory}"
var="elementDC" selectionMode="checkbox"
selection="#{profileMB.selectedNodesDevCat}">
<p:ajax event="select" listener="#{profileMB.onClickTreeDC}" />
<p:ajax event="unselect"
listener="#{profileMB.onClickUnSelectTreeDC}" />
<p:treeNode>
<h:outputText value="#{elementDC}" />
</p:treeNode>
</p:tree>
</p:tab>
</p:tabView>
</h:panelGroup>
</h:form>
</ui:composition>
I'm using primefaces v5.1, JSF v2.2.8, spring v3.2.5, hibernate v4.2.7 and java v1.7
I found the solution in p:tabView I must used cache="false"

ajax call in jsf with popup window

Below is my code in .xhtml file. I need to add ajax call in one of the inputtextbox component. Say.. on blur of inputtextbox where id="search_dias" i should make ajax call with popup window showing the response value and then i should place that value in inputTextBox where id="search_partyName"
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:form>
<p:panel id="panel1" styleClass ="myPanelStyle1" header="SEARCH PRODUCTIONS " toggleable="true" toggleSpeed="100">
<h:panelGrid columns="3" border="0" rules="group">
<p:column >
<h:outputLabel for="search_dia" value="Diameter:"/>
</p:column>
<p:column>
<p:inputText id="search_dias" value="#{addFormRequest.diameter}"/>
</p:column>
<p:tooltip for="search_dias" value="Enter Dia Value" showEffect="fade" hideEffect="fade" />
<p:column >
<h:outputLabel for="search_partyName" value="PartyName:"/>
</p:column>
<p:column>
<p:inputText id="search_partyName" value="#{addFormRequest.search_partyName}"/>
</p:column>
<p:tooltip for="search_partyName" value="Enter Party Name" showEffect="fade" hideEffect="fade" />
<p:column >
<h:outputLabel for="search_date" value="Date:"/>
</p:column>
<p:calendar id="search_date" value="#{addFormRequest.search_date}"/>
<p:tooltip for="search_date" value="Enter Production Date" showEffect="fade" hideEffect="fade" />
<p:commandButton id="searchProductions" value="SEARCH" action="search" />
</h:panelGrid>
</p:panel>
</h:form>
The answers can be found here:
Show dialog on dataTable row selection
Inputtext blur event
Show dialog on ajax event in dataTable

why does the p:dialog not submit values to bean

I have a small jsf/primefaces application with a datgrid that shows (order) items.
Now I want to add items during a dialog.
I open the dialog with a button click. - works
I want to submit the values from the dialog to the bean and update the datagrid.
If I use a default value (not from the dialog) it works. The item get shown in the datagrid and the dialog get closed. That means.
-addItem Function works
-update works
But if I want to add the values from the dialog I get a null Pointer Exception. So my values will not set in the bean.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:fieldset legend="Positionen" toggleable="true" toggleSpeed="500" styleClass="mbsFieldSet">
<h:form id="form_positions">
<p:growl id="messages" showDetail="true" />
<!-- Add position mask -->
<!-- Button to open the open position mask -->
<p:commandButton id="btOpenAddPositionMask" value="Position via Dialog" onclick="dlg.show();">
</p:commandButton>
<p:dataTable var="banfPosition" value="#{banfPositionBean.lsBanfPositions}"
id="tableBanfPositions" editable="true" >
<f:facet name="header">Positionen</f:facet>
<!-- AJAX Events for editing position values -->
<p:ajax event="rowEdit" listener="#{banfPositionBean.onEdit}"
update=":form_positions:messages"/>
<p:ajax event="rowEditCancel" listener="#{banfPositionBean.onCancel}"
update=":form_positions:tableBanfPositions" />
<p:column headerText="Menge" style="width:50px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.amount}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.amount}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Matr. / Lager-Nr." style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.stockNumber}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.stockNumber}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Artikel" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.article}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.article}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Preis/Einheit" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.price}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.price}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Gesamtpreis" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.sum}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.sum}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Etat-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.etat}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.etat}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Anlagen-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.complex}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.complex}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Ändern" style="width:20px; text-align:center">
<p:rowEditor />
</p:column>
<p:column headerText="Löschen" style="width:20px; text-align:center" >
<p:commandButton id="deletePos" actionListener="#{banfPositionBean.deletePos(banfPosition)}"
update=":form_positions:tableBanfPositions" ajax="true" icon="ui-icon ui-icon-close" iconPos="center"
title="Löscht den Eintrag in dieser Zeile." />
</p:column>
</p:dataTable>
</h:form>
</p:fieldset>
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</p:dialog>
</ui:composition>
I try it with the h:form-Tag as it is shown on http://www.primefaces.org/showcase/ui/dialogForm.jsf But If I add this.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</h:form>
</p:dialog>
the page get reloaded but my bean will not be called either.
Do anyone have an idea what i am doing wrong?
Thanks for help.
-------------------------------------------
*EDIT*
-------------------------------------------
I try it with an p:inputText instead of an selectOneMenu an the bean gets called.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false" appendToBody="true">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="inputTxt" value="Artikel:" />
<p:inputText id="inputTxt" value="#{banfPositionBean.testStr}"></p:inputText>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();">
</p:commandButton>
</h:form>
</p:dialog>
So I just need to find out why it will not work for the selectOneMenu.
First I don't know what is a type of property selectedArticle, I guess it is the same type as article (in itemValue) attribute. You should define converter or on the other hand you should bind value of selectOneMenu to be the same type as article.id, and set itemValue to #{article.id}.

How to reference #{cc.clientId} in ajax update/process/render/execute?

I don't know how to reference descendant components of composite component in update or process (alias render or execute).
I have this composite component resources/components/crud.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsf/composite">
<c:interface>
<c:attribute name="controller" required="true" />
<c:facet name="fields" required="true"/>
</c:interface>
<c:implementation>
<p:dataTable
id="table"
value="#{cc.attrs.controller.autoResultModel}"
var="unit"
paginator="true"
rows="10"
lazy="true"
paginatorAlwaysVisible="true"
paginatorPosition="top"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
currentPageReportTemplate="{totalRecords} records found, Page: {currentPage}/{totalPages}"
rowsPerPageTemplate="5,10,15"
sortBy="#{unit.creationTime}"
sortOrder="descending"
selectionMode="single"
selection="#{cc.attrs.controller.selected}">
<p:ajax event="rowSelect" update="editDialog trashDialog table:commands"/>
<f:facet name="header">
<h:panelGroup id="commands" layout="block">
<p:commandButton id="newButton" value="new" image="ui-icon ui-icon-plusthick" oncomplete="editDialog.show()" actionListener="#{cc.attrs.controller.clearSelected()}" process="#this" update="#{cc.clientId}" />
<p:commandButton value="edit" image="ui-icon ui-icon-wrench" onclick="editDialog.show()" type="button" disabled="#{cc.attrs.controller.selected.id == null}"/>
<p:commandButton value="delete" image="ui-icon ui-icon-trash" onclick="trashDialog.show()" type="button" disabled="#{cc.attrs.controller.selected.id == null}"/>
</h:panelGroup>
</f:facet>
<c:insertChildren/>
</p:dataTable>
<h:panelGroup id="editDialog">
<p:dialog modal="true" widgetVar="editDialog" showEffect="fold" hideEffect="puff">
<f:facet name="header">
<h:outputText value="#{bundle['create']}" rendered="#{cc.attrs.controller.selected.id == null}"/>
<h:outputText value="#{bundle['update']}" rendered="#{cc.attrs.controller.selected.id != null}"/>
</f:facet>
<h:panelGroup layout="block">
<c:renderFacet name="fields"/>
<br/>
<p:commandButton value="#{bundle['create']}" actionListener="#{cc.attrs.controller.create}" process="editDialog" update="table" oncomplete="closeDialog(xhr, status, args, editDialog)" rendered="#{cc.attrs.controller.selected.id == null}"/>
<p:commandButton value="#{bundle['update']}" actionListener="#{cc.attrs.controller.update}" process="editDialog" update="table" oncomplete="closeDialog(xhr, status, args, editDialog)" rendered="#{cc.attrs.controller.selected.id != null}"/>
<p:commandButton value="#{bundle['copy']}" actionListener="#{cc.attrs.controller.create}" process="editDialog" update="table" oncomplete="closeDialog(xhr, status, args, editDialog)" rendered="#{cc.attrs.controller.selected.id != null}">
<f:setPropertyActionListener target="#{cc.attrs.controller.selected.id}" value="#{null}"/>
</p:commandButton>
</h:panelGroup>
</p:dialog>
</h:panelGroup>
<p:dialog modal="true" header="asdasd" widgetVar="trashDialog" hideEffect="explode" showEffect="explode">
<h:panelGroup id="trashDialog" layout="block">
<h:outputText value="#{bundle['trashconfirm']}">
<f:param name="name" value="#{cc.attrs.controller.selected.name}"/>
</h:outputText>
</h:panelGroup>
<p:commandButton value="#{bundle['confirm']}" actionListener="#{cc.attrs.controller.destroy}" process="#this" update="table" oncomplete="closeDialog(xhr, status, args, trashDialog)"/>
</p:dialog>
</c:implementation>
</html>
called by this page test.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cc="http://java.sun.com/jsf/composite/components">
<h:head>
<title>Default Title</title>
<h:outputStylesheet name="css/screen.css"/>
<h:outputScript name="js/common.js"/>
</h:head>
<h:body>
<p:growl id="messages" autoUpdate="true"/>
<h:form id="itemForm">
<cc:crud id="itemCrud" controller="#{itemController}">
<f:facet name="fields">
<h:panelGrid columns="3">
<h:outputLabel value="manufacturer" for="manufacturer"/>
<p:selectOneMenu id="manufacturer" value="#{itemController.selected.manufacturer}" converter="#{manufacturerController.converter}">
<f:selectItems value="#{manufacturerController.facade.findAll()}" var="e" itemLabel="#{e.title}" itemValue="#{e}"/>
</p:selectOneMenu>
<p:message for="manufacturer"/>
<h:outputLabel value="partNumber" for="partNumber"/>
<p:inputText id="partNumber" value="#{itemController.selected.partNumber}"/>
<p:message for="partNumber"/>
<h:outputLabel value="configurationIndex" for="configurationIndex"/>
<p:inputText id="configurationIndex" value="#{itemController.selected.configurationIndex}"/>
<p:message for="configurationIndex"/>
</h:panelGrid>
</f:facet>
<p:column headerText="#{bundle['manufacturer']}" filterBy="#{unit.manufacturer.title}" sortBy="#{unit.manufacturer.title}">
#{unit.manufacturer.title}
</p:column>
<p:column headerText="#{bundle['partNumber']}" filterBy="#{unit.partNumber}" sortBy="#{unit.partNumber}">
#{unit.partNumber}
</p:column>
<p:column headerText="#{bundle['configurationIndex']}" filterBy="#{unit.configurationIndex}" sortBy="#{unit.configurationIndex}">
#{unit.configurationIndex}
</p:column>
<p:column headerText="#{bundle['modifyStatus']}" filterBy="#{unit.modifyStatus}" sortBy="#{unit.modifyStatus}">
#{unit.modifyStatus}
</p:column>
<p:column headerText="#{bundle['description']}" filterBy="#{unit.description}" sortBy="#{unit.description}">
#{unit.description}
</p:column>
</cc:crud>
</h:form>
</h:body>
</html>
And I have this output:
AVVERTENZA: PWC4011: Unable to set request character encoding to UTF-8 from context /epcsdb, because request parameters have already been read, or ServletRequest.getReader() has already been called
INFO: Skipping call to libraryExists(). Please set context-param com.sun.faces.enableMissingResourceLibraryDetection to true to verify if library http://java.sun.com/jsf/composite/components actually exists
INFO: Cannot find component with identifier "itemForm:itemCrud:table:newButton" in view.
INFO: Cannot find component with identifier "itemForm:itemCrud" in view.
INFO: Cannot find component with identifier "editDialog" in view.
INFO: Cannot find component with identifier "trashDialog" in view.
INFO: Cannot find component with identifier "itemForm:itemCrud:j_idt34" in view.
Result of this is that no component is updated with any ajax call. I don't understand why "itemForm:itemCrud:table:newButton" cannot be found. It is only referenced with process="#this".
I'm using primefaces 3.0.RC1-SNAPSHOT and Mojarra 2.1.3_01.
You need to prefix absolute client IDs with the NamingContainer separator which is by default :.
update=":#{cc.clientId}"
See also:
How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"

h:selectOneMenu default value issue when put it in h:dataTable

I have a problem with h:selectOneMenu.
If I put it in h:dataTable I'm unable to set the default value.
This is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:dataTable value="#{utenteBean.listaUtenti}"
var="utente" >
<h:column>
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="1"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{sW.headerUsername}" />
</f:facet>
<h:outputText escape="false"
value="#{utente.username}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{sW.headerEnabled}" />
</f:facet>
<h:form>
<h:commandLink action="#{utenteBean.updateAbilitato}">
<h:outputText value="#{utente.enabled}">
<f:converter converterId="abilitatoConverter"/>
</h:outputText>
<f:setPropertyActionListener target="#{utenteBean.utente}"
value="#{utente}"/>
</h:commandLink>
</h:form>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{sW.headerRuolo}" />
</f:facet>
<h:form>
<h:selectOneMenu value="ROLE_ADMIN"
valueChangeListener="#{utenteBean.updateRuolo}">
<f:selectItem itemLabel="Utente" itemValue="ROLE_USER"/>
<f:selectItem itemLabel="Admin" itemValue="ROLE_ADMIN"/>
</h:selectOneMenu>
</h:form>
</h:panelGroup>
</h:column>
</h:dataTable>
</ui:component>
If I move the h:form with selectOneMenu out of h:dataTable all works.
I'm using jsf2.0 on glassfish3
Any Ideas?
(Solved by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
I have solved it by myself, i think there is a bug in <h:selectOneMenu value="ROLE_ADMIN" i changed the value="" from static to dynamic with a reference to an istance in managed bean and all work perfectly.

Resources