0
votes

I have a button, when i click a modal panel opened - it's work fine. Now i tried to add a button to hide the panel - it's work also, but the problem is when i tried to show a text "panel closed" after button click it doesn't work. I use Jsf 1.2 and richfaces 3.3.3.

I have the following error message:

org.apache.jasper.el.JspELException: /index.jsp(35,7) 'javascript:Richfaces.hideModalPanel('myModalPanel');#{welcomeBean.showText(true)}' Method not found: class com.firstjsf.backingbeans.WelcomeBean.showText(java.lang.Boolean) at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:123)

above the code:

index.jsp

<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<f:view>
    <h:form>
        <rich:panel>
            <f:facet name="header">
                <h:outputText value="Product"></h:outputText>
            </f:facet>

            <h:form>
                <a4j:commandButton 
                    id="newWid" 
                    value="New Widget..."
                    immediate="true" ajaxSingle="true"
                    reRender="text"
                    oncomplete="javascript:Richfaces.showModalPanel('myModalPanel');"
                    styleClass="verboseButton noprint" />
            </h:form>

            <rich:modalPanel id="myModalPanel">
                <f:facet name="header">
                    <h:outputLabel value="123" />
                </f:facet> 

               From Modal Panel 

                <a4j:commandButton value="Hide" id="btn_hide"
                oncomplete="javascript:Richfaces.hideModalPanel('myModalPanel');#{welcomeBean.setShowText(true)}" />
            </rich:modalPanel>

          <h:outputText id="text" 
           value="Panel closed" 
            rendered="#{helloMessage.showText eq true}">
          </h:outputText>
        </rich:panel>
    </h:form>
</f:view>
</html>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
    <managed-bean>
        <managed-bean-name>welcomeBean</managed-bean-name>
        <managed-bean-class>com.firstjsf.backingbeans.WelcomeBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>helloMessageBean</managed-bean-name>
        <managed-bean-class>com.firstjsf.backingbeans.HelloMessageBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

    <navigation-rule>
        <description>Welcome page to message page</description>
        <from-view-id>/index.jsp</from-view-id>
        <navigation-case>
            <from-outcome>helloMessage</from-outcome>
            <to-view-id>/message.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>

     <navigation-rule>
        <description>Welcome page to message page</description>
        <from-view-id>/message.jsp</from-view-id>
        <navigation-case>
            <from-outcome>back</from-outcome>
            <to-view-id>/index.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

BeanAction

public class WelcomeBean {

    private boolean showText =false;

    public String sayHello(){
        return "helloMessage";
    }
    public boolean isShowText() {
        return showText;
    }

    public void setShowText(boolean showText) {
        this.showText = showText;
    }
}
1

1 Answers

0
votes

You're mixing JavaScript and EL expressions, @oncomplete is for executing JavaScript, if you want to do something on the server use @action or @actionListener. Otherwise the expression will be evaluated and the browser will try to execute the return value as if it was JavaScript.

By the way, your code shows you're using setShowText(true) (which is correct), but the exception says you're using just showText(true), which is it then?