How to hide blank item from SelectOneChoice in ADF

Use Case – There is a use case where User wants to display blank as selected when page loads. But he doesn’t want blank to remain there once user select any value.

Solution – This is a workaround.

Step 1, Create one JSPX with foloowing contents,

<?xml version=’1.0′ encoding=’UTF-8′?>
<jsp:root xmlns:jsp=”; version=”2.1″
< contentType=”text/html;charset=UTF-8″/>
<af:document id=”d1″ title=”doc1″>
<af:form id=”f1″>
<af:commandButton text=”commandButton 1″ id=”cb1″
action=”#{ForwardBean.process}” partialSubmit=”true”/>
<af:selectOneChoice label=”Label 1″
id=”soc1″ required=”true” binding=”#{ForwardBean.dropdown1}” showRequired=”false”>
<af:selectItem label=”Item1″ value=”one” id=”si1″/>
<af:selectItem label=”Item2″ value=”two” id=”si2″/>
<af:selectItem label=”Item3″ value=”three” id=”si3″/>
<af:outputLabel value=”outputLabel1″ id=”ol1″
binding=”#{ForwardBean.updateState}” visible=”false”/>

Step 2. Create one MBean with following contents.

package com.test;

import javax.faces.event.PhaseEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;


public class ForwardBean {
private RichSelectOneChoice dropdown1;
private RichOutputLabel updateState;

public ForwardBean() {

public String process() {
// Add event code here…
return “success”;

public void pushSelectedItem(ValueChangeEvent valueChangeEvent) {
// Add event code here…


public void setDropdown1(RichSelectOneChoice dropdown1) {
this.dropdown1 = dropdown1;

public RichSelectOneChoice getDropdown1() {
return dropdown1;

public void setUpdateState(RichOutputLabel updateState) {
this.updateState = updateState;

public RichOutputLabel getUpdateState() {
System.out.println(“Inside method call::”);
return updateState;

Step 3. You are done! Enjoy…



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s