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 7792749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:16:54+00:00 2026-06-01T22:16:54+00:00

Basically the same question as here How do I retain a ViewScoped bean on

  • 0

Basically the same question as here

How do I retain a ViewScoped bean on the page from which I redirect to a different browser tab:

firstPage.xhtml:

<h:commandLink action="#{controller.redirect}" value="#{bean.value} target="_blank"/>

When redirect/navigation finishes with initializing the other beans, it destroys this #{bean} in the process. In the redirected code I am not even using #{bean}. This used to work with

<a4j:keepAlive>

Here’s my current setup.
bean class:

@ViewScoped
public class Bean{ 
    @PreDestroy
    public void onDestroy(){ // being destroyed when I don't want to }
}

faces-config:

<navigation-rule>
  <from-view-id>/firstPage.xhtml</from-view-id>
    <navigation-case>
      <from-outcome>redirect</from-outcome>
      <to-view-id>/secondPage.xhtml</to-view-id>
  </navigation-case>
</navigation-rule>
  • 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-06-01T22:16:56+00:00Added an answer on June 1, 2026 at 10:16 pm

    You need to do as Luiggi suggested and store data temporarily in the session or pass the data (or keys sufficient to re-fetch the data) via query parameters to the target view. This is the case even if you weren’t redirecting and/or targeting a new window/tab.

    View scope is strange. It exists only as long as the user stays on the same view. When JSF sees that the view has been navigated away from, it will automatically destroy any beans scoped to that view.

    There are two ways that you can navigate to a different view. The first is a non-faces request, such as from h:link or h:button. In this case, the previous view is not being restored so JSF wouldn’t know that there are any view-scoped beans to destroy. The second is a faces request, such as from h:commandLink or h:commandButton, that returns something other than void or null. In this case, there is a postback to the view, which is restored in order to process the action. If the result of that action is to navigate away from that view, redirect or not, any beans scoped to that view will be destroyed.

    Under the hood, view scope is essentially session scope with some built-in semantics for cleaning up “old” data. This actually works well if users don’t open the application in more than one window/tab and only use navigation provided within the application (i.e., not the browser back/forward buttons). However, since we’re talking about targeting web browsers, view scope is, in my opinion, pretty useless (with the only exception being cases where you can control the target browser and completely disable back/forward/reload/location, but it doesn’t sound like you’re in that kind of environment).

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

Sidebar

Related Questions

Basically, I have the same question as this one , which unfortunately never got
I got two gridviews in the same page, which basically displays the same type
This is basically the same question as Click items in select box, and then
I basically have the same question as this guy .. The example in the
I have basically the same problem outlined in this question, however I am using
Basically my question is the exact same one as this: Simple client/server, TCP/IP encrypting
I'm seeing basically the same issue described here I have a table that starts
I basically have the same question as bder on the actionscript.org forums , namely
I basically have the exact same problem as here: http://stackoverflow.com/questions/2416155/issue-in-executing-spring-web-project-in-eclipse-on-tomcat-server but the fix for
I found this question here: OLEDB v/s ODBC Which gave me more information, but

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.