java.lang.NullPointerException at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter - sorting

I have in my JSF 2 app on JBoss AS 7.1 a PrimeFaces 5.1 datatable with lazy loading and it sorts on page load, so I know my sorting implementation works, but when I click the column to sort it throws the below exception.
17:48:34,855 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/feenix].[Faces Servlet]] (http-/0:0:0:0:0:0:0:0:8080-6) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception:
java.lang.NullPointerException
at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:469) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:76) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:603) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:152) [primefaces-5.1.jar:5.1]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:201) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:126) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
My data table:
<p:dataTable var="registroD" value="#{reportes.diario}" paginator="true" rows="10" rowsPerPageTemplate="10,20,40,80" id="registroDiarioTable" lazy="true"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">
<p:column headerText="Fecha">
<h:outputText value="#{registroD.fechaRegistro}">
<f:convertDateTime pattern="yyyy/MM/dd" type="date"/>
</h:outputText>
</p:column>
<p:column headerText="Nombre Asesor" sortBy="#{registroD.idTrabajo.idUsuario.nombres}" filterBy="#{registroD.idTrabajo.idUsuario.nombres}">
<h:outputText value="#{registroD.idTrabajo.idUsuario.nombres}"/>
</p:column>
<p:column headerText="Apellido Asesor" sortBy="#{registroD.idTrabajo.idUsuario.apellidos}" filterBy="#{registroD.idTrabajo.idUsuario.apellidos}">
<h:outputText value="#{registroD.idTrabajo.idUsuario.apellidos}"/>
</p:column>
<p:column headerText="Lugar entrega" sortBy="#{registroD.idTrabajo.idUbicacion.direccion}" filterBy="#{registroD.idTrabajo.idUbicacion.direccion}">
<h:outputText value="#{registroD.idTrabajo.idUbicacion.direccion}"/>
</p:column>
<p:column headerText="Hora entrega">
<h:outputText value="#{registroD.fechaRegistro}">
<f:convertDateTime pattern="HH:mm:ss" type="time"/>
</h:outputText>
</p:column>
<p:column headerText="Nombre" sortBy="#{registroD.numero.nombres}" filterBy="#{registroD.numero.nombres}">
<h:outputText value="#{registroD.numero.nombres}"/>
</p:column>
<p:column headerText="Apellido" sortBy="#{registroD.numero.apellidos}" filterBy="#{registroD.numero.apellidos}">
<h:outputText value="#{registroD.numero.nombres}"/>
</p:column>
<p:column headerText="Numero Celular" sortBy="#{registroD.numero.numero}" filterBy="#{registroD.numero.numero}">
<h:outputText value="#{registroD.numero.numero}" />
</p:column>
<p:column headerText="Producto" sortBy="#{registroD.producto}" filterBy="#{registroD.producto}">
<h:outputText value="#{registroD.producto}"/>
</p:column>
</p:dataTable>
This error has nothing to do (seems to me that way) with the actions I do.
What is going on?

The stack trace tells that this exception occurred while handling an exception during restore view phase of an ajax request. This is a second problem which has unfortunately hidden away all detail about the underlying exception which JSF was trying to handle, so this question can't be answered by just looking at the stack trace until you fix/replace the standard exception handler.
If upgrading to latest Mojarra version doesn't solve it, then you can (temporarily) use the one shown in this answer to print the stack trace of the real underlying exception: Exception handling in JSF ajax requests. That should in turn give sufficient clues about the real underlying problem.

Related

p:datatable displayed wrongly after ajax update

