Exporter doesn't work - jsf

I'm using an old version of PF (3.5) but I can't get DataExporter to work with the attribute selectionOnly="true".
If I don't set that attribute, everything works fine, vice versa I get this error:
Caused by: javax.el.ELException: /WEB-INF/views/AreaRiservata/Clinipass/Malattia/malattiaScaricoMandatiTesoreria.xhtml #91,61 value="#{mandato.codCompagnia}": Cannot convert codCompagnia of type class java.lang.String to class java.lang.Integer
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) ~[jsf-impl-2.1.13.jar:2.1.13]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:186) ~[jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:174) ~[jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at javax.faces.component.UIOutput.getValue(UIOutput.java:169) ~[jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
My datatable looks like this:
<p:ajax event="rowSelectCheckbox" update=":formTable:buttons" />
<p:ajax event="rowUnselectCheckbox" update=":formTable:buttons" />
<p:ajax event="toggleSelect" update=":formTable:buttons" />
<p:ajax event="rowSelect" update=":formTable:buttons" />
<p:ajax event="rowUnselect" update=":formTable:buttons" />
<p:column selectionMode="multiple" style="width:16px;text-align:center"/>
<p:column filterMaxLength="4" filterBy="#{mandato.codCompagnia}" sortBy="#{mandato.codCompagnia}" width="75" id="amala">
<f:facet name="header">
<h:outputText value="Compagnia" />
</f:facet>
<h:outputText value="#{mandato.codCompagnia}" />
</p:column>
<p:column filterBy="#{mandato.codProdotto}" sortBy="#{mandato.codProdotto}" width="75">
<f:facet name="header">
<h:outputText value="Prodotto" />
</f:facet>
<h:outputText value="#{mandato.codProdotto}" />
</p:column>
<p:column filterBy="#{mandato.annoSinistro}" sortBy="#{mandato.annoSinistro}" width="85">
<f:facet name="header">
<h:outputText value="Anno Sinistro" />
</f:facet>
<h:outputText value="#{mandato.annoSinistro}" />
</p:column>
<p:commandButton value="Crea file" ajax="false" icon="ui-icon-document">
<p:dataExporter type="csv" target="tableScaricoMandatiTesoreria" fileName="Mandati" selectionOnly="true" />
</p:commandButton>

you missed postProcessor attribute in dataExporter Component
<p:dataExporter type="csv" target="tableScaricoMandatiTesoreria"
postProcessor="#{ExportCbean.postProcessXLS}" fileName="Mandati" selectionOnly="true" />

It's not an actual fix but i've managed to bypass the issue by creating another datatable with
id="tableScaricoMandatiTesoreriaSelected" style="display: none" value="#{malattiaScaricoMandatiTesoreriaModel.selectedMandati}"
Then I've changed the ajax's updates in the other table:
<p:ajax event="rowSelectCheckbox" update=":formTable:buttons :formTable:tableScaricoMandatiTesoreriaSelected" />
<p:ajax event="rowUnselectCheckbox" update=":formTable:buttons :formTable:tableScaricoMandatiTesoreriaSelected" />
<p:ajax event="toggleSelect" update=":formTable:buttons :formTable:tableScaricoMandatiTesoreriaSelected" />
<p:ajax event="rowSelect" update=":formTable:buttons :formTable:tableScaricoMandatiTesoreriaSelected" />
<p:ajax event="rowUnselect" update=":formTable:buttons :formTable:tableScaricoMandatiTesoreriaSelected" />
And the exporter now points to the new table:
<p:dataExporter type="xls" target="tableScaricoMandatiTesoreriaSelected" fileName="Mandati" />

Related

DataTable isnt editable after i switch the tabs

I'm nesting a datable in tabview. On the first page its all working correctly and i can edit the table, but after i switch the tabs, the datatable isnt editable anymore.
Is there something i'm doing wrong?
Using Primefaces 5.3
<h:form id="form">
<p:tabView id="tabs" value="#{studentsTableView.exams}" activeIndex="#{studentsTableView.activTab}" dynamic="true" var="exam" binding="#{tabView}" cache="false" >
<p:ajax event="tabChange" update="form:tabs" />
<p:tab id="tab" title="#{exam.name}">
<p:dataTable id="students" rowIndexVar="rowIndex" var="student" editable="true" widgetVar="gradetable" editMode="cell" tableStyle="width:auto" styleClass="myTable" value="#{studentsTableView.students}">
<p:ajax event="cellEdit" update="students" />
<p:column headerText="Nr">
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Vorname">
<h:outputText value="#{student.vorname}" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="#{student.nachname}" />
</p:column>
<p:column headerText="Matrikelnummer">
<h:outputText value="#{student.matrikelnummer}" />
</p:column>
<p:columns value="#{exam.allExams}" var="subexam" columnIndexVar="colIndex">
<f:facet name="header">
<h:outputText value="#{subexam.examName}" />
</f:facet>
<p:cellEditor>
<f:facet name="output"><h:outputText id="modeloutput" value="#{studentsTableView.getGrade(subexam, student)}" /></f:facet>
<f:facet name="input"><p:inputText id="modelInput" value="#{studentsTableView.currentGrade}" valueChangeListener="#{studentsTableView.insertGrade(subexam, student)}" style="width:90%">
<p:ajax event="change" update="modelInput" />
<p:ajax event="change" update="modeloutput" />
<p:ajax event="change" update="modeloutput" />
<p:ajax event="change" update=":form:tabs:0:students" />
</p:inputText></f:facet>
</p:cellEditor>
</p:columns>
<p:column id="endgrades" headerText="Endnote">
<h:outputText id="endgrade" value="#{studentsTableView.getEndGrade(exam, student)}" />
</p:column>
<p:column headerText="Formel">
<p:selectBooleanButton id="value1" value="true" onLabel="Yes" offLabel="No" style="width:60px" />
</p:column>
<p:column headerText="Kommentar">
<p:commandButton id="public" icon="ui-icon-comment" type="button" >
<p:ajax event="click" listener="#{studentsTableView.setPublicCommentInfos(exam, student)}" update="publicarea" />
</p:commandButton>
<p:overlayPanel id="imagePanel" for="public" hideEffect="fade">
<h:inputTextarea id="publicarea" value="#{studentsTableView.publicComment}" >
<p:ajax event="change" update="publicarea" />
</h:inputTextarea>
</p:overlayPanel>
<p:commandButton id="private" icon="ui-icon-locked" type="button" >
<p:ajax event="click" listener="#{studentsTableView.setPrivateCommentInfos(exam, student)}" update="privatearea" />
</p:commandButton>
<p:overlayPanel id="privatepanel" for="private" hideEffect="fade">
<h:inputTextarea id="privatearea" value="#{studentsTableView.privateComment}" >
<p:ajax event="change" update="privatearea" />
</h:inputTextarea>
</p:overlayPanel>
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
</h:form>
Your problem could be because you're still referencing the datatable id from the first tab, even though you switched to another. You could try to create a different id for each datatable from each tab and then working with those ids and updating them.

javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or define rowKey attribute

I saw this problem here many times but it doesn't help me.
I have the first dataTable with id:servers and I can do right click over a row and a contextMenu appears. I can click in Show Process and I get a second dataTable with id:processes.
But here is the problem, instead of showing the new dataTable I get,
javax.faces.FacesException: DataModel must implement
org.primefaces.model.SelectableDataModel when selection is enabled or
you need to define rowKey attribute
But I have defined rowKey in both dataTable
I have this code:
<h:form id="form" onkeypress="return event.keyCode != 13">
<!-- <p:messages id="msgs" /> -->
<p:growl id="msgs" showDetail="true" sticky="true" autoUpdate="true" />
<!-- Context menu for servers table. -->
<p:contextMenu for="servers">
<p:menuitem value="Show processes" update="form" icon="ui-icon-search" actionListener="#{homeBean.findLSRunningProcesses}" styleClass="homeIE"/>
</p:contextMenu>
<!-- Context menu for processes table. -->
<p:contextMenu for="processes">
<p:menuitem styleClass="homeIE" update="#form" value="Stop Process" icon="ui-icon-stop" oncomplete="stopDialog.show()"/>
</p:contextMenu>
<!-- Servers table. -->
<p:dataTable id="servers" var="server" value="#{homeBean.serverList}" paginator="true" rows="10"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" widgetVar="serversTable" rowKey="#{server.adminFQDN}"
selection="#{homeBean.selectedLogicalServer}" selectionMode="single" emptyMessage="No servers found with given criteria">
<f:facet name="header">
<h:outputText value="Servers" />
</f:facet>
<p:column filterBy="#{server.ASSETID}" filterMatchMode="contains" sortBy="#{server.ASSETID}" headerText="ASSETID">
<h:outputText value="#{server.ASSETID}" />
</p:column>
<p:column filterBy="#{server.adminFQDN}" filterStyle="width:240px;" filterMatchMode="contains" sortBy="#{server.adminFQDN}" headerText="FQDN">
<h:outputText value="#{server.adminFQDN}" />
</p:column>
<p:column filterBy="#{server.adminIP}" filterMatchMode="contains" sortBy="#{server.adminIP}" headerText="Admin IP">
<h:outputText value="#{server.adminIP}" />
</p:column>
<p:column filterBy="#{server.delivery}" filterMatchMode="exact" sortBy="#{server.delivery}" headerText="Delivery">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="false" />
<f:selectItems label="#{homeBean.deliveries}" value="#{homeBean.deliveries}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.delivery}" />
</p:column>
<p:column filterBy="#{server.environment}" filterMatchMode="exact" sortBy="#{server.environment}" headerText="Environment">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" noSelectionOption="true" itemValue="#{null}"/>
<f:selectItems value="#{homeBean.environments}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.environment}" />
</p:column>
<p:column filterBy="#{server.function}" filterMatchMode="exact" sortBy="#{server.function}" headerText="Function">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{homeBean.functions}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.function}" />
</p:column>
<p:column filterBy="#{server.osVersion}" filterMatchMode="contains" sortBy="#{server.osVersion}" headerText="OS VERSION">
<h:outputText value="#{server.osVersion}" />
</p:column>
<p:column filterBy="#{server.os}" filterMatchMode="contains" sortBy="#{server.os}" headerText="OS">
<h:outputText value="#{server.os}" />
</p:column>
</p:dataTable>
<!-- Panel containing processes tables. -->
<p:panelGrid id="serverProcesses" styleClass="group-user-selection-table" rendered="#{homeBean.showSelectionPanel}">
<f:facet name="header">
<p:row>
<p:column>
<h:outputText value="#{homeBean.selectedLogicalServer.adminFQDN}" />
</p:column>
</p:row>
</f:facet>
<p:row>
<!--Processes table. -->
<p:column>
<p:dataTable id="processes" var="process" value="#{homeBean.processesList}" filteredValue="#{homeBean.filteredProcesses}"
selection="#{homeBean.selectedProcesses}" paginator="true" rows="15" rowKey="#{process.owner}"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="15,20,25,30" selectionMode="single" emptyMessage="No processses found with given criteria">
<f:facet name="header">
<h:outputText value="Processes" />
</f:facet>
<p:column name="owner" filterBy="#{process.owner}" filterMatchMode="contains" sortBy="#{process.owner}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'DESCRIPTION' : 'OWNER'}">
<h:outputText value="#{process.owner}" />
</p:column>
<p:column name="pid" filterBy="#{process.pid}" filterMatchMode="exact" sortBy="#{process.owner}" headerText="PID">
<h:outputText value="#{process.pid}" />
</p:column>
<p:column name="ppid" filterBy="#{process.ppid}" filterMatchMode="exact" sortBy="#{process.ppid}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'TYPE' : 'PPID'}">
<h:outputText value="#{process.ppid}" />
</p:column>
<p:column name="c" filterBy="#{process.c}" filterMatchMode="exact" sortBy="#{process.c}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'STATE' : 'C'}">
<h:outputText value="#{process.c}" />
</p:column>
<p:column name="stime" filterBy="#{process.stime}" filterMatchMode="contains" sortBy="#{process.stime}" headerText="STIME" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.stime}" />
</p:column>
<p:column name="tty" filterBy="#{process.tty}" filterMatchMode="contains" sortBy="#{process.tty}" headerText="TTY" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.tty}" />
</p:column>
<p:column name="time" filterBy="#{process.time}" filterMatchMode="contains" sortBy="#{process.time}" headerText="TIME" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.time}" />
</p:column>
<p:column name="cmd" filterBy="#{process.cmd}" filterMatchMode="contains" sortBy="#{process.cmd}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'NAME' : 'CMD'}">
<h:outputText value="#{process.cmd}" />
</p:column>
</p:dataTable>
</p:column>
</p:row>
</p:panelGrid>
<p:dialog header="Stop Process" widgetVar="stopDialog" minHeight="40" styleClass="dialogPosition">
<h:outputText value="You are going to stop the process "/>
<h:outputText value="#{homeBean.selectedProcesses.cmd}"/>
<h:outputText value="with PID"/>
<h:outputText value="#{homeBean.selectedProcesses.pid}"/>
<br /><br /><br /><br />
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" style="float:left" onclick="stopDialog2.show();stopDialog.hide();" actionListener="#{homeBean.attrListener}">
<f:attribute name="processPID" value="#{process.pid}" />
</p:commandButton>
<p:commandButton value="NO" onclick="stopDialog.hide()" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" style="float:right"/>
</p:dialog>
<p:dialog header="Stop Process" widgetVar="stopDialog2" minHeight="40" styleClass="dialogPosition">
<h:outputText value="You are going to send an email to:"/>
<br />
<h:outputText value="#{homeBean.email}"/>
<br /><br /><br />
<p:commandLink value="Yes" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" style="float:left" update="form" action="#{homeBean.stopProcess}" oncomplete="stopDialog2.hide();"/>
<p:commandButton value="NO" onclick="stopDialog2.hide()" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" style="float:right"/>
</p:dialog>
</h:form>
FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled
this solution works to me.
Especially this answer https://stackoverflow.com/a/10527008/5250930
The table must implement the SelectableDataModel

