primefaces 3.2 datatable incell editing not working - jsf

I have a datatable with incell editing which displays the records correctly but when I try to edit a row, the change is not reflected. Following is the xhtml code:
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.companyName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{scrip.companyName}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Exchange">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.exchange}"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu style="width: 150px" value="#{manageScrip.exchange}">
<f:selectItem itemLabel="nse" itemValue="nse"/>
<f:selectItem itemLabel="bse" itemValue="bse"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Brokerage Charge">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.brokerageCharge}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{scrip.brokerageCharge}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options">
<p:rowEditor/>
</p:column>
</p:dataTable>
</h:form>
</h:body>
Following is the managed bean function:
public void updateScrip()
{
try{
Integer i=(Integer)dt.getRowKey();
String str=i.toString();
sc=(ScripMaster) dt.getRowData(str);
scripSymbol=sc.getScripSymbol();
exchange=sc.getExchange();
companyName=sc.getCompanyName();
updateScrip(i, scripSymbol, companyName, exchange,);
}catch(Exception ex){
}
}
Alternatively I also tried:
public void updateScrip(RowEditEvent e)
{
try{
sc=(ScripMaster) e.getObject();
scripSymbol=sc.getScripSymbol();
exchange=sc.getExchange();
companyName=sc.getCompanyName();
Integer i=sc.getScripID();
updateScrip(i, scripSymbol, companyName, exchange);
}catch(Exception ex){
}
}
<?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">
<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:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form id="frm">
<p:commandLink action="/adminpages/addScrip" value="add scrip" ajax="false"/>
<p:dataTable editable="true" var="scrip" value="#{manageScrip.scripList}" binding="#{manageScrip.dt}" rowKey="#{scrip.scripID}" id="dt">
<p:ajax event="rowEdit" listener="#{manageScrip.updateScrip}" update="#this"/>
<p:column headerText="Scrip Symbol">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.scripSymbol}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{scrip.scripSymbol}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Company Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.companyName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{scrip.companyName}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Exchange">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.exchange}"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu style="width: 150px" value="#{manageScrip.exchange}">
<f:selectItem itemLabel="nse" itemValue="nse"/>
<f:selectItem itemLabel="bse" itemValue="bse"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Brokerage Charge">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{scrip.brokerageCharge}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{scrip.brokerageCharge}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options">
<p:rowEditor/>
</p:column>
</p:dataTable>
</h:form>
</h:body>

The most important part is missing the datatable tag.
Make sure the "editable" attribute is set to true. This attribute was invented in version 3.2 i think, making many onld datatables not editable.

Try using h:inputText instead of p:inputText.

Related

using <p:dataTable> cellEdit event is never fired in Primefaces

I am having issue in firing an ajax call on the cellEdit event of a Data Table. The table shows up just fine on the UI but nothing happens when I click any of the cell.
xhtml
<h:form>
<p:dataTable id="decisionTree" var="tree"
value="#{treeBean.content}" editable="true" editMode="cell"
styleClass="smallGrid">
<f:facet name="header">
Notes Decision Tree
</f:facet>
<p:ajax event="cellEdit" listener="#{treeBean.onCellEdit}"
immediate="true" update=":#{p:component('notesTextArea')}" />
<p:column headerText="Comment Type">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.commentType}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.commentType}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="MTCNs">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.mtcns}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.mtcns}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Call Type">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.callType}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.callType}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Phone">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.phone}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.phone}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Dispute Reason">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.disputeReason}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.disputeReason}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Placement Decision">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{tree.placementDescision}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{tree.placementDescision}" disabled="true" />
</f:facet>
</p:cellEditor>
</p:column>
<!--
<p:column>
<p:rowEditor />
</p:column>
-->
</p:dataTable>
</h:form>
Here is the Bean.
#Component("treeBean")
#Scope(value = "view", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class TreeBean {
private List<TreeDto> content;
private String result="";
public List<TreeDto> getContent() {
return content;
}
public void setContent(List<TreeDto> content) {
this.content = content;
}
#PostConstruct
public void init() {
content=new ArrayList<TreeDto>();
TreeDto dto1=new TreeDto();
dto1.setCommentType("First Attempt");
dto1.setMtcns("mtcn1");
dto1.setCallType("OBC");
dto1.setPhone("8975730838");
dto1.setDisputeReason("Fraud");
dto1.setPlacementDescision("Write Off");
content.add(dto1);
}
public void onCellEdit(CellEditEvent event) {
RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "Status","something clicked"));
}
}
My intention to capture the value of the cells clicked. But I am not able to get an event fired in the first place on cell edit. Please give me some suggestions on how to resolve this.
Try to add a widgetVar to your dataTable and then edit your cell with a contextMenu for your data table, which call onclick="PF('yourWidgetVar').showCellEditor();return false;"
Somenthing like this
<p:contextMenu for="decisionTree" widgetVar="cMenu">
<p:menuitem value="Edit Cell" icon="ui-icon-search" onclick="PF('yourWidgetVar').showCellEditor();return false;"/>
<p:menuitem value="Hide Menu" icon="ui-icon-close" onclick="PF('cMenu').hide()"/>
</p:contextMenu>
You can take a look to Primefaces documentation too:
https://www.primefaces.org/showcase/ui/data/datatable/edit.xhtml

