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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:16:45+00:00 2026-05-24T17:16:45+00:00

I am writing a JSF 2.0 application, and I want to use CDI annotations

  • 0

I am writing a JSF 2.0 application, and I want to use CDI annotations instead of the “equivalent” JSF annotations. In other words, @Model or @Named instead of @ManagedBean, and @Inject instead of @ManagedProperty.

The only thing I cannot get to work is @ViewScoped which is necessary for AJAX components. The only reliable work-around is to use @SessionScoped, which is not a good practice.

What is the correct practice? As much as I search I just get more confused.

This is on GlassFish 3.1.1, which I understand has Weld 1.1.0 in it.

UPDATE: The original form of this question said that I could not get @ConversationScoped to work. Since then I found my error and I did get it to work like so:

@Model
@ConversationScoped
public class Abean implements Serializable {

@Inject Conversation conversation;

// stuff omitted for brevity

public String getSomething() {
    if (conversation.isTransient()) conversation.begin();
    return "something";
}

This seems to do the trick. However now my question is changed. Where exactly are you supposed to call conversation.end()? Do I have to write a filter to detect when the user leaves the page? Or if it is left alone, just when would the Abean instance be de-referenced?

SECOND UPDATE: A very good discussion of CDI’s @ConversationScoped I found here.

I am still left with the problem of how to call conversation.end(). My bean provides stateful backing to a data table browser updated via AJAX, and the optimal place to call end() is when the user navigates away from the page. However short of writing a filter to monitor the pages I don’t really see any way of doing that. Any suggestion of “best practice” is welcome.

  • 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-24T17:16:46+00:00Added an answer on May 24, 2026 at 5:16 pm

    That’s way simpler with the (CDI) scopes of MyFaces CODI. They have a better @ConversationScoped and you will love the @ViewAccessScoped for what you are trying.

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

Sidebar

Related Questions

I'm writing a JSF 2.0 application with Hibernate and Postgresql database. My problem is
I'm writing a JSF 2.1 web application, which is hosted by Tomcat 6. At
I am writing a web application using JSF 2. I have downloaded mojarra-2.1.3-FCS-binary.zip and
i am writing a web application with jsf 2.0 and using primefaces framework. i
when searching for solutions to problems I have writing a JSF 2.0 application, 99%
I have weird problem. I'm using Eclipse for writing J2EE (java, jsf, javascript) application
Writing a dictionary application for android. Want to set translation direction in accord with
I am writing a web application (While learning JSF from scratch, and thanks to
I'm writing an application in JSF 2.0 which supports many languages, among them ones
Writing some test scripts in IronPython, I want to verify whether a window is

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.