I am trying to have both context menu as well as filter in my page but after I filter and reload the page I get this exception
DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.
<p:dataTable
id="wtmInbox"
rendered="#{flowDashboardManagedBean.renderOnLoadForWtm}"
value="#{flowDashboardManagedBean.worktimematrixList}"
var="wtms"
stickyHeader="false"
tableStyleClass="IEListTable"
widgetVar="wtmInboxWidVar"
scrollable="true"
scrollHeight="700"
editable="true" rowKey="#{wtms.worktimematrix.workTimeMatrixId}" selection="#{flowDashboardManagedBean.selectedWorktimematrix}" selectionMode="single">
<p:ajax event="rowEdit" listener="#{flowDashboardManagedBean.onRowEdit}" update="wtmInbox"/>
<p:ajax event="contextMenu" listener="#{flowDashboardManagedBean.onRowSelect}" ></p:ajax>
filter :
<p:column headerText="#{bundle.status}"
sortBy="#{wtms.worktimematrix.workTimeMatrixStatus.name}"
filterBy="#{wtms.worktimematrix.workTimeMatrixStatus.name}"
filterMatchMode="exact"
style="text-align:right;"
priority="1"
width="10%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{wtms.worktimematrix.workTimeMatrixStatus}" converter="workTimeMatrixStatusConverter"></h:outputText>
</f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{wtms.worktimematrix.workTimeMatrixStatus}" converter="workTimeMatrixStatusConverter">
<f:selectItem itemLabel="#{bundle.select}" itemValue="#{null}"/>
<f:selectItems value="#{flowDashboardManagedBean.workTimeMatrixStatuses}" var="worktimematrixStatus" itemValue="#{worktimematrixStatus}" itemLabel="#{worktimematrixStatus.name}"></f:selectItems>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
<f:facet name="filter">
<p:selectOneMenu onchange="PF('wtmInboxWidVar').filter()" id="flowModelTypeFilter">
<f:selectItem itemLabel="#{bundle.status}" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{flowDashboardManagedBean.workTimeMatrixStatusNames}" var="status" itemValue="#{status}"/>
</p:selectOneMenu>
</f:facet>
</p:column>
Found out the Problem, The entity behind the table did not implement serializable. After I added that filters worked then when I added in the context menu it also worked.
Related
Iam trying to display a list of currencies from a database through a drop down list , every currency has a logo
<p:selectOneMenu value="#{currencyController.currency}"
converter="#{currencyConverter}"
var="c" style="width:180px">
<f:selectItems value="#{currencyController.currencyList}"
var="currency"
itemLabel="#{currency.currencyName}"
itemValue="#{currency}"/>
<p:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{c.name}"/>
</p:column>
<p:column style="width:10%">
<p:graphicImage value="#{c.image}"
cache="false"
style="height:3em;width:3em"/>
</p:column>
</p:selectOneMenu>
The name is displayed fine but the problem is that the logo is not getting displayed at all
I am using PrimeFaces editable p:dataTable
But When I select from selectCheckboxMenu I not call method event change not trigerred
<p:column headerText="Allowed Sec Action" style="width:250px">
<p:cellEditor>
<f:facet name="input">
<p:selectCheckboxMenu multiple="true" value="#{validation.detail.allowedSecAction}"
collectionType="java.util.ArrayList" >
<f:selectItems var="item" itemValue="#{item}"
itemLabel="#{item}"
value="#{emdValidationView.allowedSecActionList}" />
</p:selectCheckboxMenu>
</f:facet>
<f:facet name="output">
<p:selectCheckboxMenu multiple="true" value="#{validation.detail.allowedSecAction}"
collectionType="java.util.ArrayList">
<p:ajax event="change" update="#form"
listener="#{emdValidationView.handleChange()}" />
<f:selectItems var="item" itemValue="#{item}"
itemLabel="#{item}"
value="#{emdValidationView.allowedSecActionList}" />
</p:selectCheckboxMenu>
</f:facet>
</p:cellEditor>
</p:column>
I have a requirement for an editable datatable that has a single column, lets say brand, that when set to "Other" will replace the editor in the next column, model - with an inputText rather than a selectOne. If any particular car brand is selected then the list of models for that brand is displayed. If "Other" is chosen then they can type in a model in an input text field. I can't seem to get the mechanics of this to work in primefaces using various combinations of rendered and events. Is this sort of inline switching of editing components based on the data in the row possible? I've built a simple example using the primefaces datatable demo for cars (and adding a field Model) to illustrate what I am attempting.
Page snippet
<p:dataTable id="cars1" var="car" value="#{dtEditView.cars1}"
editable="true" style="margin-bottom:20px">
<f:facet name="header">
Row Editing
</f:facet>
<p:ajax event="rowEdit" listener="#{dtEditView.onRowEdit}"
update="cars1" />
<p:ajax event="rowEditCancel" listener="#{dtEditView.onRowCancel}"
update="cars1" />
<p:column headerText="Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.id}" />
</f:facet>
<f:facet name="input">
<p:inputText id="modelInput" value="#{car.id}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Year">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.year}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.year}" style="width:100%" label="Year" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Brand">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.brand}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{car.brand}" style="width:100%">
<f:selectItems value="#{dtEditView.brands}" var="man"
itemLabel="#{man}" itemValue="#{man}" />
<p:ajax event="change" immediate="true" update="model model_ti"></p:ajax>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Model">
<p:cellEditor rendered="#{car.brand != 'Other'}">
<f:facet name="output">
<h:outputText value="#{car.model}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{car.model}" style="width:100%"
id="model">
<f:selectItems value="#{dtEditView.getModels(car.brand)}"
var="man" itemLabel="#{man}" itemValue="#{man}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
<p:cellEditor rendered="#{car.brand == 'Other'}">
<f:facet name="output">
<h:outputText value="#{car.model}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{car.model}" style="width:100%"
id="model_ti" />
</f:facet>
</p:cellEditor>
</p:column>
Thanks!
I was able to solve this problem by putting an ID on the cell editor for model, and adding that to the update list when changing brand.
I have implemented primefaces roweditor for components like inputtext,autocomplete . I am trying to implement for selectmanymenu but could not get the result. If i use cell editor then i need to use input and output value should refer the same . Here selectmanymenu value would be the list not a single variable. So i am not sure how to handle it.
I would like know the proper implementation of p:selectManyMenu with p:cellEditor. I am not sure that we have option to do this also.
I have searched in stackoverflow as well as in google, did not get any answers for this.
Please help me out.
Below is the code details
<p:dataTable
value="#{projectViewBean.projectListToEdit}"
editable="true" var="proj" id="editProjLst">
<p:ajax event="rowEdit" listener="#{projectEntryBean.onEdit}"/>
<p:ajax event="rowEditInit" listener="#{projectEntryBean.onRowEditInit}"></p:ajax>
<p:column headerText="Project Status" id="sts">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{proj.projectStatus}"></p:outputLabel>
</f:facet>
<f:facet name="input">
<p:selectOneMenu
value="#{proj.projectStatus}"
id="pjstval">
<f:selectItems value="#{projectEntryBean.projectStatusList}"
id="pjstlst" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Phase" id="dbphase">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{proj.projectPhaseValue}"></p:outputLabel>
</f:facet>
<f:facet name="input">
<p:autoComplete
completeMethod="#{projectEntryBean.autoSearchProjectPhase}"
value="#{proj.projectPhaseValue}"
dropdown="true" scrollHeight="200" emptyMessage="No Phase Found"
minQueryLength="1" forceSelection="true"></p:autoComplete>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Project Manager" id="pjtmgr">
<p:cellEditor id="pm">
<f:facet name="output">
<p:outputLabel value="#{projectEntryBean.pjtView.projectUserList}"></p:outputLabel>
</f:facet>
<f:facet name="input">
<p:selectManyMenu
value="#{proj.projectManager}"
id="projectmanagerval">
<f:selectItems value="#{projectEntryBean.pjtView.projectUserList}"
id="pmlst" />
</p:selectManyMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
Finally i am able to achieve it by using converter. It might be helpful for someone. Please see the solution
<p:column headerText="Project Manager" id="pjtmgr">
<p:cellEditor id="pm">
<f:facet name="output">
<p:outputLabel value="#{proj.projectManager}">
<f:converter converterId="vendorConverter"></f:converter>
</p:outputLabel>
</f:facet>
<f:facet name="input">
<p:selectManyMenu
value="#{proj.projectManager}"
id="projectmanagerval">
<f:selectItems value="#{projectEntryBean.pjtView.projectUserList}"
id="pmlst" />
</p:selectManyMenu>
</f:facet>
</p:cellEditor>
</p:column>
I am trying to make an Editable DataTable by cell in Primefaces, but after an edit of a cell, the event not submitted and my code can't detect the newValue, and there is no error or log in the stack trace
here is my code:
xhtml:
<p:dataTable id="ListC"
value="#{recruitmentProcessMB.candidateListInProcess}"
var="candid" rowKey="#{candid.idCandidate}"
style="border:0px; " editable="true" editMode="cell">
<p:ajax event="cellEdit"
update="ListC"
listener="#{recruitmentProcessMB.onCellEdit}"
/>
<p:column headerText="Date d'entretien">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{candid.interviewDateCandidate}">
<f:convertDateTime type="date" dateStyle="short"
pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar id="date"
value="#{candid.interviewDateCandidate}"
navigator="true" pattern="dd/MM/yyyy" mask="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column id="vRH" headerText="Validation Par RH " disabledSelection="#{candid.currentTask!='InterviewAndValidationByRH'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText
value="#{candid.decisionOfRh}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu id="rhDecision" style="display: inline-block;"
value="#{candid.decisionOfRh}"
disabled="#{candid.currentTask!='InterviewAndValidationByRH'}" >
<f:selectItem itemLabel="Selectionner..." />
<f:selectItem itemLabel="Accepté" itemValue="Accepté"/>
<f:selectItem itemLabel="Refusé" itemValue="Refusé"/>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
Bean:
public void onCellEdit(CellEditEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
Candidate c = context.getApplication().evaluateExpressionGet(
context, "#{candid}", Candidate.class);
System.out.println("+++++++++++ "+c.getFirstNameCandidate()+" "+c.getNameCandidate());
System.out.println("*********** "+event.getNewValue().toString());
logger.info(c.getInterviewDateCandidate().toString());
}
try to add the attribute immediate="true" in the in the tag p:ajax and my bean method was called
<p:ajax event="cellEdit"
update="ListC"
immediate="true"
listener="#{recruitmentProcessMB.onCellEdit}"
process="#this"
/>