I have problem with a primefaces datable, I have a filter on a column and before to filter the result my datatable is displayed properly like this:
When I choose a filter, the combobox of the filter is properly poulated:
A soon I choose the item for the filter, the results are properly filtered but I have a display of the datatable like this:
I just see the results who should be display in a datatable but the table is gone.
The code seems good and I don't see where is the problem:
<p:outputPanel autoUpdate="true" class="ui-g-12">
<div class="card">
<h1>Gestion des noeuds</h1>
<h:form>
<p:dataTable value="#{nodeController.nodes}"
var="node"
tableStyle="table-layout: auto;"
rowKey="#{node.nodeId}"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="false"
rows="15"
widgetVar="nodeTable"
filteredValue="#{nodeController.filterNodes}"
editable="true"
selection="#{nodeController.selectedNode}"
selectionMode="single"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column headerText="ID">
<h:outputText value="#{node.nodeId}"/>
</p:column>
<p:column headerText="Nom">
<h:outputText value="#{node.modeName}"/>
</p:column>
<p:column headerText="Description">
<h:outputText value="#{node.nodeDescription}"/>
</p:column>
<p:column filterBy="#{node.typeNodeId}" filterMatchMode="exact" headerText="Type">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('nodeTable').filter()">
<f:selectItem itemLabel="filtre" itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="#{nodeController.nodeTypes}"/>
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{node.typeNodeId}"/>
</p:column>
<p:column headerText="IPv4">
<h:outputText value="#{node.ipv4}"/>
</p:column>
<p:column headerText="IPv6">
<h:outputText value="#{node.ipv6}"/>
</p:column>
<p:column headerText="powwo agent">
<h:selectBooleanCheckbox value="#{node.agentInstalled}"/>
</p:column>
<p:column headerText="Network status" style="text-align:center">
<p:graphicImage rendered="#{node.isconnected}" name="images/ConnectionStatus25.png" library="omega-layout" width="20"/>
<p:graphicImage rendered="#{!node.isconnected}" name="images/Siren-25.png" library="omega-layout" width="20"/>
</p:column>
<p:column>
<p:rowEditor/>
</p:column>
</p:dataTable>
<p:commandButton value="effacer"
update="msg"
actionListener="#{nodeController.deleteSelectedNode()}"
style="width:auto;margin-bottom:10px;margin-top: 10px"/>
</h:form>
</div>
</p:outputPanel>
Did you already meet this issue with the rendered of a datable? Any idea how to fix it?
Effectively, your title and first sentence are not correct. It is not a bug in the datatable but a 'bug' in your code. You should not use autoupdate="true" on the p:outputPanel in this case. It updates all its content on each ajax update that happens inside it, including an ajax update during filtering. This latter also updates the datatable which means two conflicting updates. Off-topic: If you'd created a Minimal, Complete, and Verifiable example , you'd have found this out during removal of code.
If you have this problem when you have an ajax listener on one of the filter/page/sort/... events on the datatable and you need the autoUpdate="true" on the panel for other events in the wrapping panel, you could also prevent the autoUpdate to happen for these specific events by adding a ignoreAutoUpdate="true" to the specific events. So e.g.
<p:ajax event="filter" ignoreAutoUpdate="true" ... />

p:dataTable sortBy not working

<p:dataTable value="#{externalUsersBean.usersList}" var="user" paginator="true" rows="25">
<p:column headerText="UID" sortBy="#{user.uid}">
<h:outputText value="#{user.uid}"/>
</p:column>
<p:column headerText="Username" sortBy="#{user.username}">
<h:outputText value="#{user.username}"/>
</p:column>
...
...
</p:dataTable>
I tried changing scope in the bean to ViewScoped, yet not working.
I tried using sortBy="uid" syntax, yet not working.
I can't understand what I'm doing wrong.

Primefaces: multiple datatables on page - sorting

