1

I need to register an user and after that I would like to call a <rich:popupPanel> for example to show the error or successful message with an icon.

<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>
</rich:popupPanel>

How do I do that after the validation of the register process in my controller ? I could call a <h:message>, but I think a popupPanel with some icon and the status message would be more appropriate to the user.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Valter Silva
  • 16,446
  • 52
  • 137
  • 218

1 Answers1

1

In general, you'd just set some (boolean) toggle or a specific object property in the bean's action method which is then used in the rendered attribute of the containing component in question. Here's an example with a simple boolean:

private boolean success;

public void submit() {
    // ...

    success = true;
}

public boolean isSuccess() {
    return success;
}

with

<rich:popupPanel rendered="#{bean.success}">
     ...
</rich:popupPanel>

You can also set some object property and then check if it is not empty or null. E.g. when the User is successfully saved after registration and thus got an ID from the DB:

<rich:popupPanel rendered="#{not empty bean.user.id}">
     ...
</rich:popupPanel>

Note: in the particular case of your <rich:popupPanel>, you can also use the show attribute instead of rendered attribute.

<rich:popupPanel show="#{bean.success}">
     ...
</rich:popupPanel>

The only difference is that when show is false, the component is still rendered, but then with CSS display:none; so that it is visually hidden in the HTML DOM tree, so that you can redisplay it with just JavaScript.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • thanks for you help. But now if I put this success in a SessionScope, it always apperars the box.. any idea how I show the message to the user after his sign up and then after set to false the success attribute ? – Valter Silva Nov 02 '11 at 00:30
  • Don't put request/view scoped data in the session scope. Put request/view scoped data in the request/view scope. See also http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ManagedBeanScopes – BalusC Nov 02 '11 at 00:36
  • Thank you mate, you gave a an insight =] , you're the best – Valter Silva Nov 02 '11 at 01:00