Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Rich:PickList Control  RSS feed

Kapil Nimje
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using the rich picklist control for displaying the list of available Questions from the database (Question Table Object) on left hand side of picklist, and selection of question is appearing on right hand side of the list. Now the question are selected will be appear in the panel next to picklist will display the details of that question as per mention in below structure.

Now I have the releation maintain in database table as follows

Question Table (id, Text) values(1, What is your Sex?)
Answer Table (id, Text, question_id) values(1, Male,1)
(id, Text, question_id) values(2, Female,1)

So the Panel Will display the output as

1 What is your Sex?
* Male
* Female

2 Next Selected Question?
* ans1
* ans2

So when I click the question from left hand side list, the right hand seletion is displayed, but panel next to rich: picklist with above mention output is not being displayed?

Kindly Help me to sort out this issue,

Below are my code

JSF code

<f:facet name="header">
Demo Block Question Selection

<h:panelGrid columns="2" columnClasses="top, top">

<rich:pickList value="#{demoBlockBean.demoQuestions}" converter="#{demoBlockConverter}" switchByClick="true" >

<a4j:support event="onlistchanged" reRender="showPanel"/>
<f:selectItems value="#{demoBlockController.allEnabledDemoQuestionsSelectItems}"/>


<rich:panel id="showPanel" bodyClass="pbody">
<f:facet name="header">
<hutputText value="Options Choosen"></hutputText>
<a4j:repeat value="#{demoBlockBean.demoQuestions}" var="demoQuestionSelectedList">

Bean Class

@Scope(value = "request")
@Component(value = "demoBlockBean")
public class DemoBlockBean {

private List<DemoQuestion> demoQuestions;

public List<DemoQuestion> getDemoQuestions() {
return demoQuestions;

public void setDemoQuestions(List<DemoQuestion> demoQuestions) {
this.demoQuestions = demoQuestions;


Controller Class for getting list of Question from DB

@Scope(value ="request")
@Component(value= "demoBlockController")
public class DemoBlockController {

DemoQuestionService demoQuestionService;

public List<SelectItem> getAllEnabledDemoQuestionsSelectItems() {
List<DemoQuestion> demoQuestionList = demoQuestionService.getEnabledDemoQuestions();
List<SelectItem> demoQuestionSelectItemList = new ArrayList<SelectItem>(demoQuestionList.size());
for (DemoQuestion demoQuestion : demoQuestionList) {
demoQuestionSelectItemList.add(new SelectItem(demoQuestion, demoQuestion.getText()));
return demoQuestionSelectItemList;

Converter Class

@Service(value = "demoBlockConverter")
@Scope(value = "session")
public class DemoBlockConverter implements Converter{

private DemoQuestionService demoQuestionService;

public Object getAsObject(FacesContext context, UIComponent component, String value)
throws ConverterException {
if (context == null || component == null) throw new NullPointerException();
if (value == null || value.length() == 0) return null;

DemoQuestion demoQuestion = demoQuestionService.getDemoQuestion(new Long(value));
System.out.println("demoQuestion In Converter========="+demoQuestion.getText() + "value=== " + value);
return demoQuestion;
} // end method getAsObject

public String getAsString(FacesContext context, UIComponent component, Object value)
throws ConverterException {
if (context == null || component == null) throw new NullPointerException();
if (value == null || value.getClass() != DemoQuestion.class) return null;

DemoQuestion demoQuestion = (DemoQuestion) value;
return demoQuestion.getId().toString();
} // end method getAsString

Please find the attached File also for reference.
[Thumbnail for PickList-Form.JPG]
Rich PickList Form Demo
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!