【问题标题】:JSF Richfaces modalPanelJSF Richfaces modalPanel
【发布时间】:2015-12-13 13:07:40
【问题描述】:

我有一个按钮,当我单击打开的模式面板时 - 它工作正常。现在我尝试添加一个按钮来隐藏面板 - 它也可以工作,但问题是当我尝试在按钮单击后显示文本“面板关闭”时它不起作用。我使用 Jsf 1.2 和 Richfaces 3.3.3。

我收到以下错误消息:

org.apache.jasper.el.JspELException: /index.jsp(35,7) 'javascript:Richfaces.hideModalPanel('myModalPanel');#{welcomeBean.showText(true)}' 找不到方法:com 类.firstjsf.backingbeans.WelcomeBean.showText(java.lang.Boolean) at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:123)

代码上方:

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;
    }
}

【问题讨论】:

    标签: jsf richfaces jsf-1.2


    【解决方案1】:

    您正在混合 JavaScript 和 EL 表达式,@oncomplete 用于执行 JavaScript,如果您想在服务器上执行某些操作,请使用 @action 或 @actionListener。否则表达式将被计算并且浏览器将尝试执行返回值,就像它是 JavaScript 一样。

    顺便说一句,您的代码显示您正在使用setShowText(true)(这是正确的),但异常表明您只使用showText(true),那么它是什么?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 2011-07-02
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 2010-10-10
      • 1970-01-01
      相关资源
      最近更新 更多