PickList items not rendered if validation failed

UI Components for JSF
Post Reply
bandeng
Posts: 4
Joined: 10 Oct 2010, 05:28

11 Dec 2010, 23:09

One page with
1. inputText required="true",
2. pickList,
3. commandButton ajax="false" action="#{bean.myaction} (use action and make ajax false, because it needs to navigate to a different page after submission),
4. messages,

The issues is if nothing was input in the inputtext, validation failed, the messages display the error messages, but the picklist doesn't show the item labels or item values, it is blank with the items box with no text. Is that a bug of primefaces or did I miss anything?

I am using 2.2 RC2.

Thanks.

bandeng
Posts: 4
Joined: 10 Oct 2010, 05:28

11 Dec 2010, 23:39

I just found some clue. It is related with the how primefaces works with the converter. My implementation of the converter is return the key of the item, and create a dummy item with the key passed as:

@Override
public Object getAsObject(FacesContext ctx, UIComponent component, String id) {
return new User(id);

Note: reason I created a dummy user, because I don't want to query database again to populate a user completely in the converter, what I need is only the user Id so that in the action listener, I just query the duallistmodel like users.getTarget, and it returns a list of dummy users with the ids. then I will query the database for a complete set of user data, etc.
}

@Override
public String getAsString(FacesContext ctx, UIComponent component, Object user) {
return ((User)user).getId().toString();
}

And in my pick list, the itemLabel is not the id of the user, but the name of the user, and the itemValue is the user with that converter. It seems when post back, primefaces ignores the value="#{mybean.users}", but rather directly queries the converter to get the user objects, and populate the picklist, therefore, the name for the itemLabel is blank.

I may need to run it in debug mode to see if I can further use the component parameter to get the full user data and avoid the database query.

Any other idea?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests