JSF rendering popup frow a manegbean condition?

I´m using this for show a message in login when a error happens:

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

But, I want to show a popup, however, this is not working, i'm trying somethings like this:

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

I'm trying this example:

Simple popup example

Are there a way to show a popup from a manegedbean's return ?

Thanks in advance !

Answers


You're calling the function before the popupPanel is created, that's why you're getting the undefined error.

You don't have to render a JS function in order to show the panel though, you can just show the panel:

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

Need Your Help

Counting number of documents

python path count operating-system

I have a corpus, and I need to count the number of documents and tokens in the corpus as a whole, but also its subparts.

Jquery slider to change interval on refresh script

javascript jquery jquery-ui

i'm using this piece of code to refresh my div every X seconds:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.