2 Replies Latest reply on May 1, 2009 9:20 AM by Michael Hughes

    a4j:jsFunction - Problems With Action Parameter Creating Con

    Michael Hughes Newbie

      Hi,

      On my project we desparately need to use confirmation dialogues e.g. Confirm Yes/No? before an action is submitted (like deleting a row in a datatable). I have tried to implement Mike Katz's confirmation dialogue http://www.jsfone.com/blog/max_katz/2008/11/richfaces_confirmation_dialog_2__custom_tag.html as a custom tag but the problem is passing in an action to the custom tag to be submitted.

      Here is my custom tag implementation "confirmation.jspx" :

      <?xml version="1.0" encoding="UTF-8" ?>
      <ui:component 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">
      
      <a4j:commandButton value="#{value}"
       onclick="#{rich:component('confirmation')}.show();return false"
       styleClass="#{styleClass}"
       binding="#{binding}"
       />
      
      <a4j:jsFunction name="submit" reRender="#{reRender}" action="#{action}"/>
      
      <rich:modalPanel id="confirmation" width="250" height="160">
       <f:facet name="header">#{header}</f:facet>
       <f:facet name="controls">
       <h:panelGroup>
       <h:graphicImage id="hidelink"
       styleClass="hidelink"
       value="/images/RSM_WinIcon_Close_def.gif"
       />
       <rich:componentControl for="confirmation"
       attachTo="hidelink"
       operation="hide"
       event="onclick"
       />
       </h:panelGroup>
       </f:facet>
      
       <h:panelGrid>
       <h:panelGrid columns="2">
       <h:graphicImage value="/images/exclamation.jpg" height="40" width="40"/>
       <h:outputText value="#{message}" style="FONT-SIZE: medium;" />
       </h:panelGrid>
      
       <h:panelGroup>
       <rich:spacer height="40px" />
       <input type="button"
       value="#{button1Value}"
       onclick="#{rich:component('confirmation')}.hide(); submit();return false;" />
       <input type="button"
       value="#{button2Value}"
       onclick="#{rich:component('confirmation')}.hide();return false" />
       </h:panelGroup>
       </h:panelGrid>
      </rich:modalPanel>
      </ui:component>


      The parameter
      action="#{action}"
      is the key to the problem.

      Here's the stack trace error I get:
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      javax.el.PropertyNotFoundException: /WEB-INF/tags/confirmation.jspx @15,74 action="#{action}": /pages/content/admin/currency/currencyDataTable.jspx @99,20 action="#{currencyDataTableController.onDeleteButtonClicked}": Property 'onDeleteButtonClicked' not found on type com.cognotec.rslm.war.admin.currency.CurrencyDataTableController
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:70)
       at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
       at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
       at javax.faces.component.UICommand.broadcast(UICommand.java:387)
       at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
       at org.ajax4jsf.component.UIInclude.broadcast(UIInclude.java:168)
       at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
       at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
       at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
       at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       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:128)
       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:286)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      


      ...and this is how I implement my custom tag:
      <richx:confirm value="Delete"
       styleClass="commandButton"
       reRender="currencyDataTable"
       binding="#{currencyDataTableController.deleteButton}"
       action="#{currencyDataTableController.onDeleteButtonClicked}"
       button1Value="OK"
       button2Value="Cancel"
       header="Confirm Delete"
       message="Are you sure you want to delete this currency?"
       />


      The method I am trying to execute is:
      action="#{currencyDataTableController.onDeleteButtonClicked}"


      If I modify "confirmation.jspx" to submit the method directly ie:
      action="#{currencyDataTableController.onDeleteButtonClicked}"


      It works fine and the method is executed when the user clicks ok. In Mike Katz's example code he has the action hardcoded in the custom tag which limits its use greatly.

      Any help from anybody would be much appreciated as dialogue boxes are an integral part of many UIs.

      Michael