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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:17:08+00:00 2026-05-26T07:17:08+00:00

I have a JSF facelets page that displays a table of data depending on

  • 0

I have a JSF facelets page that displays a table of data depending on which page they are viewing. When I display page 1, I call the view() action method to get the data from the database for both pages and store it as a private member field of the bean (two arrays). I also call conversation.start() on the injected conversation instance in the view() method.

When the user clicks the “next” button (h:commandButton) to go to page 2, I am executing a next() method to update the backing bean to point to array 2 so it will print out its contents. The problem is, array 2 no longer exists. I don’t know why I am losing conversation scope. Any ideas?

//tells the object which page we are on, and thus what data to display.
private int part = 1; 

// These arrays are filled with data but conversation scope doesn't 
// keep them on the next postback.
private int[] part1 = new int[15], part2 = new int[15];
  • 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-26T07:17:09+00:00Added an answer on May 26, 2026 at 7:17 am

    You should paste some more code so we can help you better.
    From what you say i cannot see where you called the method for ending the conversation(You need that too when working with conversation scope).

    I will paste here a little example that i think will help you understand how conversation scope works:

    This is the start page of a wizard(Conversation scope is great for wizards)

    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core">
    
    <h:head>
        <title>ConversationScoped demo CDI(Component Dependency
        Injection)</title>
    </h:head>
    
    <h:body>
    
    
    
        <h3>ConversationScoped demo CDI(Component Dependency Injection)</h3>
    
        <p>A conversation scope provides persistence until a goal is
        reached<br />
        In this example the first entered value will remain until the end
        method is called<br />
        in some page.<br />
        This is a really useful gadget, for making registration wizards and
        similar tools...</p>
    
        <h:form>
            <h:outputText value="Type something" />
            <h:inputText value="#{ supportBB.someValue}" />
            <h:commandButton value="continue" action="#{ supportBB.onClick}" />
        </h:form>
    
    </h:body>
    </html>
    

    This is the second page of the wizard

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core">
    
    <h:head>
        <title>ConversationScoped demo CDI(Component Dependency
        Injection)</title>
    </h:head>
    
    <h:body>
    
    
    
        <h3>This is the next page(The value is saved in the conversation)</h3>
    
            <h4><h:outputText value="#{ supportBB.someValue}"/></h4>
    
        <h:form>        
            <h:commandButton value="Finish conversation" action="#{ supportBB.onKeepGoing}"/>
        </h:form>
    
    </h:body>
    </html>
    

    And this is the page where the scope ends

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core">
    
    <h:head>
        <title>ConversationScoped demo CDI(Component Dependency
        Injection)</title>
    </h:head>
    
    <h:body>
    
    
    
        <h3>This is the last page.The value still saved in conversation(until the end() method is called)</h3>
    
        <h4><h:outputText value="#{ supportBB.someValue}" /></h4>
    
        <h:form>
            <h:outputText
                value="Click finish to end the conversation(So saved values are disposed)" />
            <h:commandButton value="Finish" action="#{ supportBB.onFinish}" />
        </h:form>
    
    </h:body>
    </html>
    

    Here the @ConversationScoped backing bean that starts and ends the conversation

    package backingbeans;
    
    import java.io.Serializable;
    
    import javax.enterprise.context.Conversation;
    import javax.enterprise.context.ConversationScoped;
    import javax.inject.Inject;
    import javax.inject.Named;
    
    @Named()
    @ConversationScoped()
    public class SupportBB implements Serializable {
        private static final long serialVersionUID = 1L;
        private String someValue;
        @Inject
        private Conversation conversation;
    
        // Control start and end of conversation
        public void start() {
            conversation.begin();
        }
    
        public void end() {
            conversation.end();
        }
    
        // Navigation
        public String onClick() {
            if(someValue.equals("") || conversation == null) {
                return "";//Dont go anywhere if the there was no input the field
            }
            start();
            return "nextpage?faces-redirect=true";
        }
    
    public String onKeepGoing() {
        return "finish?faces-redirect=true";
    }
    
    public String onFinish() {
        end();// If triggered when there is no conversation(i.e URL Navigation)
                // there will be an exception
        return "index?faces-redirect=true";
    }
    
    // Getters & Setters
    public String getSomeValue() {
        return someValue;
    }
    
    public void setSomeValue(String someValue) {
        this.someValue = someValue;
    }
    
    }
    

    I think this example is very simple and can help you understand how it works. Ask if you don’t understand something

    NOTE:

    I think but i am not sure at 100% but ConversationScope only works if the backing bean is a CDI bean. This mean uses the annotation @Named. Better double check that.

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

Sidebar

Related Questions

I have a JSF page that displays a RichFaces Treeview, from a TreeNodeImpl model
In my JSF page I have a combobox that updates a table when an
I have a problem with my facelets: I constricted a nav part that displays
In my .xhtml page, I have the following form: <ui:composition xmlns:ui=http://java.sun.com/jsf/facelets template=./../template/CustomerTemplate.xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:f=http://java.sun.com/jsf/core
I'm building a JSF+Facelets web app, one piece of which is a method that
I have a JSF page which has a variable number inputText elements containing numeric
I have a JSF page which is outputting XHTML (from a facelet). One of
I'm using JSF 1.2 with Richfaces and Facelets. I have an application with many
Using Richfaces 3.3.0GA, jsf 1.2_14 and facelets. I have a richfaces ModalPanel with an
I have a JSF application that uses mostly Richfaces. I would like to introduce

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.