PrimeFaces editable cell doesn't update the value

So I am trying to use a PrimeFaces data table to set data to a list as follows;
<h:form id="frmSalarySupplement">
<p:panel>
<p:dataTable id="tblSalarySupplement"
value="#{salSupplementMB.dataListFromDB}"
var="salSupp"
rowIndexVar="rowSn"
scrollable="true"
rows="10"
paginator="true"
editable="true"
editMode="cell"
rowsPerPageTemplate="10,20,50,100">
<p:ajax event="cellEdit"
listener="#{salSupplementMB.onCellEdit}"
update="#this" />
<p:column headerText="#" escape="false"
style="white-space:pre-line;
word-break:break-all;
width:20px;
text-align:center;">
<h:outputText value="#{rowSn+1}" />
</p:column>
<p:column headerText="Name"
style="white-space:pre-line;
word-break:break-all;
width:250px;">
<h:outputText value="#{salSupp.empId.name}" />
</p:column>
<p:column headerText="Designation"
style="white-space:pre-line;
word-break:break-all;
width:150px;">
<h:outputText value="#{salSupp.empId.designation.designationName}" />
</p:column>
<p:column headerText="Allowance"
style="white-space:pre-line;
word-break:break-all;
width:100px;">
<p:cellEditor>
<f:facet name="input">
<h:inputText value="#{salSupp.allowance}"
style="width:100%" />
</f:facet>
<f:facet name="output">
<h:outputText value="#{salSupp.allowance}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Special
Allowance"
style="white-space:pre-line;
word-break:break-all;
width:100px;">
<p:cellEditor>
<f:facet name="input">
<h:inputText value="#{salSupp.specialAllowance}"
style="width:100%" />
</f:facet>
<f:facet name="output">
<h:outputText value="#{salSupp.specialAllowance}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Transport
Allowance"
style="white-space:pre-line;
word-break:break-all;
width:100px;">
<p:cellEditor>
<f:facet name="input">
<h:inputText value="#{salSupp.transportAllowance}"
style="width:100%" />
</f:facet>
<f:facet name="output">
<h:outputText value="#{salSupp.transportAllowance}" />
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</p:panel>
</h:form>
So I want to be able to save the data I have edited on the cell to set it on the list. When I do the following, I don't get an updated value.
public void onCellEdit(CellEditEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
}
Can someone suggest what shall I do with it?
Update
Also, can anyone tell me why my table loads multiple times when I edit the value? Maybe that's what's giving me the problem.

Add a blank line in PrimeFaces datatable

I have a problem in datatable when adding a new line:
I want to add a blank line, but if I click on the button it adds a line but component remains.
<p:selectCheckboxMenu> contains old value.
That is to say value of <p:selectCheckboxMenu> preserves the value of the previous line
<p:dataTable value="#{solotionManager.customers}"
id="table" var="o"
widgetVar="50"
style="width: 100%;"
editable="true"
scrollHeight="330"
styleClass="datatable">
<p:ajax event="rowEdit" listener="#{customerBeansController2.onEdit}" update=":form1:table" process="#this"/>
<f:facet name="header">
Order List
</f:facet>
<p:ajax event="rowEditCancel" listener="#{customerBeansController2.onCancel}" update=":form1:messages"/>
<p:column>
<f:facet name="header" >
<h:outputText value="ID customer" style="width:100%"/>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{o.id}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{o.id}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="firstName"/>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{o.firstName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{o.firstName}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="lastName"/>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{o.lastName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{o.lastName}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="SelectManyMenu" style="width:100%"/>
</f:facet>
<p:cellEditor>
<f:facet name="input">
<p:selectCheckboxMenu value="#{solotionManager.choice}" label="Phone" converter="entrantConverter">
<f:selectItems value="#{solotionManager.listeChoice}" var="c" itemValue="#{c}" itemLabel="#{c}"/>
</p:selectCheckboxMenu >
</f:facet>
<f:facet name="output">
<p:selectCheckboxMenu value="#{solotionManager.choice}" label="Phone" converter="entrantConverter">
<f:selectItems value="#{solotionManager.listeChoice}" var="c" itemValue="#{c}" itemLabel="#{c}"/>
</p:selectCheckboxMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options">
<p:rowEditor/>
</p:column>
</p:dataTable>
public String newLine(javax.faces.event.ActionEvent actionEvent) {
this.customers.add(this.custom1);
this.custom1=new Customer();
return null;
}
the code for the button that adds the line:
<p:commandButton value="add row" actionListener="#{solotionManager.newLine}" update="table" oncomplete="addRowOnComplete()"/>
Function javascript addRowOncomplete :
<script type="text/javascript">
function addRowOnComplete() {
jQuery('.ui-datatable-data tr td').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click();});
}
</script>

javax.servlet.ServletException: <p:ajax> Event:rowEdit is not supported

I am getting an error message while trying to use PrimeFaces for my making each row editable. I was checking online many people are making use of this. However when I am trying to create a page with a report in which each row can be edited. I get error that Event:rowEdit is not supported. Can someone please point out my mistake or something I need to include in my XHTML file. Or If i'm doing things right at all.
This table has lot of data that's why I took this approach
Below is the additional information regarding my setup :
Glassfish v3
JPA2.1
PrimeFaces3.5 (i hve the jar included in my project's build path since other report pages are working to confirm primefaces is working)
EJB 3.1
Here is my XHTML code
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:p="http://primefaces.org/ui">
<f:metadata>
<f:viewParam name="userId" value="#{loginBean.username}"></f:viewParam>
</f:metadata>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link href="./css/PageLayout.css" rel="stylesheet" type="text/css" />
<title>Edit Lord of Data Entries</title>
</h:head>
<h:body>
<div style="background-color: #205a8c; width: auto; height: 60px">
<h3>Edit Lord Of Data</h3>
</div>
<div id="breadcrumb" align="left">
<h:form>
<p:breadCrumb>
<p:menuitem value="Home" url="home.jsf"></p:menuitem>
<p:menuitem value="Home" url="home.jsf"></p:menuitem>
<p:menuitem value="Users" url="reportUsers.jsf"></p:menuitem>
<p:menuitem value="Groups" url="reportGroups.jsf"></p:menuitem>
<p:menuitem value="User's Group" url="reportUserGroup.jsf"></p:menuitem>
</p:breadCrumb>
</h:form>
</div>
<h:form id="form">
<p:growl id="messages" showDetail="true"></p:growl>
<p:dataTable var="myReport"
value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
editable="true" paginator="true"
rows="500"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="500,1000,5000">
<f:facet name="header"> Lord Of Data Report</f:facet>
<p:ajax event="rowEdit"
listener="#{lordOfDataAdminManagedBean.onEditListener}"></p:ajax>
<p:ajax event="rowEditCancel"
listener="#{lordOfDataAdminManagedBean.onCancel}"></p:ajax>
<p:column>
<p:rowEditor></p:rowEditor>
</p:column>
<p:column headerText="Row Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.rowId}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.rowId}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Group Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.security}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.security}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Type">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.type}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.type}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Auto">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.auto}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.auto}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Access">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.access}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.access}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comment">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.comment}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.comment}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD1 Domain">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD1Domain}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD1Domain}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD1 User">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD1User}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD1User}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD1 Mail">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD1Mail}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD1Mail}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD1 Display Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD1DisplayName}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD1DisplayName}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD1 Cost Center">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD1CostCenter}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD1CostCenter}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD2 User">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD2User}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD2User}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD2 Mail">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD2Mail}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD2Mail}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD2 Display Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD2DisplayName}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD2DisplayName}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD2 Cost Center">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD2CostCenter}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD2CostCenter}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Domain1">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.domain1}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.domain1}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="RechteGruppe Read">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.rechteGruppeRead}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.rechteGruppeRead}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="AuthentifizierteBenutzer">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.authentifizierteBenutzer}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.authentifizierteBenutzer}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="LOD2 Domain">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.LOD2Domain}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.LOD2Domain}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Email Send Status">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.emailSendStatus}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.emailSendStatus}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Email Feedback">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.emailFeedback}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.emailFeedback}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comment1">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.comment1}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.comment1}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comment2">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.comment2}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.comment2}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comment 3">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.comment3}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.comment3}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Username">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.username}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.username}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
Managed Bean Code snippet for handling Edit function
public void onEditListener(RowEditEvent event) {
FacesMessage msg = new FacesMessage("Edited");
try {
Lodreport mydata = (Lodreport) event.getObject();
if (mydata == null) {
System.out.println("No data input found");
} else {
lODBR.updateReport(mydata);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
} catch (Exception e) {
}
}
public void onCancel(RowEditEvent event) {
FacesMessage msg = new FacesMessage("Cancelled");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
Error Stack Trace
WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.view.facelets.TagException: /editNewLODAdmin.xhtml #44,7 <p:ajax> Event:rowEdit is not supported.
at org.primefaces.component.behavior.ajax.AjaxBehaviorHandler.applyAttachedObject(AjaxBehaviorHandler.java:149)
at org.primefaces.component.behavior.ajax.AjaxBehaviorHandler.apply(AjaxBehaviorHandler.java:127)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:774)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:223)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:453)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
It's not working because
You technically haven't added row editing support to your table, you're editing a cell. Add a <p:rowEditor/> to your table to hook into the rowEdit event
Your table, it's not a real table. The <p:dataTable/> tag doesn't actually wrap the <p:column/> or anything else
What you should have:
<p:dataTable var="myReport" value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist" editable="true">
<f:facet name="header"> Lord Of Data Report</f:facet>
<p:ajax event="rowEdit"
listener="#{lordOfDataAdminManagedBean.onEditListener}"
></p:ajax>
<p:ajax event="rowEditCancel"
listener="#{lordOfDataAdminManagedBean.onCancel}"
></p:ajax>
<p:column headerText="Row Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.rowId}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.rowId}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<p:rowEditor />
</p:column>
</p:dataTable>
I see:
<p:dataTable var="myReport"
value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
editable="true"></p:dataTable>
<f:facet name="header"> Lord Of Data Report</f:facet>
<p:ajax event="rowEdit"
listener="#{lordOfDataAdminManagedBean.onEditListener}"
></p:ajax>
<p:ajax event="rowEditCancel"
listener="#{lordOfDataAdminManagedBean.onCancel}"
></p:ajax>
<p:column headerText="Row Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.rowId}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.rowId}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
you have to try:
<p:dataTable var="myReport"
value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
editable="true">
<f:facet name="header"> Lord Of Data Report</f:facet>
<p:ajax event="rowEdit"
listener="#{lordOfDataAdminManagedBean.onEditListener}"
></p:ajax>
<p:ajax event="rowEditCancel"
listener="#{lordOfDataAdminManagedBean.onCancel}"
></p:ajax>
<p:column headerText="Row Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{myReport.rowId}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{myReport.rowId}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>