Update DataTable after cell edit not working in primefaces

I have a datatable includes some cell for edit, and these cells are disabled in specific conditions and after an other cell edition will be enabled.
My problem is after the edit, the new data stored in the database but the datatable not updated directly, it will be updated after reloading the page.
All what I want is how can I make the hole datatable updated after the edit or making the page reloaded
and here is my code:
<h:form id="process">
<p:remoteCommand name="onCellEdit" update=":process:ListC" />
<p:dataTable id="ListC"
value="#{recruitmentProcessMB.candidateListInProcess}"
var="candid" rowKey="#{candid.idCandidate}"
style="border:0px; " paginator="true"
paginatorTemplate="{PreviousPageLink} {NextPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="3,5,10" paginatorPosition="top"
rows="10" editable="true" editMode="cell">
<f:facet name="footer" >
<h:outputLabel value="Valider processus pour le Manager:" style="display: inline-block;"/>
<h:selectOneMenu id="managersInProcess" style="display: inline-block;"
value="#{recruitmentProcessMB.selectedManagerInProcess}">
<f:selectItem itemLabel="Selectionner..." itemValue="#{null}"/>
<f:selectItems value="#{recruitmentProcessMB.managersInProcess}" />
</h:selectOneMenu>
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<p:commandButton icon="ui-icon-seek-next"
value="Valider le processus"
ajax="true"
style="display: inline-block;"
disabled="false"></p:commandButton>
</f:facet>
<p:ajax event="cellEdit"
update=":process:ListC"
immediate="true"
listener="#{recruitmentProcessMB.onCellEdit}"
process="#this"
oncomplete="onCellEdit()"
/>
<p:column headerText="Prenom">
<h:outputText value="#{candid.firstNameCandidate}" />
</p:column>
<p:column headerText="Nom">
<h:outputText value="#{candid.nameCandidate}" />
</p:column>
<p:column headerText="Specialité">
<h:outputText value="#{candid.specialityCandidate}" />
</p:column>
<p:column headerText="Niveau d'etude">
<h:outputText value="#{candid.levelStudyCandidate}" />
</p:column>
<p:column headerText="CV" style="text-align: center ;width:30px;">
<p:commandButton icon="ui-icon-arrowthickstop-1-s"
ajax="false"
actionListener="#{recruitmentProcessMB.downloadAction(candid.cvCandidate,candidate.nameCandidate,candidate.firstNameCandidate)}">
<p:fileDownload
value="#{recruitmentProcessMB.downloadContentProperty}" />
</p:commandButton>
</p:column>
<p:column headerText="Manager" style="position:center;">
<h:outputText
value="#{candid.employee.firstNameEmployee} #{candid.employee.nameEmployee}" />
</p:column>
<p:column headerText="Date d'entretien">
<p:cellEditor id="c1">
<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="dateInterview"
value="#{candid.interviewDateCandidate}"
navigator="true" pattern="dd/MM/yyyy" mask="true" immediate="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Validation Par Manager " >
<p:cellEditor id="c2">
<f:facet name="output" >
<h:outputText
value="#{candid.decisionOfManager}" />
</f:facet>
<f:facet name="input" >
<h:selectOneMenu id="manegerDecision" style="display: inline-block;"
value="#{candid.decisionOfManager}"
disabled="#{candid.currentTask!='InterviewAndValidationByManager'}"
immediate="true">
<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:column headerText="Validation Par RH " >
<p:cellEditor id="c3" >
<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'}"
immediate="true">
<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>
</h:form>

