2012-01-01 10 views
0

JSF 2.0でログインに成功すると、ナビゲーションバーが表示されます。ここに私のlogin.xhtmlファイルの一部です。 ナビゲーションバーは、hereと表示されるPrimefacesコンポーネントです。ログイン成功時にnavigationBar(primefaces)を表示する方法(JSF 2.0)

表示されているとおり、方法をトリガーするとナビゲーションバーが表示されます。topBar.show() ログインに成功したらどうすればいいですか?

<h:form> 
    <p:messages showDetail="false" /> 
    <h:panelGrid columns="2"> 
     <h:outputLabel for="pseudo" value="#{i18n.Pseudo}" /> 
     <h:inputText id="pseudo" label="#{i18n.Pseudo}" required="true" value="#{loginController.grimpeur.login}" 
     maxlength="128" /> 
     <h:outputLabel for="password" value="#{i18n.Password}:" /> 
     <h:inputSecret id="password" value="#{loginController.grimpeur.password}" /> 
    </h:panelGrid> 
    <h:commandButton type="submit" action="#{loginController.processLogin}" value="#{i18n.Ok}" /> 
    <h:commandButton type="button" value="#{i18n.Password_forgotten}" onclick="dlg.show();" /> 
    </h:form> 

    <p:notificationBar position="top" effect="slide" widgetVar="loginBar" styleClass="top"> 
    <h:graphicImage value="#{loginController.grimpeur.login}/#{loginController.grimpeur.avatar}" width="80" height="70" 
     title="avatar" /> 
    <h:outputFormat id="logged_in_msg" value="#{i18n.Welcome_logged_in_user}" style="color:#FFCC00;font-size:36px;"> 
     <f:param value="#{loginController.grimpeur.login}" /> 
     <f:param value="#{i18n.Climbing}" /> 
    </h:outputFormat> 
    </p:notificationBar> 

答えて

3

私はあなたがPrimeFaces v3.0.RC2のRequestContextとそれを実現することができると思います。これは次のようなものでなければなりません。

<p:notificationBar widgetVar="bar"> 
    <h:outputText value="You have successfully log in!" /> 
</p:notificationBar> 

<p:commandButton type="submit" actionListener="#{loginController.processLogin}" 
       value="#{i18n.Ok}" /> 

@ManagedBean 
@RequestScoped 
public class LoginController { 
    public void processLogin(ActionEvent actionEvent) { 
     boolean successful; 
     // process your login here 

     if (successful) { 
     RequestContext context = RequestContext.getCurrentInstance(); 
     context.execute("bar.show();"); 
     } 
    } 
} 
+0

ありがとうございました。それは仕事でした;) – paissad

+0

よろしくお願いします! :P –

関連する問題