1

I add the following lines to web.xml

<session-config>
    <session-timeout>1</session-timeout>
</session-config>

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/login/login.xhtml</location>
</error-page>

to redirect to login page when the session expires and it is in fact redirecting but the fields name and password and the button "fazer login" disappear: enter image description here enter image description here

Heres the relevant code in the login page:

<div class="conteudo">
    <div class="icone-produto"></div>
    <div class="coluna-direita">
        <div class="logo-produto" alt="Wplex-EP"></div>
        <div class="card signin-card">

            <h:panelGrid columns="1">

                <h:dataTable value="#{funcionarioController.lista}"
                    rendered="false"></h:dataTable>
                <h:dataTable value="#{escalaController.lista}" rendered="false"></h:dataTable>
                <h:dataTable value="#{indisponibilidadeController.lista}"
                    rendered="false"></h:dataTable>
                <h:dataTable value="#{programacoesController.programacoes}"
                    rendered="false"></h:dataTable>
                <h:dataTable value="#{funcionarioController.lista}"
                    rendered="false"></h:dataTable>

                <h:inputText class="texto" placeholder="Usuário" 
                    value="#{loginController.login}" />
                <h:inputSecret class="texto" placeholder="Senha" 
                    value="#{loginController.senha}"/>

                <h:commandLink id="fazerLoginId" action="#{loginController.isLoginOk}"
                    styleClass="btn btn-wplex mouseon">
                    Fazer Login
                </h:commandLink>

            </h:panelGrid>
        </div>
    </div>
</div>
Tiny
  • 27,221
  • 105
  • 339
  • 599
StudioWorks
  • 483
  • 1
  • 6
  • 25

1 Answers1

3

The disappearing elements are actually all JSF components. This part,

<location>/login/login.xhtml</location>

must match the <url-pattern> of the FacesServlet entry in the very same web.xml in order to get it to parse the XHTML and render the JSF components as HTML. Apparently you don't have any one on *.xhtml. Perhaps it's *.jsf or /faces/*. You'd need to alter the <location> accordingly to match the <url-pattern> of the FacesServlet, so that it gets invoked. E.g. in case of *.jsf:

<location>/login/login.jsf</location>

An alternative is to just use an <url-pattern> of *.xhtml, so that you never need to fiddle and get confused with virtual URLs.

<servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I see, my is *.jsf so it must be it. Where should I look if wanna go deeper on this subject (what these tags mean, how web.xml and jsf work with each other, etc)? – StudioWorks Sep 22 '14 at 17:28
  • 1
    Just take a step back and learn basic servlets. http://stackoverflow.com/tags/servlets/info – BalusC Sep 22 '14 at 18:01