I'm using Primefaces 5.2.
On my page, I have several p:datatables with the same columns and the same sortBy expression.
Something like:
<p:dataTable .. id="tab1">
<p:column sortBy="#{prop1}">
#{prop1}
</p:column>
</p:dataTable>
<p:dataTable .. id="tab2">
<p:column sortBy="#{prop1}">
#{prop1}
</p:column>
</p:dataTable>
Sorting works fine so far, but I get strange behaviour and finally a NullPointerException if I sort one of the tables (let's call it table A) and then refresh the page (e.g. by firing a h:commandButton). In this case ALL tables have the same column highlighted as table A. Also, as soon as I sort a table other than table A afterwards, the following exception occurs:
21:33:36,149 SEVERE javax.enterprise.resource.webcontainer.jsf.application (default task-25) Error Rendering View[/stocks.xhtml]: java.lang.NullPointerException
at org.primefaces.component.datatable.DataTable.findColumnInGroup(DataTable.java:905) [primefaces-5.2.jar:5.2]
at org.primefaces.component.datatable.DataTable.findColumn(DataTable.java:896) [primefaces-5.2.jar:5.2]
at org.primefaces.component.datatable.DataTable.getSortColumn(DataTable.java:1401) [primefaces-5.2.jar:5.2]
at org.primefaces.component.datatable.feature.SortFeature.singleSort(SortFeature.java:136) [primefaces-5.2.jar:5.2]
at org.primefaces.component.datatable.DataTableRenderer.preRender(DataTableRenderer.java:109) [primefaces-5.2.jar:5.2]
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:83) [primefaces-5.2.jar:5.2]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104) [jsf-impl-2.2.8-jbossorg-1.jar:]
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:621) [jsf-impl-2.2.8-jbossorg-1.jar:]
at com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:1110) [jsf-impl-2.2.8-jbossorg-1.jar:]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456) [jsf-impl-2.2.8-jbossorg-1.jar:
The solution is to add rowStatePreserved="true" to the table containing the other tables. This was added in Primefaces 5.1.14 and is part of JSF 2.1.
Credits for: sdjavaudvk (http://forum.primefaces.org/viewtopic.php?f=3&t=43441).
<p:dataTable id="tab1" var="resumo" value="#{resumoView.resumos}" rows="20"
paginator="true"
rowsPerPageTemplate="5,10,15,20"
rowStatePreserved="true">
...
Have you tried using a different form for each datatable? Like this:
<h:form>
<p:dataTable id="tab1"> ... </p:dataTable>
</h:form>
<h:form>
<p:dataTable id="tab2"> ... </p:dataTable>
</h:form>
We encountered the same problem on Primefaces6.0.
We had a form containing two tables, and a specific column can be either filtered via a list of values (filterMatchMode exact) or via an input text (filterMatchMode contains).
The first table didn't have a working filter (we encountered the same NullPointerException as you did), and the second was working fine.
The two tables were in a component, and the column filtered and sorted in the two tables was built conditionnaly with the JSTL like this :
<c:choose>
<c:when test="#{cc.attrs.filterOperatorExact}">
<p:column headerText="Header name"
sortBy="#{vector.operatorForDisplay}"
filterBy="#{vector.operatorForDisplay}" filterMatchMode="exact"
filterOptions="#{cc.attrs.filtersOperatorList}">
<h:outputText value="#{vector.operatorForDisplay}" />
</p:column>
</c:when>
<c:otherwise>
<p:column headerText="Header name"
sortBy="#{vector.operatorForDisplay}"
filterBy="#{vector.operatorForDisplay}" filterMatchMode="contains">
<h:outputText value="#{vector.operatorForDisplay}" />
</p:column>
</c:otherwise>
</c:choose>
Using the "JSF way" to do this with the rendered attribute, the problem disappeared :
<p:column headerText="Header name"
sortBy="#{vector.operatorForDisplay}"
filterBy="#{vector.operatorForDisplay}" filterMatchMode="exact"
filterOptions="#{cc.attrs.filtersOperatorList}"
rendered="#{cc.attrs.filterOperatorExact}">
<h:outputText value="#{vector.operatorForDisplay}"/>
</p:column>
<p:column headerText="Header name"
sortBy="#{vector.operatorForDisplay}"
filterBy="#{vector.operatorForDisplay}" filterMatchMode="contains"
rendered="#{not cc.attrs.filterOperatorExact}">
<h:outputText value="#{vector.operatorForDisplay}"/>
</p:column>
Hope it helps.

Primefaces Complex Datatable Filtering and Sorting

I am using a complex datatable that can sort and filter with various filter. my problem is as I try to use column filter, global filter or sorting datatable pagination suddenly drops to 1 page and it doesn't turn back to first state with pagination. At the beginning I have 92 pages but after filtering/sorting it becomes a datatable with 1 page, even though I clear the textbox of filter it stays as 1 page.
Here is my datatable:
<h:panelGroup rendered="#{projectsController.items.rowCount > 0}">
<p:growl id="growl" />
<p:dataTable id="datatable" value="#{projectsController.items}" var="item" filterEvent="keyup"
paginator="true" rows="5" emptyMessage="Proje bulunamadı." paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="4,5,6,7,8,9,10"
filteredValue="#{projectsController.filteredProjects}" style="font-size:11px;font-weight: bold;" widgetVar="proj" >
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Tüm Alanlarda Ara: " />
<p:inputText id="globalFilter" onkeyup="proj.filter();" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column id="c1" headerText="Proje Adı" width="500" filterStyle="display:none" styleClass="wrap" sortBy="#{item.projectname}" filterBy="#{item.projectname}" filterMatchMode="contains" >
<h:outputText value="#{item.projectname}"/>
</p:column>
<p:column headerText="İlçe" width="150" styleClass="wrap" filterStyle="display:none" filterBy="#{item.district}" sortBy="#{item.district}" filterOptions="#{populator.districtsDD}" filterMatchMode="exact">
<h:outputText value="#{item.district}"/>
</p:column>
<p:column headerText="Sektör" width="150" styleClass="wrap" filterStyle="display:none" filterBy="#{item.sector}" sortBy="#{item.sector}" filterOptions="#{populator.sectorsDD}" filterMatchMode="exact">
<h:outputText value="#{item.sector}"/>
</p:column>
<p:column headerText="Başlangıç Tarihi" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.startdate}" filterBy="#{item.startdate}" filterMatchMode="contains">
<h:outputText value="#{item.startdate}"/>
</p:column>
<p:column headerText="Bitiş Tarihi" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.enddate}" filterBy="#{item.enddate}" filterMatchMode="contains">
<h:outputText value="#{item.enddate}"/>
</p:column>
<p:column headerText="İş Durumu" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.workstatus}" filterBy="#{item.workstatus}" filterMatchMode="contains">
<h:outputText value="#{item.workstatus}"/>
</p:column>
<p:column>
<p:commandButton id="selectButton" update=":display" oncomplete="carDialog.show()" icon="ui-icon-search" title="Detayları Gör">
<f:setPropertyActionListener value="#{item}" target="#{projectsController.selectedP}" />
<p:ajax event="click" update=":viewTabs:tabView:mapTab"/>
</p:commandButton>
<p:commandButton id="editButton" update=":displayEdit" oncomplete="editDialog.show()" icon="ui-icon-pencil" title="Düzenle">
<f:setPropertyActionListener value="#{item}" target="#{projectsController.selectedP}" />
</p:commandButton>
<p:commandButton update="growl" title="Projeyi Sil" id="confirm" action="#{projectsController.destroy}" icon="ui-icon-trash" ajax="false" onclick="if (!confirm('Bu projeyi gerçekten silmek istiyor musunuz?'))
return false;"/>
</p:column>
</p:dataTable>
After filtering or sorting how can I reset my datatable to first state? Thanks in advance.
Primefaces 3.5, Oracle WebLogic 10g, JSF 2.2
Here is the snapshot:
![enter image description here][1]
For those who want to know solution, I have removed both jsf-api.jar and jsf-impl.jar from the libraries instead I have put netbeans' own jsf2.1 library. Basically I have downgraded to jsf2.1. I just suspect if jsf-api and jsf-impl gives me the support of jsf2.2.
Hope this helps to someone.

