richfaces - JSF Composite Component with conditional popup panel -
i'm trying render composite component shows popup panel based on outcome of backing bean method. far no success. appreciate help.
- glassfish 4.1
- mojarra 2.2
- richfaces 4.5.4
composite component (conditionalactionlink.xhtml):
<ui:component xmlns="http://www.w3.org/1999/xhtml" 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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface> <composite:attribute name="value"/> <composite:attribute name="style"/> <composite:attribute name="disabled"/> <composite:attribute name="render"/> <composite:attribute name="message" /> <composite:attribute name="renderedbtn" type="java.lang.boolean"/> <composite:attribute name="condition" required="true" method-signature="java.lang.boolean action()"/> <composite:attribute name="execaction" required="true" method-signature="void action()"/> </composite:interface> <composite:implementation> <ui:debug hotkey="x" /> <h:form> <a4j:commandlink id="actnlnx" value="#{cc.attrs.value}" oncomplete="#{managepurchases.billhaspaymentsapplied ? showmessage() : submittoserver() }" style="#{cc.attrs.style}" disabled="#{cc.attrs.disabled}"/> <a4j:jsfunction name="showmessage" onbegin="#{rich:component('noticedialog')}.show()" execute="@form"/> <a4j:jsfunction name="submittoserver" action="#{cc.attrs.execaction}" render="#{cc.attrs.render}" execute="@form"/> <rich:popuppanel id="noticedialog" modal="true" autosized="true" resizeable="false" style="font-size: large;"> <f:facet name="header" style="font-size: large;"> <h:outputtext value="notice" /> </f:facet> <f:facet name="controls"> <h:outputlink value="#" onclick="#{rich:component('noticedialog')}.hide(); return false;"> x </h:outputlink> </f:facet> <h:outputtext value="#{cc.attrs.message}"/> <br/><br/> <h:commandbutton value="ok" onclick="#{rich:component('noticedialog')}.hide(); return false;" style="font-size: large;"/> </rich:popuppanel> </h:form> </composite:implementation>
invoking page:
<cc:conditionalactionlink value="delete" style="font-size: large;text-decoration:none" message="this bill has payments applied. please delete payments first." condition="#{managepurchases.billhaspaymentsapplied}" execaction="#{managepurchases.deletebill}"/>
btw, need use condition value in composite component, challenged how avoid nested el expression: oncomplete="#{cc.attr.condition ? showmessage() : submittoserver() }"
backing bean:
public boolean getbillhaspaymentsapplied(){ applogger.entry(); //if(bill.getpayments().size() > 0) return applogger.exit(true); //else //return applogger.exit(false); } public void deletebill(){ applogger.entry(); applogger.debug("delete bill here."); //billdaobean.deletebill(bill); applogger.exit(); }
i've tried many tweaks, search online. particular version, error message
javax.el.elexception: function 'showmessage' not found
i seeking way achieve behavior.
thanks in advance!
the oncomplete
attribute of <a4j:commandlink>
component must evaluate string
. here, el tries invoke either showmessage()
or submittoserver()
java method depending on boolean value, not found.
what want string
js function name, put function names between single quotes make them string
:
oncomplete="#{managepurchases.billhaspaymentsapplied ? 'showmessage()' : 'submittoserver()'}"
i dont have richfaces-ready playground (by way, never used richfaces either), can't test, should trick !
Comments
Post a Comment