This post is about a very common question
How to set selected values in af:selectManyChoice component ?
Sometimes we need to set some values in selectManyChoice component on some action
In this post i am using Departments table of HR Schema to create selectManyChoice (Multiple Selection)
Just drag and drop Departments viewObject as ADF Select Many Choice
see- Using Multiple Selection (selectManyListbox & selectManyCheckbox component) in ADF
(Jdev Version- 12.1.3)
dropped a button on page and on this button action , setting values in component
See this simple managed bean code -
run application and check-
Downoad Sample Application
Thanks , Happy Learning :)
How to set selected values in af:selectManyChoice component ?
Sometimes we need to set some values in selectManyChoice component on some action
In this post i am using Departments table of HR Schema to create selectManyChoice (Multiple Selection)
Just drag and drop Departments viewObject as ADF Select Many Choice
see- Using Multiple Selection (selectManyListbox & selectManyCheckbox component) in ADF
(Jdev Version- 12.1.3)
dropped a button on page and on this button action , setting values in component
See this simple managed bean code -
import java.util.ArrayList; import javax.faces.event.ActionEvent; import oracle.adf.view.rich.component.rich.input.RichSelectManyChoice; import oracle.adf.view.rich.context.AdfFacesContext; public class SetValueSmcBean { private RichSelectManyChoice selectMcBind; public SetValueSmcBean() { } /**Methos to set selected values in SelectManyChoice * @param actionEvent */ public void setSelectedValuesAction(ActionEvent actionEvent) { ArrayList listVal = new ArrayList(20); //Add DepartmentId to list that you want to set as selected listVal.add(101); listVal.add(102); // Set this List as value using component binding selectMcBind.setValue(listVal.toArray()); //Refresh Component on page (partial target) AdfFacesContext.getCurrentInstance().addPartialTarget(selectMcBind); } public void setSelectMcBind(RichSelectManyChoice selectMcBind) { this.selectMcBind = selectMcBind; } public RichSelectManyChoice getSelectMcBind() { return selectMcBind; } }
run application and check-
Downoad Sample Application
Thanks , Happy Learning :)
500 Internal Server Error
ReplyDeletejava.lang.UnsupportedOperationException
while running the application getting this issue please help me on this issue
thanks
Download again and check and let me know
DeleteThanks for the Blog ,It helped me in my project.
ReplyDeleteBut after getting the selected element in the selectManyChoice Box while commiting on the same page this component shows error and does not let me to proceed unless i select something in selectManyChoice box manually.
Error:-
Please Help!!!!!!!!!!!
Thanks.
and what is the error ?
Deleteand are you setting values in selectManyChoice or getting ?
Gracias por el Blog. Me ayudó en mi proyecto.
DeletePero después de obtener el elemento seleccionado en el cuadro selectManyChoice al comprometerse en la misma página, este componente muestra un error y no me permite continuar a menos que seleccione manualmente algo en el cuadro selectManyChoice.
help!!!!!
Hi Ashish,
ReplyDeletehow to set the default values for selectManyChoice from programmatic VO?