Set required attribute of two h:selectManyCheckbox

I have two h:selectManyCheckBox with the required attribute set to true.
What I want is that the required attribute of both of the components work together.
Only display the error message if and only if both of the selected items list are empty.
Right now my problem is that the message displays if either one of them is empty. Here's my code:
<rich:panel>
<f:facet name="header">
<h:outputText value="Actualización de catálogos"/>
</f:facet>
<h:panelGrid columns="4">
<h:outputLabel for="actualizarCatalogoPEC"
value="Actualizar catálogos PEC"/>
<h:selectBooleanCheckbox id="actualizarCatalogoPEC"
value="#{administrationBean.actualizaTodosPecChecked}">
<f:ajax event="click"
render="todosCatalogosPEC"/>
</h:selectBooleanCheckbox>
<h:outputLabel for="actualizarCatalogoSAGARPA"
value="Actualizar catálogos SAGARPA"/>
<h:selectBooleanCheckbox id="actualizarCatalogoSAGARPA"
value="#{administrationBean.actualizaTodosSagarpaChecked}">
<f:ajax event="click"
render="todosCatalogosSAGARPA"/>
</h:selectBooleanCheckbox>
<a4j:outputPanel id="todosCatalogosPEC">
<h:selectManyCheckbox id="selectCatalogosPEC"
disabled="#{administrationBean.actualizaTodosPecChecked}"
required="true"
value="#{administrationBean.catalogosPecSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection">
<f:selectItems value="#{administrationBean.catalogosPecOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<a4j:outputPanel id="todosCatalogosSAGARPA">
<h:selectManyCheckbox id="selectCatalogosSAGARPA"
disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
required="true"
value="#{administrationBean.catalogosSagarpaSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection" >
<f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<rich:message id="messageCatalogosPEC"
for="selectCatalogosPEC"/>
<h:panelGroup/>
<rich:message id="messageCatalogosSAGARPA"
for="selectCatalogosSAGARPA"/>
<h:panelGroup/>
<a4j:commandButton value="Actualizar catálogos"
render="messageCatalogosPEC"
action="#{administrationBean.doActualizaCatalogos}"/>
</h:panelGrid>
</rich:panel>
Cheers
UPDATE
I've changed my code as follows: (just added binding and modified required)
<a4j:outputPanel id="todosCatalogosPEC">
<h:selectManyCheckbox id="selectCatalogosPEC"
disabled="#{administrationBean.actualizaTodosPecChecked}"
binding="selectCatalogosPEC"
required="#{empty selectCatalogosSAGARPA.value}"
value="#{administrationBean.catalogosPecSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection">
<f:selectItems value="#{administrationBean.catalogosPecOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<a4j:outputPanel id="todosCatalogosSAGARPA">
<h:selectManyCheckbox id="selectCatalogosSAGARPA"
binding="selectCatalogosSAGARPA"
disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
required="#{empty selectCatalogosPEC.value}"
value="#{administrationBean.catalogosSagarpaSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection" >
<f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
but got this error:
jun 01, 2012 10:31:37 AM org.apache.catalina.core.StandardWrapperValve invoke
Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/SRC_RichFaces] threw exception [java.lang.String cannot be cast to javax.faces.component.UIComponent] with root cause
java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1941)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1144)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:504)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:157)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
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 org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
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 org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
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.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
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 org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
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.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
You need to bind them both to the view and in the required attribute of the first one, check if the UIInput#getSubmittedValue() of the second one is empty and in the required attribute of the second one, check if the UIInput#getValue() of the first one is empty.
<h:selectManyCheckbox
binding="#{selectCatalogosPEC}"
required="#{empty selectCatalogosSAGARPA.submittedValue}"
>
...
</h:selectManyCheckbox>
<h:selectManyCheckbox
binding="#{selectCatalogosSAGARPA}"
required="#{empty selectCatalogosPEC.value}"
>
....
</h:selectManyCheckbox>
See also:
JSF two required h:inputText (exclusive or)

Resources