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
Related
I'm developing composite component in JSF. In that I can pass method names as arguments in following way.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="noOfButtons" type="java.lang.Integer" required="true"/>
<composite:attribute name="actionOnly" type="java.lang.Boolean" required="true"/>
<composite:attribute name="myBean" required="true" type="com.jsf.CRUDBean"/>
<composite:attribute name="myIcons" type="java.lang.String" required="true"/>
<composite:attribute name="myAction" type="java.lang.String" required="true"/>
<composite:attribute name="myDesc" type="java.lang.String" required="true"/>
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<c:forEach begin="0" end="#{cc.attrs.noOfmys - 1}" var="counter"
varStatus="status">
<h:commandButton id="myButton_${counter}"
action="#{cc.attrs.myBean[fn:split(cc.attrs.myAction, ',')[status.index]]}"
image="#{request.contextPath}/resources/images/#{fn:split(cc.attrs.myIcons, ',')[status.index]}"
title="#{fn:split(cc.attrs.myDesc, ',')[status.index]}"
style="padding:2px">
<p:spacer width="5px;" />
</c:forEach>
</composite:implementation>
</html>
This is working perfect.But in my case, I need to pass action in following way.
<c:forEach begin="0" end="#{cc.attrs.noOfmys - 1}" var="counter"
varStatus="status">
<h:commandButton id="myButton_${counter}"
image="#{request.contextPath}/resources/images/#{fn:split(cc.attrs.myIcons, ',')[status.index]}"
title="#{fn:split(cc.attrs.myDesc, ',')[status.index]}"
style="padding:2px">
<f:attribute name="action" value="#{cc.attrs.myBean[fn:split(cc.attrs.myAction, ',')[status.index]]}" />
</h:commandButton>
<p:spacer width="5px;" />
</c:forEach>
But this is not working in my application. Whenever I click commandButton from the page nothing happening at user level. Any help would be thankful.
I have the following composite component, and I want to use o:validateMultipleFields (o:validateAllOrNone more specifically).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite"
>
<composite:interface>
<composite:attribute name="target" />
<composite:attribute name="label"/>
<composite:attribute name="value" />
<composite:attribute name="required" />
<composite:attribute name="size" />
<composite:attribute name="disabled" />
<composite:attribute name="styleInput" required="false" />
<composite:editableValueHolder name="input" targets="input" />
<composite:clientBehavior name="change" event="change" targets="#{cc.attrs.target}" />
<composite:clientBehavior name="keypress" event="keypress" targets="#{cc.attrs.target}" />
</composite:interface>
<composite:implementation>
<p:outputLabel id="label" for="input" value="#{cc.attrs.label}" />
<h:panelGrid columns="3">
<p:inputText id="input" value="#{cc.attrs.value}"
style="#{cc.attrs.styleInput}" size="#{cc.attrs.size}"
disabled="#{cc.attrs.disabled}" required="#{cc.attrs.required}">
</p:inputText>
<p:message for="input" display="icon">
<p:effect type="pulsate" event="load" delay="500" />
</p:message>
</h:panelGrid>
</composite:implementation>
</html>
The validation is working as expected, but the labels of the components specified on the components property are no showing. Instead it's showing the components id's.
<cetcomp:editar id="origem" label="Origem" size="10" />
<cetcomp:editar id="cst" label="CST" size="10" />
<o:validateAllOrNone id="origemCst" components="origem:input cst:input" showMessageFor="origem:input" />
The ValidateMultipleFields extracts the labels from the label attribute of the physical input components. Exactly those labels which would be used in standard JSF validation, too. You indeed have none, they are only set on the <p:outputLabel>.
Add them accordingly:
<p:inputText ... label="#{cc.attrs.label}">
An alternative is to use <o:outputLabel> instead of <p:outputLabel> as the OmniFaces one would automatically copy the label to the associated input component.
<o:outputLabel ... for="input" value="#{cc.attrs.label}" />
<p:inputText id="input" ... />
Update: it turns out that it actually still didn't work. The #{cc} wasn't available while ValidateMultipleFields is extracting the labels. This was fixed as per issue 134 and it will be available in OmniFaces 2.1.
I am making composite component where i have commandButton. But it doesn't work.
Usage:
<wk:commandButton value="Non-Ajax actionListener" actionListener="#{ioBean.saveListener}" />
Code of component: commandButton.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html 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:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="action" method-signature="void action(javax.faces.event.ActionEvent)" default="null"/>
<cc:attribute name="actionListener" method-signature="void actionListener(javax.faces.event.ActionEvent)" default="null"/>
<cc:attribute name="styleClass" default="button" />
</cc:interface>
<cc:implementation>
<p:commandButton
value="#{cc.attrs.value}"
action="#{cc.attrs.action}"
actionListener="#{cc.attrs.actionListener}"
styleClass="#{styleClass}">
<cc:insertChildren />
</p:commandButton>
</cc:implementation>
</html>
And this is log:
0000006c FaceletViewDe E Inner component action not found when retargetMethodExpressions
0000006c FaceletViewDe E Inner component actionListener not found when retargetMethodExpressions
0000006c srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: Ostrzeżenie: nie można ustawić nagłówka. Odpowiedź została już zatwierdzona.
I think the problem is with default value for action and actionListener. But according to the PrimeFaces documentation, default value for action and actionListener is null.
One option is to make four different variants where action and actionListener are null or are defined but it doedn't seem to be good solution.
Use <cc:attribute targets> instead of explicitly specifying a possibly null action(listener).
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="action" targets="buttonId" />
<cc:attribute name="actionListener" targets="buttonId" />
</cc:interface>
<cc:implementation>
<p:commandButton id="buttonId" value="#{cc.attrs.value}" />
</cc:implementation>
I've created a composite that contains the PrimeFaces selectManyMenu. I'm attempting to pass the bound selection value into the composite, but it fails.
Composite code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<composite:interface>
<composite:attribute name="selectedUsers" required="true"/>
<composite:attribute name="users" required="true" type="java.util.List"/>
<composite:attribute name="recommendActionHandler" required="true" method-signature="void listener()"/>
<composite:attribute name="recommendButtonStyle"/>
<composite:clientBehavior name="click" event="change" targets="recommendUsers" default="true"/>
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<h:form id="recommendForm" prependId="false">
<p:growl id="recommendGrowl" showDetail="true"/>
<p:commandButton id="recommendBtn" value="Recommend" type="button" update=":recommendForm,recommendUsers" style="#{cc.attrs.recommendButtonStyle}"/>
<p:overlayPanel id="recommendPanel" for="recommendBtn" widgetVar="recommendPanel"
dynamic="true"
hideEffect="fade"
showCloseIcon="true">
<p:selectManyMenu id="recommendUsers" value="#{cc.attrs.selectedUsers}" showCheckbox="true"
style="width:150px;height:200px">
<f:selectItems value="#{cc.attrs.users}" var="user" itemLabel="#{user.login}" itemValue="#{user.login}"/>
</p:selectManyMenu>
<p:commandButton id="submitRecommendations"
value="Send"
update="recommendUsers recommendGrowl"
actionListener="#{cc.attrs.recommendActionHandler}"
process="recommendUsers #this"
/>
</p:overlayPanel>
</h:form>
</div>
</composite:implementation>
</html>
View code:
<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:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
>
<ui:composition template="/WEB-INF/facelet_templates/default.xhtml">
<ui:define name="content">
<kf:recommend id="recommendIt"
selectedUsers="#{recommendViewBean.selectedUsers}"
users="#{recommendViewBean.users}"
recommendActionHandler="#{recommendController.saveRecommendations()}"
/>
</ui:define>
</ui:composition>
</html>
View bean code:
public class RecommendViewBean {
private List<UserType> users = new ArrayList<UserType>();
private List<String> selectedUsers = new ArrayList<String>();
//setters and getters...
}
In the code above, the value selectedUsers is the value in question. I pass the view/backing bean's List value that holds the selections for the selectManyMenu's value attribute. This works great when outside of a composite or if I pass the view bean like this...
<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:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
>
<ui:composition template="/WEB-INF/facelet_templates/default.xhtml">
<ui:define name="content">
<kf:recommend id="recommendIt"
selectedUsers="#{recommendViewBean}"
users="#{recommendViewBean.users}"
recommendActionHandler="#{recommendController.saveRecommendations()}"
/>
</ui:define>
</ui:composition>
</html>
...
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<composite:interface>
<composite:attribute name="selectedUsers" required="true"/>
<composite:attribute name="users" required="true" type="java.util.List"/>
<composite:attribute name="recommendActionHandler" required="true" method-signature="void listener()"/>
<composite:attribute name="recommendButtonStyle"/>
<composite:clientBehavior name="click" event="change" targets="recommendUsers" default="true"/>
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<h:form id="recommendForm" prependId="false">
<p:growl id="recommendGrowl" showDetail="true"/>
<p:commandButton id="recommendBtn" value="Recommend" type="button" update=":recommendForm,recommendUsers" style="#{cc.attrs.recommendButtonStyle}"/>
<p:overlayPanel id="recommendPanel" for="recommendBtn" widgetVar="recommendPanel"
dynamic="true"
hideEffect="fade"
showCloseIcon="true">
<p:selectManyMenu id="recommendUsers" value="#{cc.attrs.selectedUsers.selectedUsers}" showCheckbox="true"
style="width:150px;height:200px">
<f:selectItems value="#{cc.attrs.users}" var="user" itemLabel="#{user.login}" itemValue="#{user.login}"/>
</p:selectManyMenu>
<p:commandButton id="submitRecommendations"
value="Send"
update="recommendUsers recommendGrowl"
actionListener="#{cc.attrs.recommendActionHandler}"
process="recommendUsers #this"
/>
</p:overlayPanel>
</h:form>
</div>
</composite:implementation>
</html>
So, my question is, how would I pass the appropriate bound value for selectManyMenu's value attribute into the composite?
Thanks so much. Let me know if I need to explain more.
I am goin to explain a problem that I have when I use one composite component inside a template.
Imagine one view like this, that work with a generic managed bean with view scope. I pass it to the template as a parameter.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:trkal="http://java.sun.com/jsf/composite/trkalcomponents">
<ui:composition template="/template.xhtml">
<ui:param name="maisuBean" value="#{genericBean}" />
</ui:composition>
</html>
The template is like this. Beside other components, it also use one composite component.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:trkal="http://java.sun.com/jsf/composite/trkalcomponents">
<h:head>
<title>Titulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</h:head>
<h:body>
<h:form enctype="multipart/form-data">
...
<trkal:toolbarbuttonwidget id="buttonToolbar" label="Action" iconName="toolbar.png"
buttonAction="#{maisuBean.myActionListener}"
>
</trkal:toolbarbuttonwidget>
...
<h:commandLink id="otherButton" actionListener="#{maisuBean.myActionListener}">
<h:graphicImage library="images" name="toolbar.png" />
<h:outputText value="Other Action" />
</h:commandLink>
...
</h:form>
</h:body>
</html>
As you can see, this template use one composite components that allow specify the action listener that hear this event.
<composite:interface>
<composite:attribute name="id" />
<composite:attribute name="buttonAction" method-signature="void myAction(javax.faces.event.ActionEvent)" targetAttributeName="actionListener"/>
<composite:attribute name="iconName" />
<composite:attribute name="label"/>
<composite:attribute name="title"/>
<composite:attribute name="styleClass"/>
</composite:interface>
<composite:implementation>
<h:outputStylesheet target="head" library="trkalcomponents" name="toolbarbuttonwidget.css" />
<h:commandLink id="buttonAction">
<h:graphicImage library="images" name="#{cc.attrs.iconName}" />
<h:outputText value="#{cc.attrs.label}" />
</h:commandLink>
</composite:implementation>
If I click in otherButton, it work fine, but if I click in buttonToolbar it don't work.
09-nov-2012 19:16:28 javax.faces.event.MethodExpressionActionListener processAction
GRAVE: Se ha recibido 'javax.el.PropertyNotFoundException' al invocar la escucha de acción '#{maisuBean.myActionListener}' para el componente 'buttonAction'
09-nov-2012 19:16:28 javax.faces.event.MethodExpressionActionListener processAction
GRAVE: javax.el.PropertyNotFoundException: /template.xhtml #20,6 buttonAction="#{maisuBean.myActionListener}": Propiedad 'myActionListener' no hallada en el tipo com.joxeja.test.ToolBarBean
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
It seem that it can't resolve the EL expression inside the composite component.
What is wrong? How can I use one composite componente inside one template?
I am using Mojarra 2.1.7
Thanks.
Sorry I missed this on the first read:
Your implementation isn't targeting the attributes properly. I made this mistake (as I'm pretty sure all of us do). You need to reference the attributes as -> #{cc.attrs.someAttribute} not by their name. You do this for most of the elements, but not the actionListener. If that is your code it should fix it. Your signatures are correct. You're trying to use the targetAttributeName which I'm not familiar with. My guess is you need to set the id of the component to that name (so your button would be myAction not actionListener (if I'm referencing the same example you are).
That aside, how I would do it is:
<composite:interface>
<composite:attribute name="id" />
<!--
<composite:attribute name="buttonAction" method-signature="void myAction(javax.faces.event.ActionEvent)" targetAttributeName="actionListener"/>
-->
<composite:attribute name="buttonAction" method-signature="void action(javax.faces.event.ActionEvent)"/>
<composite:attribute name="iconName" />
<composite:attribute name="label"/>
<composite:attribute name="title"/>
<composite:attribute name="styleClass"/>
</composite:interface>
<composite:implementation>
<h:outputStylesheet target="head" library="trkalcomponents" name="toolbarbuttonwidget.css" />
<!-- fix below -->
<h:commandLink id="buttonAction" actionListener=#{cc.attrs.buttonAction}>
<h:graphicImage library="images" name="#{cc.attrs.iconName}" />
<h:outputText value="#{cc.attrs.label}" />
</h:commandLink>
</composite:implementation>
I like this method because it is similar to the rest of the way pages are marked up and it seems simple. Give it a shot.