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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:46:46+00:00 2026-06-15T04:46:46+00:00

My primefaces pickList source and target values do not change, I have followed the

  • 0

My primefaces pickList source and target values do not change, I have followed the example in primefaces showcase
and also looked at several posts here but still am not able to solve the problem. I am using a list from the database to populate the source as follows:

private DualListModel<Course> courseModel;
public CourseBean() {
    List<Course> target = new ArrayList<Course>();
    List<Course> source = new ArrayList<Course>();
    courseModel = new DualListModel<Course>(source, target);
}
...
//this DualListModel getter also populates the source with values from db
public DualListModel<Course> getCourseModel() {
    courseModel.setSource(getCourseList());
    return courseModel;
}

My converter is

import org.omnifaces.converter.SelectItemsConverter;

@FacesConverter("courseConverter")
public class CourseConverter extends SelectItemsConverter {
@Override
public String getAsString(FacesContext context, UIComponent component,
        Object value) {
    Integer id = (value instanceof Course) ? ((Course) value).getId()
            : null;
    return (id != null) ? String.valueOf(id) : null;
}
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
    Course course = new Course();
    course.setId(Integer.parseInt(value));
    return course;
}
}

and finally my xhtml page is:

<h:form>
    <p:pickList id="coursesOffered"
        value="#{courseView.courseModel}" var="course"
        itemValue="#{course}" itemLabel="#{course.courseTitle}"
        converter="courseConverter" showSourceFilter="true"
        showTargetFilter="true" filterMatchMode="contains">

        <f:facet name="targetCaption">Selected</f:facet>
        <f:facet name="sourceCaption">All Courses</f:facet>

        <p:ajax event="transfer" listener="#{courseView.onTransfer}" />

        <p:column style="width:10%">  
        #{course.courseCode}:
    </p:column>
        <p:column style="width:90%">  
       #{course.courseTitle}  
    </p:column>

    </p:pickList>

    <p:commandButton id="pojoSubmit" value="Submit"
        update="displayPlayers" oncomplete="playerDialog.show()"
        style="margin-top:5px" />

    <p:dialog showEffect="fade" hideEffect="fade" widgetVar="playerDialog">
        <h:panelGrid id="displayPlayers" columns="2">

            <h:outputText value="Source: " style="font-weight:bold" />
            <ui:repeat value="#{courseView.courseModel.source}"
                var="course">
                <h:outputText value="#{course.courseTitle}"
                    style="margin-right:5px" />
            </ui:repeat>

            <h:outputText value="Target: " style="font-weight:bold" />
            <ui:repeat value="#{courseView.courseModel.target}"
                var="course">
                <h:outputText value="#{course.courseTitle}"
                    style="margin-right:5px" />
            </ui:repeat>

        </h:panelGrid>
    </p:dialog>
</h:form>

The pickList is displayed correctly with source populated with values from database, however, upon clicking the button, the dialog just displays the original source list values and an empty target list even after transferring items on the interface. What am I missing?

  • 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-15T04:46:47+00:00Added an answer on June 15, 2026 at 4:46 am

    I see some problems with your code. In the getter, you are reconstructing the DualList from the database, reseting any changes you’ve done so far.

    try making you getter something like this:

    public DualListModel<Course> getCourseModel() {
        return this.courseModel;
    }
    

    Construct and load your list from the database in a method annotated @PostConstruct rather than in the constructor+getter.

    public CourseBean() {}
    
    @PostConstruct
    public void init() {
        List<Course> target = new ArrayList<Course>();
        courseModel.setSource(getCourseList());
        courseModel = new DualListModel<Course>(source, target);
    }
    

    Also annotate your bean @ViewScoped, so you dont construct a new bean with empty target-list on every request

    @ManagedBean(name="courseView")
    @ViewScoped
    public class CourseBean {
    
    }
    

    Finally you also need a setter:

    public void setCourseModel(DualListModel<Course> courseModel) {
        this.courseModel = courseModel;
    }
    

    I have not really looked into the converter, when I did a picklist lasttime i took the converter included in primefaces showcase (Never tried the omnifaces one). Here is a link to the source: http://code.google.com/p/ind/source/browse/indicadorCensoJSF/src/ve/gob/ine/censo/beans/convert/PrimeFacesPickListConverter.java?spec=svn154&r=154

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

Sidebar

Related Questions

I have tried to implement a picklist like the one in primeFaces with jQuery
I am trying to learn pickList from Primefaces . What I have jsf file,
I have primefaces autocomplete which is fetching values from database. When I type in
I use primefaces with facelets and i have a quastion: for example i have
I have several PrimeFaces checkboxes on a page. If you click the master checkbox,
I am testing the PrimeFaces example avaible at https://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml . I correctly imported PrimeFaces
In Primefaces, how do I change the icon that is being used by the
I am working in primefaces 3.3 and jsf 2.0. I have problem in deleting
I'm using Primefaces 3.3.1 and have question. I have p:commandButton inside p:column of p:dataTable.
I am using Primefaces google map component. I have some markers and info windows

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.