JSF Richfaces modalPanel

时间:2015-12-13 13:07:40

标签: jsf richfaces jsf-1.2

我有一个按钮,当我点击打开的模态面板时 - 它工作正常。现在我尝试添加一个按钮来隐藏面板 - 它的工作也是如此,但问题是我试图显示文本"面板关闭"点击按钮后它不起作用。我使用Jsf 1.2和richfaces 3.3.3。

我有以下错误消息:

  

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

代码上方

的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>

面-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 个答案:

答案 0 :(得分:0)

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

顺便说一句,您的代码显示您正在使用let height = items[indexPath.row].boundingRectWithSize(CGSizeMake(CGFloat.max,UIScreen.mainScreen().bounds.size.width), options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: font!], context: nil).size.height (这是正确的),但例外情况表明您只使用setShowText(true),那么它就是吗?