@ViewScoped object is destroyed even if the same JSF page is displayed

Solution Unverified - Updated -


I have JSF application using javax.faces.view.ViewScoped object like the following. However, the ViewScoped bean is destroyed after the action even if the same JSF page is displayed. How do I keep the ViewScoped bean on the same page?

  • example.xhtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:jsf="http://xmlns.jcp.org/jsf">
<head jsf:id="head">
<meta charset="UTF-8" />
    <form jsf:id="form" jsf:prependId="false">
        <input type="submit" jsf:action="#{exampleBackingBean.execute(download)}" value="click" />
  • ExampleBackingBean.java
public class BackingBean implements Serializable {

    ExampleFileList filelist;

    public String execute(String action) throws Exception {
       if (action.equals("download") {
          // application processing against the filelist object like file download...

          // back to the same example.xhtml
          return "example.xhtml";
       } else { 
          // other application processing ...
          return "other.xhtml";
  • ExampleListBean.java
@Named(value = "list")
public class ExampleFileList implements Serializable{
    List<String> file = new ArrayList<String>();

    public void init(){
        // initialize file list

    public List<String> getFile() {
        return file;

    public void setFile(List<String> file) {
        this.file = file;


  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
  • JSF

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In