I'm developing a composite component to centralize and reuse primefaces components:
<?xml version="1.0"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bridge="http://portletfaces.org/bridge"
xmlns:m3="http://java.sun.com/jsf/composite/m3jsf"
xmlns:Portlet="http://java.sun.com/portlet_2_0"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="rendered" type="java.lang.Boolean" default="true"/>
</composite:interface>
<composite:implementation>
<span id="#{cc.clientId}">
<p:overlayPanel id="idPanelloListaDatiFullScreen" dynamic="true" appendToBody="false"
styleClass="m3PanelListaDati" binding="#{m3DataTableBackingBean.bindingVarOverlay}"
rendered="#{cc.attrs.rendered}">
</p:overlayPanel>
<p:panel id="idPanelloListaDati" styleClass="m3PanelListaDati"
rendered="#{cc.attrs.rendered}">
<composite:insertChildren></composite:insertChildren>
</p:panel>
</span>
</composite:implementation>
And I use it in a view as:
<m3:myCompositePanel id="idCompositePanel/>
But when view is rendering an exception is trown:
Caused by: java.lang.NullPointerException
at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:567)
at org.primefaces.component.overlaypanel.OverlayPanelRenderer.encodeScript(OverlayPanelRenderer.java:67)
at org.primefaces.component.overlaypanel.OverlayPanelRenderer.encodeEnd(OverlayPanelRenderer.java:37)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at com.sun.faces.renderkit.html_basic.CompositeRenderer.encodeChildren(CompositeRenderer.java:78)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:439)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at com.liferay.faces.bridge.application.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:35)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
... 219 more
I'm using PirmeFaces 3.5.23, mojarra 2.1.21 and I'm developing a portlet in Liferay 6.1.3ga3 and bridge 3.1.3ga4
Thank you for any help
Line 67 of the PrimeFaces OverlayPanelRenderer.java class is trying to resolve the value of the for attribute. It looks like you may have forgotten to specify a value for the for attribute in your p:overlayPanel.
Related
I'm creating a composite component in my application with following code :
<?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:p="http://primefaces.org/ui"
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
<composite:interface>
<composite:attribute name="url" required="true" type="java.lang.String" />
<composite:attribute name="label" required="true" type="java.lang.String" />
<composite:attribute name="compId" required="true" type="java.lang.String" />
</composite:interface>
<composite:implementation>
<p:menuitem id="#{cc.attrs.compId}" value="#{cc.attrs.label}" url="#{cc.attrs.url}" />
</composite:implementation>
</html>
And am using this composite component in my index page as following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:ex="http://xmlns.jcp.org/jsf/composite/example">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>PrimeFaces</title>
</f:facet>
</h:head>
<h:body>
<p:menu>
<p:submenu id="admin" label="Admin" >
<ex:menuItem label="Go" url="www.google.com" compId="tempMenu"/>
</p:submenu>
</p:menu>
</h:body>
</html>
But whenever I'm trying to access index.xhtml page am getting following error.
javax.faces.component.UINamingContainer cannot be cast to org.primefaces.model.menu.MenuElement
But if i create composite component with following changes in composite:implementation part it's working fine.
composite component :
<p:menu>
<p:submenu id="admin" label="Admin" >
<p:menuitem value="#{cc.attrs.label}" url="#{cc.attrs.url}" id="#{cc.attrs.compId}"/>
</p:submenu>
</p:menu>
index.xhtml:
<ex:menuItem label="Go" url="www.google.com" compId="tempMenu" />
Why am I getting javax.faces.component.UINamingContainer cannot be cast to org.primefaces.model.menu.MenuElement while creating composite component? Any help would really useful. Thanks in advance.
Composite components are inherently of type UINamingContainer. The <p:submenu> supports only children of type MenuElement.
Use a tagfile instead of a composite. Composites are generally only useful for composited input fields.
/WEB-INF/tags/menuItem.xhtml:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<p:menuitem id="#{id}" value="#{label}" url="#{url}" />
</ui:composition>
/WEB-INF/my.taglib.xml:
<facelet-taglib
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd"
version="2.2"
>
<namespace>http://www.example.com/ui</namespace>
<tag>
<tag-name>menuItem</tag-name>
<source>tags/menuItem.xhtml</source>
<attribute>
<description>Component ID.</description>
<name>id</name>
<required>true</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Menu item label.</description>
<name>label</name>
<required>true</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Menu item URL.</description>
<name>url</name>
<required>true</required>
<type>java.lang.String</type>
</attribute>
</tag>
</facelet-taglib>
/WEB-INF/web.xml:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/my.taglib.xml</param-value>
</context-param>
Usage:
<html ... xmlns:ex="http://example.com/ui">
...
<p:menu>
<p:submenu id="admin" label="Admin" >
<ex:menuItem id="tempMenu" label="Go" url="www.google.com" />
</p:submenu>
</p:menu>
See also:
How to create a composite component for a datatable column?
When to use <ui:include>, tag files, composite components and/or custom components?
I have a problem when try to validate the rich:calendar component with o:validateOrder.
Code:
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:tablas="http://java.sun.com/jsf/composite/tablas"
xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions"
xmlns:templates="http://java.sun.com/jsf/composite/templates"
>
<body>
<f:metadata>
<f:event type="preRenderView" listener="#{baseController.iniciarConversacion()}" />
</f:metadata>
<ui:composition template="/templates/TemplateABM.xhtml">
<ui:define name="title">
#{msgs['facturacion.abm.generacion.factura.individual.pagina.titulo']}
</ui:define>
<ui:define name="top">
<h1>#{msgs['facturacion.abm.generacion.factura.individual.titulo']}</h1>
</ui:define>
<ui:define name="content">
<h:form id="formFacturaIndividual">
<h:panelGroup id="panelFechas">
<h:inputHidden id="fechaInicioFactura" value="#{facturaController.fechaInicioFactura}">
<f:convertDateTime type="date" pattern="dd/MM/yy"/>
</h:inputHidden>
<h:inputHidden id="fechaFinFactura" value="#{facturaController.fechaFinFactura}">
<f:convertDateTime type="date" pattern="dd/MM/yy"/>
</h:inputHidden>
<h:inputHidden id="fechaEmisionComprobanteUltima" value="#{comprobanteController.fechaEmisionComprobanteUltima}">
<f:convertDateTime type="date" pattern="dd/MM/yy"/>
</h:inputHidden>
</h:panelGroup>
<o:validateOrder id="validacionFechaFacturaMenorAFechaInicioFactura" type="gte" components="fechaFactura fechaInicioFactura"
message="#{msgs['comun.abm.fecha.factura.menor.limite.dia']}" showMessageFor="fechaFactura" />
<o:validateOrder id="validacionFechaFacturaMayorAFechaFinFactura" type="lte" components="fechaFactura fechaFinFactura"
message="#{msgs['comun.abm.fecha.factura.menor.limite.dia']}" showMessageFor="fechaFactura" />
<o:validateOrder id="validacionFechaFacturaMayorAFechaEmisionUltimoComprobante" type="gte" components="fechaFactura fechaEmisionComprobanteUltima"
message="#{of:format1(msgs['comun.abm.fecha.factura.menor.ultimo.comprobante'], comprobanteController.fechaEmisionComprobanteUltima)}" showMessageFor="fechaFactura" />
<o:massAttribute name="disabled" value="#{tipoComprobanteController.entidad == null}">
<rich:panel id="panelDatosFactura" header="#{msgs['facturacion.abm.generacion.padron.panel.datos.factura']}">
<h:panelGrid id="DatosFactura" columns="3">
<h:outputLabel value="#{msgs['facturacion.abm.generacion.padron.fecha.factura']}" for="fechaFactura"/>
<rich:calendar
id="fechaFactura"
datePattern="dd/MM/yyyy"
showWeeksBar="false"
enableManualInput="true"
value="#{generacionFacturacionIndividualController.facturaBean.fechaFactura}"
required="true"
requiredMessage="La Fecha de la Factura es Obligatoria" >
<a4j:ajax event="change" execute="#form" />
</rich:calendar>
<h:panelGroup>
<rich:message for="fechaFactura"/>
</h:panelGroup>
</h:panelGrid>
</rich:panel>
</o:massAttribute>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
Exception:
java.lang.IllegalArgumentException: All values must implement java.lang.Comparable.
at org.omnifaces.component.validator.ValidateOrder.validateValues(ValidateOrder.java:142)
at org.omnifaces.component.validator.ValidateMultipleFields.validateComponents(ValidateMultipleFields.java:213)
at org.omnifaces.component.validator.ValidatorFamily.processValidators(ValidatorFamily.java:63)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1216)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:536)
at org.richfaces.context.MetaComponentProcessingVisitCallback.visit(MetaComponentProcessingVisitCallback.java:73)
at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:103)
at org.richfaces.context.ExtendedExecuteVisitContext.invokeVisitCallback(ExtendedExecuteVisitContext.java:55)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1652)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:383)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:257)
at org.richfaces.context.ExtendedPartialViewContext.processPartial(ExtendedPartialViewContext.java:263)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1162)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at ar.com.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.String
at java.lang.String.compareTo(String.java:108)
at java.util.Collections$ReverseComparator.compare(Collections.java:3578)
at java.util.Collections$ReverseComparator.compare(Collections.java:3569)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324)
at java.util.TimSort.sort(TimSort.java:189)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.omnifaces.component.validator.ValidateOrder$Type$4.invoke(ValidateOrder.java:99)
at org.omnifaces.component.validator.ValidateOrder$Type$4.invoke(ValidateOrder.java:95)
at org.omnifaces.component.validator.ValidateOrder$Type.validateOrder(ValidateOrder.java:111)
at org.omnifaces.component.validator.ValidateOrder.validateValues(ValidateOrder.java:139)
... 44 more
I debuged the code and the problem is that the rich:calendar component send String instead Date type, this doesn't happen me in other pages i dont know is omnifaces problem or richfaces. Any ideas?
The <o:validateXxx> components are sensitive to their location relative to the target input components. This is very useful to prioritize validation depending on component's own converter and validators.
When placed before the target input components, then they will validate the raw unsubmitted values, and they will run before any of component's own validators.
When placed after the target input components, then they will validate the converted values (if any converter is involved), and they will run after any of component's own validators.
In your particular case, you placed the <o:validateOrder> between those components. This is not the recommended approach. You will end up getting a List filled with Date instances from components above the validator and String instances from components below the validator.
See also the ValidateMultipleFields javadoc (emphasis mine):
This validator can be placed anywhere in the form, but keep in mind that the components will be validated in the order as they appear in the form. So if this validator is been placed before all of the components, then it will be executed before any of the component's own validators. If this validator fails, then the component's own validators will not be fired. If this validator is been placed after all of the components, then it will be executed after any of the component's own validators. If any of them fails, then this validator will not be exeucted. It is not recommended to put this validator somewhere in between the referenced components as the resulting behaviour may be confusing. Put this validator either before or after all of the components, depending on how you would like to prioritize the validation.
im using
RichFaces 4.5.1.Final
Weld 2.2.8.Final
Mojarra 2.1.29
JSF 2.1
The problem is when im starting to use template with Facelets and an exception is thrown in this case obviously NullPointerException but if you see the stacktrace is wrapping the exception into another exception and i cant see the real cause of the problem, the original exception. Is important to say that if i coment the NPE code works perfectly. Any ideas that was causing the issue, Facelets, JSF or Weld. this happen with all exception
I have this structure:
Controller
#Named(value="productoController")
#ConversationScoped
public class ProductoController {
public void alta(){
String test = null;
//Throw NPE
test.concat("");
}
}
Page:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:templates="http://java.sun.com/jsf/composite/templates">
<ui:composition template="/templates/TemplateABM.xhtml">
<ui:define name="title">
#{msgs['producto.abm.alta.pagina.titulo']}
</ui:define>
<ui:define name="top">
<h1>#{msgs['producto.abm.alta.titulo']}</h1>
</ui:define>
<ui:define name="content">
<templates:productos id="templateProductos"
page="alta"
disableComponents="false"
btnAccionText="#{msgs['comun.abm.boton.guardar']}"
btnAccion="#{productoController.alta()}"
/>
</ui:define>
</ui:composition>
</html>
Templates:
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:templates="http://java.sun.com/jsf/composite/templates"
>
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="page" required="true" />
<composite:attribute name="btnAccionText" required="true" />
<composite:attribute name="btnAccion" method-signature="java.lang.String action()" required="true" />
<composite:attribute name="disableComponents" required="true" />
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<f:metadata>
<f:event type="preRenderView" listener="{productoController.iniciarConversacion}" />
</f:metadata>
<h:form id="formABMProducto">
<templates:botonera id="templateBotonera"
margen="8%"
page="#{cc.attrs.page}"
btnAccionText="#{cc.attrs.btnAccionText}"
btnAccion="#{cc.attrs.btnAccion}"
/>
</h:form>
</composite:implementation>
</html>
Template Botonera.xhtml
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="margen" required="true" />
<composite:attribute name="page" required="true" />
<composite:attribute name="btnAccionText" required="false" />
<composite:attribute name="btnAccion" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="btnExportar" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="disabled" required="false" />
<composite:attribute name="execute" required="false" />
<composite:attribute name="oncompleteValue" required="false" />
<composite:attribute name="deshabilitarBotonAccion" required="false" />
<composite:attribute name="habilitarBotonSeguir" required="false" />
<composite:attribute name="habilitarBotonExportar" required="false" />
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<div id="botonera">
<a4j:commandButton
id="btnAccion"
value="#{cc.attrs.btnAccionText}"
action="#{cc.attrs.btnAccion}"
disabled="#{cc.attrs.disabled}"
execute="#{cc.attrs.execute}"
render="#form"
oncomplete="#{cc.attrs.oncompleteValue}"
rendered="#{!cc.attrs.deshabilitarBotonAccion}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnSeguir"
value="#{msgs['comun.abm.boton.seguir']}"
action="/abm/servicios/alta"
immediate="true"
disabled="#{titularController.deshabilitarBotonSeguir}"
rendered="#{cc.attrs.page eq 'alta' and cc.attrs.habilitarBotonSeguir}" style="margin:0px #{cc.attrs.margen};"/>
<a4j:commandButton
id="btnExportar"
value="#{msgs['facturacion.abm.generacion.padron.boton.exportar']}"
action="#{cc.attrs.btnExportar}"
execute="#{cc.attrs.execute}"
render="#form"
rendered="#{cc.attrs.habilitarBotonExportar}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnCancelar"
action="#{commonController.reset(cc.attrs.page)}"
immediate="true"
value="#{msgs['comun.abm.boton.cancelar']}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnAyuda"
value="#{msgs['comun.abm.boton.ayuda']}"
style="margin:0px #{cc.attrs.margen};" />
<a4j:commandButton
id="btnSalir"
value="#{msgs['comun.abm.boton.salir']}"
onclick="#{rich:component('popupConfirmacionSalida')}.show();"
style="margin:0px #{cc.attrs.margen};"
immediate="true" />
</div>
<ui:include src="/templates/common/popup_salida.xhtml" />
</composite:implementation>
</html>
stacktrace:
GRAVE: javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Método no hallado: com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap#33704fed.btnAccion()
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at ar.com.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.el.MethodNotFoundException: Método no hallado: com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap#33704fed.btnAccion()
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:259)
at org.apache.el.parser.AstValue.invoke(AstValue.java:271)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:187)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:450)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
Thanks
Ignacio
Response for User BalusC, i attached the screen and receive the same result with FullAjaxExceptionHandler.
I saw this in the console maybe you can use (this doesnt reflect in the view):
dic 23, 2014 3:45:06 PM com.sun.faces.facelets.el.ContextualCompositeMethodExpression invoke
ADVERTENCIA: jsf.facelets.el.method.expression.invoke.error:javax.el.ELException: java.lang.NullPointerException
dic 23, 2014 3:45:06 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
I'm using JSF Composite Component for reuse component. However, I keep getting a null-pointer error, I follow some of the tutorial I found but none mention this problem.
The stack trace added:
java.lang.NullPointerException
at com.sun.faces.application.view.FaceletViewHandlingStrategy$MethodRetargetHandlerManager$ArbitraryMethodRegargetHandler.retarget(FaceletViewHandlingStrategy.java:1883)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.retargetMethodExpressions(FaceletViewHandlingStrategy.java:772)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:201)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:972)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)
I'm using Netbean 8.0, and the JSF is included in a Enterprise Application project, not sure if that cause any difference from a webApplication project.
<?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://xmlns.jcp.org/jsf/html"
xmlns:composite="http://xmlns.jcp.org/jsf/composite"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="action"/>
</composite:interface>
<composite:implementation>
<h:form>
<h:panelGrid columns="2">
<h:panelGroup>Customer Name:</h:panelGroup>
<h:panelGroup>
<h:inputText value="#{MyMB.customer.name}">
<f:validateRegex pattern="(?:[A-Za-z]+\s*)+"/>
</h:inputText>
</h:panelGroup>
<h:panelGroup>Address:</h:panelGroup>
<h:panelGroup>
<h:inputText value="#{MyMB.customer.address}"></h:inputText>
</h:panelGroup>
<h:panelGroup>Date Of Birth:</h:panelGroup>
<h:panelGroup>
<h:inputText value="#{MyMB.customer.dateOfBirth}">
<f:convertDateTime pattern="MM/dd/yyyy"/>
</h:inputText>
</h:panelGroup>
<h:panelGroup>Gender:</h:panelGroup>
<h:panelGroup>
<h:selectOneRadio value="#{MyMB.customer.gender}">
<f:selectItem itemValue="Male" itemLabel="Male"/>
<f:selectItem itemValue="Female" itemLabel="Female"/>
</h:selectOneRadio>
</h:panelGroup>
</h:panelGrid>
<h:commandButton value="Submit" action="#{cc.attrs.action}"></h:commandButton>
</h:form>
</composite:implementation>
</h:body>
</html>
Index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:comp="http://java.sun.com/jsf/composite/comp">
<h:head>
<title>Customers Management</title>
</h:head>
<h:body>
<h:button value="Register Customer" outcome="register.xhtml"></h:button>
<h:button value="Update Customer Info" outcome="update.xhtml"></h:button>
<comp:customerForm action="#{MyMB.findCustomer()}"></comp:customerForm>
<h:panelGrid columns="2">
<h:panelGroup>
</h:panelGroup>
<h:panelGroup>
<h:form>
<h:selectOneListbox style="margin-left: 100px; width:200px; height:120px" value="#{MyMB.customer}">
<f:selectItems value="#{MyMB.listOfCust}"/>
</h:selectOneListbox>
<h:commandButton value="Remove" action="#{MyMB.removeCustomer()}"></h:commandButton>
<h:commandButton value="Update Customer Info" action="update.xhtml"></h:commandButton>
</h:form>
</h:panelGroup>
</h:panelGrid>
</h:body>
</html>
Try this one
<composite:attribute name="action" method-signature="java.lang.String action()"/>
I have a jsf page, main.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="WEB-INF/templates/layout.xhtml">
<ui:define name="title">Page Title</ui:define>
...
Layout.xml is as follows:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title><ui:insert name="title">Default Title</ui:insert></title>
<h:outputStylesheet library="theme" name="main.css" />
</h:head>
<h:body>
<div id="header">
<ui:insert name="header">
<ui:include src="header.xhtml"/>
</ui:insert>
<ui:insert name="toolbar">
<ui:include src="toolbar.xhtml" />
</ui:insert>
</div>
<div id="content">
<br/>
<ui:insert name="content">
TBD
</ui:insert>
</div>
<div id="footer">
<ui:insert name="footer">
<ui:include src="footer.xhtml"/>
</ui:insert>
</div>
</h:body>
</html>
When I try to load the page, I get the following stack trace:
Dec 8, 2011 8:58:50 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/main.xhtml]
java.lang.NullPointerException: Argument Error: Parameter value is null
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeURIAttribute(HtmlResponseWriter.java:985)
at com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd(StylesheetRenderer.java:108)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at com.sun.faces.renderkit.html_basic.HeadRenderer.encodeHeadResources(HeadRenderer.java:105)
at com.sun.faces.renderkit.html_basic.HeadRenderer.encodeEnd(HeadRenderer.java:92)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
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:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.lmig.cm.ps.editor.filter.SecuredPageFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.lmig.cm.ps.editor.user.UserFilter.handleDeveloperEnvironment(Unknown Source)
at com.lmig.cm.ps.editor.user.UserFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.lmig.cm.ps.editor.filter.SessionTimeoutFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
If I remove the section from layout.xhtml:
<h:head>
<title><ui:insert name="title">Default Title</ui:insert></title>
<h:outputStylesheet library="theme" name="main.css" />
</h:head>
The page will load (of course with no css or title). Even if I only have this in the page:
<h:head>
</h:head>
It will not render, and I receive the same error.
I have been working for quite a while, and can not figure out what I am doing wrong. My hunch is that it has something to do with the version of the jars I have included, but swapping most of them out, hasn't led to a solution.
Does anyone have any ideas?
java.lang.NullPointerException: Argument Error: Parameter value is null
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeURIAttribute(HtmlResponseWriter.java:985)
at com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd(StylesheetRenderer.java:108)
Let's look at the StylesheetRenderer#encodeEnd() source (I'm using Mojarra 2.1.4; I assume that you're also using it as most if not all com.sun.faces line numbers in your stack trace match 100% with the source; in the future however please mention exact version):
105 String resourceUrl = "RES_NOT_FOUND";
105 if (resource != null) {
106 resourceUrl = context.getExternalContext().encodeResourceURL(resource.getRequestPath());
107 }
108 writer.writeURIAttribute("href", resourceUrl, "href");
So, resourceUrl is null somehow.
Let's look at ExternalContext#encodeResourceURL(String) source:
311 public abstract String encodeResourceURL(String url);
D'oh, it's abstract. Well, let's look at the default Mojarra implementation, the com.sun.faces.context.ExternalContextImpl:
521 public String encodeResourceURL(String url) {
522 return ((HttpServletResponse) response).encodeURL(url);
523 }
Ah, it delegates to HttpServletResponse#encodeURL() which should by default not return null at all.
So, your problem can have at least 2 possible causes:
You have a custom ExternalContext implementation which is not doing its job in encodeResourceURL() properly.
You have a custom HttpServletResponseWrapper implementation which is not doing its job in encodeURL() properly.
Putting a debugger breakpoint on line 106 of StylesheetRenderer and debugging from there
should tell you which implementations are actually been used.
That the same exception occurs when you remove the <h:outputStylesheet> is likely because RichFaces implicitly inserts those components in there as well for own stylesheets. Based on your XML namespace declarations, you're using RichFaces.