This content has been marked as final.
Show 2 replies
-
1. Re: Validate blank selectOneMenu
oneworld95 Jun 5, 2009 5:12 PM (in response to oneworld95)Figured it out:
public Map<String, Object> getRatingItems(){ if (ratingItem == null){ ratingItem = new LinkedHashMap<String, Object>(); ratingItem.put("Please Select...",null); ratingItem.put("TV-Y", "TV-Y"); ratingItem.put("TV-Y7", "TV-Y7"); ratingItem.put("TV-G", "TV-G"); ratingItem.put("TV-PG", "TV-PG"); ratingItem.put("TV-14", "TV-14"); ratingItem.put("TV-MA", "TV-MA"); } return ratingItem; }
and then also added the <rich:message> tag:<h:selectOneMenu id="lstRating" value="#{asset.rating}" required="true" requiredMessage="Rating is required."> <f:selectItems value="#{asset.ratingItems}" /> </h:selectOneMenu> <rich:message for="lstRating" styleClass="errors" />
-
2. Re: Validate blank selectOneMenu
oneworld95 Jun 5, 2009 5:17 PM (in response to oneworld95)Sorry. Jumped the gun. This is the code that works:
private ArrayList<SelectItem> ratingItems = null; public ArrayList<SelectItem> getRatingItems(){ ratingItems = new ArrayList<SelectItem>(); ratingItems.add(new SelectItem(null,"Select One...")); ratingItems.add(new SelectItem("TV-Y", "TV-Y")); ratingItems.add(new SelectItem("TV-Y7", "TV-Y7")); ratingItems.add(new SelectItem("TV-G", "TV-G")); ratingItems.add(new SelectItem("TV-PG", "TV-PG")); ratingItems.add(new SelectItem("TV-14", "TV-14")); ratingItems.add(new SelectItem("TV-MA", "TV-MA")); return ratingItems; }