Dynamically generated panelGroup can't be located

I have the following structure in my application:
<h:outputLabel value="Regiões :" />
<p:autoComplete multiple="true" value="#{investimento.regioesSelecionadas}"
completeMethod="#{investimento.completaRegiao}"
var="reg" itemLabel="#{reg.label}" itemValue="#{reg}"
converter="entityConverter" forceSelection="true">
<p:column>
<h:outputText value="#{reg.label}" />
</p:column>
<p:ajax event="itemSelect" update="regiaoCol" />
<p:ajax event="itemUnselect" update="regiaoCol" />
<p:ajax event="itemUnselect" listener="#{investimento.tiraUmaRegiao}"/>
</p:autoComplete>
<h:outputText />
<h:panelGroup id="regiaoCol">
<c:forEach items="#{investimento.regioesSelecionadas}" var="regSel" rendered="#{!investimento.regioesSelecionadas.isEmpty()}">
<h:panelGrid columns="2">
<h:outputLabel value="Região #{regSel.label} - Estados:" />
<p:autoComplete multiple="true" value="#{investimento.estadosSelecionados}"
var="est" itemLabel="#{est.label}" itemValue="#{est}"
completeMethod="#{investimento.completaEstado}"
converter="entityConverter" forceSelection="true" cash="true">
<f:attribute name="regPar" value="#{regSel}" />
<p:column>
<h:outputText value="#{est.label}" />
</p:column>
<p:ajax event="itemSelect" update="#{investimento.idComposta(est, regSel)}" />
<p:ajax event="itemUnselect" update="regiaoCol" />
<p:ajax event="itemUnselect" update="#{investimento.idComposta(est, regSel)}"/>
<p:ajax event="itemUnselect" update="#{investimento.idComposta(est, regSel)}" listener="#{investimento.tiraUmEstado}"/>
</p:autoComplete>
<h:outputLabel />
<h:panelGroup id="#{investimento.idComposta(est, regSel)}">
<c:forEach items="#{investimento.estadosSelecionados}" var="estSel">
<h:panelGrid columns="2">
<h:outputLabel value="Estado #{estSel.label} - Municipios: #{investimento.idComposta(est, regSel)}" />
<p:autoComplete multiple="true" value="#{investimento.municipiosSelecionados}"
var="mun" itemLabel="#{mun.label}" itemValue="#{mun}"
completeMethod="#{investimento.completaMunicipio}" maxResults="8"
converter="entityConverter" forceSelection="true" cash="true">
<f:attribute name="estPar" value="#{estSel}" />
<p:column>
<h:outputText value="#{mun.label}" />
</p:column>
</p:autoComplete>
</h:panelGrid>
</c:forEach>
</h:panelGroup>
</h:panelGrid>
</c:forEach>
</h:panelGroup>
So, whenever I pick a "Região" will apear in "regiaoCol" new options for the user to select. However there's an issue: when I remove a "Região", add it again and try to remove it once more, it causes the following error:
> Grave: Error Rendering View[/InsI.xhtml]
javax.faces.FacesException: Cannot find component with expression "munEst2Reg3" referenced from "form:j_idt190".
at org.primefaces.expression.SearchExpressionFacade.resolveComponentInternal(SearchExpressionFacade.java:422)
at org.primefaces.expression.SearchExpressionFacade.resolveComponentForClient(SearchExpressionFacade.java:200)
at org.primefaces.expression.SearchExpressionFacade.resolveComponentsForClient(SearchExpressionFacade.java:147)
at org.primefaces.util.AjaxRequestBuilder.addExpressions(AjaxRequestBuilder.java:92)
at org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:85)
at org.primefaces.behavior.ajax.AjaxBehaviorRenderer.getScript(AjaxBehaviorRenderer.java:80)
at javax.faces.component.behavior.ClientBehaviorBase.getScript(ClientBehaviorBase.java:103)
at org.primefaces.renderkit.CoreRenderer.encodeClientBehaviors(CoreRenderer.java:458)
Which, I presume, is caused by the browser looking for that reference, in this case "munEst2Reg3" and it not being there. However: why it throws the error? How is it different from removing the "Região" the first time? How to I solve the issue? Should I submit the page after each unselection? (which wouldn't be the most user friendly option)
Tiny's response put me on the right track and, after some debuging I found somethings:
As all the instances are altering the same list is paramount that all of them have a event or one will delete the inputs of the other;
You have also to take care on how the dataTable behaves and guarantee that he only gets the values that you are interested in;
How my code ended up being:
<h:outputLabel value="Regiões :" />
<p:autoComplete multiple="true" value="#{investimento.regioesSelecionadas}"
completeMethod="#{investimento.completaRegiao}"
var="reg" itemLabel="#{reg.label}" itemValue="#{reg}"
converter="entityConverter" forceSelection="true">
<p:column>
<h:outputText value="#{reg.label}" />
</p:column>
<p:ajax event="itemSelect" update="regiaoCol" />
<p:ajax event="itemUnselect" update="regiaoCol" listener="#{investimento.tiraUmaRegiao}"/>
</p:autoComplete>
<h:outputText />
<h:panelGroup id="regiaoCol">
<p:dataTable value="#{investimento.regioesSelecionadas}" var="regSel" rendered="#{investimento.regioesSelecionadas.isEmpty() == false}">
<p:column>
<h:outputLabel value="Região #{regSel.label} - Estados:" />
</p:column>
<p:column>
<p:autoComplete multiple="true" value="#{investimento.estadosSelecionados}"
var="est" itemLabel="#{est.label}" itemValue="#{est}"
completeMethod="#{investimento.completaEstado}"
converter="entityConverter" forceSelection="true">
<f:attribute name="regPar" value="#{regSel}" />
<p:column>
<h:outputText value="#{est.label}" />
</p:column>
<p:ajax event="itemSelect" update="#{investimento.idComposta()}" >
<f:attribute name="regiaoPar" value="#{regSel}" />
</p:ajax>
<p:ajax event="itemUnselect" update="#{investimento.idComposta()}" listener="#{investimento.tiraUmEstado}">
<f:attribute name="regiaoPar" value="#{regSel}" />
</p:ajax>
</p:autoComplete>
</p:column>
<p:column>
<h:panelGroup id="#{investimento.idComposta()}">
<f:attribute name="regiaoPar" value="#{regSel}" />
<p:dataTable value="#{investimento.meusEstSel()}" var="estSel" rendered="#{investimento.meusEstSel().isEmpty() == false}">
<f:attribute name="regiaoPar" value="#{regSel}" />
<p:column>
<h:outputLabel value="Estado #{estSel.label} - Municipios:" />
</p:column>
<p:column>
<p:autoComplete multiple="true" value="#{investimento.municipiosSelecionados}"
var="mun" itemLabel="#{mun.label}" itemValue="#{mun}"
completeMethod="#{investimento.completaMunicipio}" maxResults="8"
converter="entityConverter" forceSelection="true">
<f:attribute name="estPar" value="#{estSel}" />
<p:column>
<h:outputText value="#{mun.label}" />
</p:column>
<p:ajax event="itemSelect" />
<p:ajax event="itemUnselect" />
</p:autoComplete>
</p:column>
</p:dataTable>
</h:panelGroup>
</p:column>
</p:dataTable>
</h:panelGroup>

Accessing invisible tabs in primefaces

I tried to update a Gmap which placed in a tabView. But i am getting the
java.lang.IllegalArgumentException: tab2
error. I have searched this problem a little and noticed that it is available only if tab is visible. So what can I do ? The code block is below:
<h:form id="form">
<p:tabView orientation="left" id="tabView" styleClass="tabView">
<p:ajax event="tabChange" listener="#{sucBean.onTabChange}"
update=":form:tabView:map" />
<p:tab title="Bütün Suçlar" id="tab1">
<p:gmap zoom="10" type="HYBRID" center="40.78470,29.94873" id="map"
model="#{sucBean.advancedModel}"
style="width:740px;height:500px;margin:-14px 0 0 -10px;">
<p:ajax event="overlaySelect" listener="#{sucBean.onMarkerSelect}" />
<p:gmapInfoWindow>
<p:outputPanel
style="text-align:justify;display:block;margin:auto:">
<p:panelGrid columns="2" cellpadding="8">
<h:outputText value="Suç Tipi:" style="color:red" />
<h:outputText value="#{sucBean.marker.data.sucTipi}" />
<h:outputText value="Tarih: " style="color:red" />
<h:outputText value="#{sucBean.marker.data.islenmeZamani}" />
<h:outputText value="Adres: " style="color:red" />
<h:outputText value="#{sucBean.marker.data.adres}" />
<h:outputText value="Suçu İşleyen:" style="color:red" />
<h:outputText value="#{sucBean.marker.data.isleyenBilgisi}" />
</p:panelGrid>
</p:outputPanel>
</p:gmapInfoWindow>
</p:gmap>
</p:tab>
<p:tab title="Suç Ara" id="tab2">
<p:fieldset legend="Ayrıntılı Arama" styleClass="searchField"
id="fieldSet">
<p:panelGrid columns="4" cellpadding="10">
<p:inputText value="#{sucBean.arananKelime}" style="width:300px" />
<h:outputText value=" Kriter:" />
<p:selectOneMenu value="#{sucBean.aramaKriteri}">
<f:selectItem itemLabel="Suç Tipi" itemValue="sucTipi" />
<f:selectItem itemLabel="Adres" itemValue="adres" />
<f:selectItem itemLabel="İşlenme Zamanı" itemValue="zaman" />
<f:selectItem itemLabel="Cinsiyet" itemValue="cinsiyet" />
<f:selectItem itemLabel="Yaş" itemValue="yas" />
</p:selectOneMenu>
<p:commandButton value="Ara"
actionListener="#{sucBean.sucKaydiAra}" update="aramaSonucu" />
</p:panelGrid>
</p:fieldset>
<p:dataTable var="suc" value="#{sucBean.sucModel}" paginator="true"
rows="10" id="aramaSonucu" selection="#{sucBean.selectedSuc}">
<p:column selectionMode="multiple" style="width:18px"></p:column>
<p:column headerText="Suç Tipi">
<h:outputText value="#{suc.sucTipi}" />
</p:column>
<p:column headerText="İşlenme Zamanı">
<h:outputText value="#{suc.islenmeZamani}" />
</p:column>
<p:column headerText="Adres">
<h:outputText value="#{suc.adres}" />
</p:column>
<p:column headerText="Suçu İşleyen">
<h:outputText value="#{suc.isleyenBilgisi}" />
</p:column>
<!-- <f:facet name="footer"> -->
<!-- </f:facet> -->
</p:dataTable>
<p:commandButton id="multiSelectButton" actionListener="#{sucBean.secilenleriGetir}" update=":form:tabView:tab2:map2"
value="Secilenleri Haritada Göster" icon="ui-icon-pin-s" />
<p:gmap zoom="12" type="HYBRID" center="40.78470,29.94873"
id="map2" model="#{sucBean.advancedModel2}"
style="width:740px;height:300px;margin:10px 0 0 -10px;">
When you reference a component inside container components like tabView or accordion, you don't need to include the actual tab id in your update target.
In your case update=":form:tabView:map2" would be the correct update target.

Resources