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

  • Home
  • SEARCH
  • 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 6375341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:36:09+00:00 2026-05-25T01:36:09+00:00

I have a JSF page where users can enter their car into my database.

  • 0

I have a JSF page where users can enter their car into my database. The form has three input fields:

  • Manufacturer
  • Model
  • Registration

The Manufacturer and Model field are both autocompletion fields. In order to complete the Model field, I need to know what value the user selected in the Manufacturer field prior to submitting the form. To that end, I set up an AJAX call to inform the managed bean of the selected value:

<p:autoComplete id="manufacturer"
                minQueryLength="3"
                completeMethod="#{carController.complete}"
                forceSelection="true">
   <p:ajax event="itemSelect"
           listener="#{carController.manufacturerSelected}" />
</p:autoComplete>

And in the managed bean:

public void manufacturerSelected(SelectEvent se) {
    manufacturer = se.getObject().toString();
}

The autocomplete field and handler method for the model look about the same, with slighly different values.

To retain the manufacturer value across the multiple XHR requests, I have set the bean to ConversationScoped and begin the conversation in a @PostConstruct annotated method:

@Named
@ConversationScoped
public class CarController implements Serializable {

@Inject
private Conversation conversation;

@PostConstruct
private void init() {
    conversation.begin();
}

What I would expect is the bean getting only instantiated once for the page because the conversation has not been ended yet, and retaining the value in the manufacturer field. This, however, does not hold true, and the bean is instantiated again for each XHR request, causing the manufacturer field to be null as well. Setting a breakpoint in the PostConstruct method revealed that it is in fact getting called and so is the manufacturerSelected method.

I suspect this has something to do with the fact that I am not manually propagating the conversation ID but the documentation says that this ID should automatically be propagated with any faces request. Is this in fact true, and, does that mean that XHR requests are not necessarily faces requests?

Edit: Setting breakpoints at various locations in the bean has revealed that each XHR request has a new bean (conversation.getId() keeps changing) so I am obviously not propagating the ID right. How would one propagate the ID with p:ajax and where can I get it with EL?

  • 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-25T01:36:10+00:00Added an answer on May 25, 2026 at 1:36 am

    Since you’re not really using a conversation (at least not in the example you give), why not use the view scope? This will do exactly what you want, without the overhead of having to propogate a conversation id.

    Do note that for @ViewScoped to work, you have to change the bean to a JSF managed bean (remove @Named). This is due to a design bug/spec oversight in Java EE 6. If you want to keep using CDI, then there’s a Java EE 6 extension from Seam 3 available that fixes this bug.

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

Sidebar

Related Questions

I have a form in my jsf page(a popup) that I used to upload
I have a small JSF application where the user is required to enter some
I am having issues with JSF/ADF/PPR on refreshing the page incorrectly. I have a
I am creating a JSF application. I have some items (e.g. products) from database
I try to create login form in web application. in JSP page I can
I have a JSF Page which gets few inputs from the User, I want
I have a JSF 2.0 application running on GlassFish v3. It has EJBs that
I have a login.jsp page which contains a login form. Once logged in the
I have a web-application where the users can be sent directly to some specific
Let's say that I have an application which manages users. You can add new

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.