0

I'm creating a jsf page with primefaces commandButton, this button will be rendered based on viewParam passed for the page. If viewParam is true commandButton will be shown, otherwise not. I'm calling a method from this commandButton using action attribute. My method is not calling and no errors are shown in the page. If I call a method without 'rendering' attribute it works fine.

Am using CDI bean with request scope and following configurations :primefaces 5.0, JSF 2.2, Glassfish Server 4.1. My 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:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Facelet Title</title>
     </h:head>
    <h:body>
        <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                        xmlns:ui="http://java.sun.com/jsf/facelets"
                        xmlns:f="http://java.sun.com/jsf/core"
                        template="TopLayout.xhtml">
            <ui:define name="metaData">
            <f:metadata>
                <f:viewParam name="showButton" value="#{chartView.showButton}" />
            </f:metadata>
        </ui:define>
            <ui:define name="content">
                <p:messages autoUpdate="true"/>
                <h:form>
                    <p:commandButton value="Submit" action="printInvoice" rendered="#{chartView.showButton}"
                                     ajax="false"/>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
Roudhran
  • 23
  • 1
  • 7
  • 2
    There is no bean referenced in `commandButton` `action` attribute. If `printInvoice` is a method of `chartView` it should be `action="#{chartView.printInvoice()}"`. Just wondering if this can work. Also wondering: `rendered="#{chartView.showButton}"`. This has nothing to do with the `viewParam`, isn't it? – opfau Dec 01 '15 at 12:52
  • And if 'action' is just meant to be loading a page, you 'abuse' a commandButton. In addition check the value of the rendered attribute when server side when it is evaluated. Tried with `rendered="true"`? – Kukeltje Dec 01 '15 at 13:15
  • Possible duplicate of [commandLink/commandButton/ajax backing bean action/listener method not invoked](http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked) – Mahendran Ayyarsamy Kandiar Dec 01 '15 at 17:46

0 Answers0