Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 209765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:56:42+00:00 2026-05-11T17:56:42+00:00

Ok simple question. I have a JSF application, containing a login page. The problem

  • 0

Ok simple question. I have a JSF application, containing a login page. The problem is if the user loads the login page, leaves it for a while, then tries to login the session expires and a ViewExpiredException is thrown. I could redirect back to the login when this happens, but that isn’t very smooth. How can I allow this flow to properly login without an additional attempt?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:56:42+00:00Added an answer on May 11, 2026 at 5:56 pm

    Update

    As of Mojarra 2.1.19 / 2.2.0 you can now set the transient attribute of the <f:view> to true:

    <f:view transient="true">
         Your regular content
    </f:view>
    

    You can read about in on Balusc’s blog here:

    http://balusc.blogspot.com.br/2013/02/stateless-jsf.html

    Original

    If you’re using Facelets you can create your own ViewHandler to handle this:

    public class LoginViewHandler extends FaceletViewHandler
    {
        public LoginViewHandler( ViewHandler viewHandler )
        {
            super( viewHandler );
        }
    
        @Override
        public UIViewRoot restoreView( FacesContext ctx, String viewId )
        {
            UIViewRoot viewRoot = super.restoreView( ctx, viewId );
    
            if ( viewRoot == null && viewId.equals( "/login.xhtml" ) )
            {
                // Work around Facelet issue
                initialize( ctx );
    
                viewRoot = super.createView( ctx, viewId );
                ctx.setViewRoot( viewRoot );
    
                try
                {
                    buildView( ctx, viewRoot );
                }
                catch ( IOException e )
                {
                    log.log( Level.SEVERE, "Error building view", e ); 
                }
            }
    
            return viewRoot;
        }
    }
    

    Change “/login.xhtml” to your login page. This checks to see if it can restore your view, and if it cannot and the current view is your login page it will create and build the view for you.

    Set this in your face-config.xml as follows:

    <application>
        <!-- snip -->
        <view-handler>my.package.LoginViewHandler</view-handler>
    </application>
    

    If you’re using JSF without Facelets (i.e. JSPs) you can try having the class extend ViewHandlerWrapper – note that buildView() will not be available. Hopefully createView() on it’s own will set the view up correctly but I’m not 100% sure with JSF/JSP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to JSF and have a problem with my simple JSF application.
I have created a simple JSF application, now must to connect to SQL Server
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
This is a (hopefully) really simple question - I have been told recently that
Simple question: do I have to delete or delete [] c ? Does the
Pretty simple question: When i have a persistable object, it usually has a property
I have a very simple question. I want to test whether a particular port
I have a simple question. Is there a way ( using reflections I suppose
I have a simple question and wish to hear others' experiences regarding which is
I have a simple question related to one-line programming. First an example: function test(a)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.