Primefaces 3.0 DataTable inCell editing , RowEditEvent doesn't retrieve updated field

I am working on a sample app with primefaces 3 , using datatables incell editing mode. Although when i edit , i see the event.getObjects gives me the object which is not modified.
Changed the property of the object on debug mode, it does update.
So i couldn't figure out why i cant get the edited property.
Below are my eventlistener method and the xhtml;
Any pointers are welcomed
Thanks in advance
EventListener
public void editListener(RowEditEvent event){
System.out.println("EDIT LISTENER");
update((Employer)event.getObject());
}
JSF :
<h:form id="form">
<h1><h:outputText value="List"/></h1>
<p:dataTable value="#{employer.employers}" var="item" paginator="true" rows="10" style="width:300px">
<p:column>
<f:facet name="header">
<h:outputText value="Id"/>
</f:facet>
<h:outputText value="#{item.id}"/>
</p:column>
<p:column headerText="Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.name}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.name}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Surname"/>
</f:facet>
<h:outputText value="#{item.surname}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Phone"/>
</f:facet>
<h:outputText value="#{item.phone}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email"/>
</f:facet>
<h:outputText value="#{item.email}"/>
</p:column>
<p:column headerText="Options" style="width:50px">
<p:rowEditor />
</p:column>
<p:ajax event="rowEdit" listener="#{employer.editListener}"></p:ajax>
</p:dataTable>
</h:form>
After this...
<p:dataTable value="#{employer.employers}" var="item" paginator="true"
rows="10" style="width:300px">
...put the following:
<p:ajax event="rowEdit" update="#this" listener="#{HandlerClassName.rowEditListener}" />

Resources