title: How can I reload the same page from a managedBean in JSF?
body: <p>Im implementing a login in a JSF application and have a problem with the redirection.</p>
  
  <p>I want to make available the login form in every xhtml in the app, but after the login success or fail I want to keep the user in the same page they were when clicked on login.</p>
  
  <p>I have tried to return null in the managedBean methong but that doesnt work because it not refreshes the webPage, I need the page to be refreshed for the view logic to work.</p>
  
  <p>This is the login form:</p>
  
  <pre><code>&lt;h:form id="loginForm" rendered="#{!loginBean.estaLogueado()}"&gt;
                      &lt;p:panel header="#{msg.header_login}"&gt;
                          &lt;h:outputLabel for="login" value="#{msg.login}"/&gt;
                          &lt;p:inputText id="login" value="#{loginBean.usuario}"&gt;&lt;/p:inputText&gt;&lt;br/&gt;
                          &lt;h:outputLabel for="pwd" value="#{msg.password}"/&gt;
                          &lt;p:inputText id="pwd" type="password" value="#{loginBean.password}"&gt;&lt;/p:inputText&gt;&lt;br/&gt;
                          &lt;p:commandButton action="#{loginBean.login()}" value="Login"/&gt;
                      &lt;/p:panel&gt;
                  &lt;/h:form&gt;
                  &lt;h:form id="logoutForm" rendered="#{loginBean.estaLogueado()}"&gt;
  
                      Bienvenido #{loginBean.nombreUsuario}!!&lt;br/&gt;
  
                      &lt;p:commandButton action="#{loginBean.logout()}" value="Desconectar"/&gt;
  
                  &lt;/h:form&gt;
  </code></pre>
  
  <p>And this is the method in the action attribute:</p>
  
  <pre><code>public String login(){
  
      currentUser = gu.login(usuario, password);
  
      return null;
  }
  </code></pre>
  
  <p>There is a way to return to the xhtml where the user loged, not being a fixed xhtml like "login.xhtml"??</p>