How can I reload the same page from a managedBean in JSF?

后端 未结 2 1559
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 13:44

Im implementing a login in a JSF application and have a problem with the redirection.

I want to make available the login form in every xhtml in the app, but after th

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 14:10

    As far as i am concern there is 2 ways for this purpose.

    1. You should define the components which need to be updated in update attribute of caller commandButton.
    2. You should do a real refresh by adding ?faces-redirect=true to return value of action.

    First solution.

    
                        
                            
                            

    Bienvenido #{loginBean.nombreUsuario}!!

    the update attribute will update the components.

    Second solution

    Add ?faces-redirect=true to your return value of action method for a real refresh

    public String login(){
    
        currentUser = gu.login(usuario, password);
    
        return "login?faces-redirect=true";
    }
    

提交回复
热议问题