JSF渲染弹出窗口是一个manegbean条件?

时间:2015-05-08 13:36:56

标签: jsf jsf-2 popup richfaces

我正在使用它在发生错误时在登录时显示一条消息:

<a4j:region rendered="#{usuario.fail == 1}">
            <div class="alert alert-danger alert-dismissable"
                style="width: 470px; margin: 10px auto;">
                <button type="button" class="close" data-dismiss="alert"
                    aria-hidden="true">&times;</button>
                Invalid user or password.
            </div>
        </a4j:region>

但是,我想要显示一个弹出窗口,但是,这不起作用,我正在尝试这样的事情:

<h:outputScript rendered="#{usuario.fail == 1}">
            #{rich:component('popup')}.show();
        </h:outputScript>

        <rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
                <f:facet name="header">
                    <h:outputText value="Simple popup panel" />
                </f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); return false;">
                        X
                    </h:outputLink>
                </f:facet>
                <p>Any content might be inside this panel.</p>

                <p>
                    The popup panel is open and closed from the javascript function of component client side object. The following code
                    <a href="#" onclick="#{rich:component('popup')}.hide()">hide this panel</a>:
                    <f:verbatim>&#35;</f:verbatim>{rich:component('popup')}.hide()
                </p>
            </rich:popupPanel>

我正在尝试这个例子:

Simple popup example

有没有办法从manegedbean的回归中显示弹出窗口?

提前致谢!

1 个答案:

答案 0 :(得分:5)

您在创建popupPanel之前调用该函数,这就是您获取未定义错误的原因。

您不必渲染JS功能以显示面板,但您可以只显示面板:

<rich:popupPanel id="popup" show="#{usuario.fail == 1}" …>
    …
</rich:popupPanel>