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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:50:42+00:00 2026-06-06T22:50:42+00:00

I have a session scoped managed bean called MyController. It has a reference to

  • 0

I have a session scoped managed bean called MyController. It has a reference to a POJO called MyModel. MyModel contains an ArrayList of some other POJOs which I bind to a p:orderlist like this:

                <p:orderList value="#{myController.myModel.list}" var="item" itemValue="#{item}" converter="#{itemConverter}"">
                    <f:facet name="caption">some title</f:facet>

                    <p:column>
                        #{item.text}
                    </p:column>
                </p:orderList>

My converter looks like this:

@ManagedBean
@RequestScoped
public class ItemConverter implements Converter {

    @ManagedProperty(value="#{myController.myModel.list}")
    private List<Item> list;


    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Iterator i = list.iterator();
        int id = Integer.parseInt(value);

        while (i.hasNext()) {
            Object currentObject = i.next();
            if (((Item) currentObject).getId() == id) {
                return currentObject;
            }
        }

        return null;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return Integer.toString(((Item) value).getId());
    }

}

I have built an interface and methods in myController to dynamically add items to the orderlist. When I first add an item, it seems to work fine, the list is updated and shows the new item. However, when I add the second item, the dialog that contains the list disappears and cannot be shown even by calling its show() method from JavaScript console. By debugging, I have discovered that when adding the second item, my list has become ArrayList of String instead of ArrayList of Item as it was declared and defined. It contains the String that would be returned by getAsString() method of my converter for the first item I have added to the list. Naturally, adding the second item fails since I’m trying to add an Item to a List of Strings.

How is this possible? I thought Java would never allow a List of Item to be replaced by List of String. Is it even possible to use orderlist without having it overwrite the source list with it’s own list of strings? Isn’t the job of converter to convert those strings back to objects in the first place? Would it be possible to construct orderlist on server side from List of Items and then use the binding attribute and value attribute to map to another List of String? If it is possible, how would I construct the orderlist on the server side?

EDIT: Fixed a problem with double call of i.next() in getAsObject(), but still getting a list of strings. Also, trying to manually instantiate the converter with context.getApplication().evaluateExpressionGet(context, "#{itemConverter}", itemConverter.class); returns null.

  • 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-06T22:50:44+00:00Added an answer on June 6, 2026 at 10:50 pm

    The cause of my problem was a wrong import. I imported javax.annotations.ManagedBean instead of import javax.faces.bean.ManagedBean. So, if someone ends up on this page by googling for a solution to their problem, check your imports first.

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

Sidebar

Related Questions

I have a JSF 2.0 application(App#1) that has a managed Session Scoped bean that
I have a session scoped managed bean, with a property current . If I
I have a session scoped managed bean with name 'usermanager'. i want to store
i have an managed bean(session scope) like this: class Home {// as homeBean public
I have a Controller bean (SearchController) that has two managed bean as managed properties
I have a Session scoped bean @SessionScoped public class UserData implements Serializable { private
Is it possible in JSF 2 to initialize a session-scoped managed bean as soon
I have a session bean <managed-bean> <managed-bean-name>vdcAddBean</managed-bean-name> <managed-bean-class>com.cloud.appsportfolio.jsf.vdc.beans.VDCAddBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> Now, I am injecting
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
I have a managed bean declared in session scope. There is a drop down

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.