Previously I have posted about using multi-selection components (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle) of ADF Faces. These components make use of list binding and work on base attribute and display attribute concept
Blog about Oracle ADF, JDeveloper, PL/SQL, Java, JavaScript, jQuery and Other Web Technologies
Search this blog
Showing posts with label af:selectManyCheckbox. Show all posts
Showing posts with label af:selectManyCheckbox. Show all posts
Saturday 3 June 2017
oracle.jbo.domain.DataCreationException: JBO-25009 while using multiple selection component in ADF Faces
Previously I have posted about using multi-selection components (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle) of ADF Faces. These components make use of list binding and work on base attribute and display attribute concept
You might also like:
Labels:
ADF
,
af:selectManyCheckbox
,
af:selectManyChoice
,
af:selectManyListbox
,
af:selectManyShuttle
,
get Value
,
JBO-25009
,
Jdeveloper 12.1.3
,
Jdeveloper 12c
,
Multiple Selection
,
Oracle ADF Tutorial
Friday 5 June 2015
Programmatically Select all values in ADF BC based selectMany (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle) component
Hello All,
Previously i have posted a lot about component that supports multiple selection in ADF Faces (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle)
- Multiple Selection in ADF Faces
This post is about selecting all values in a component programmatically on a event like button click, value change event etc.
Note that this post is designed for ADF BC (viewObject) based components , to set values in bean based component check this-
Programmatically populate values in ADF Faces multiSelect component (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle)
So for this i have just dropped Departments viewObject as multiSelect component on page
(af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle)
Now see code of Set all values as selected button-
/**Method to get BindingContainer of current viewPort (page) * @return */ public BindingContainer getBindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); }
/**Method to set all values as selected in SelectMany Components. * @param actionEvent */ public void setAllValuesToSelected(ActionEvent actionEvent) { int arrIndex[]; //Get the iterator binding of component DCIteratorBinding deptIter = (DCIteratorBinding) getBindings().get("DepartmentsView1Iterator"); //Get viewObject from Iterator ViewObject deptVo = deptIter.getViewObject(); //Get component list binding , component is directly based on this JUCtrlListBinding list = (JUCtrlListBinding) getBindings().get("DepartmentsView1"); DCIteratorBinding iterList = list.getDCIteratorBinding(); RowSetIterator rsi = deptVo.createRowSetIterator(null); int i = 0; int rowCount = (int) deptVo.getEstimatedRowCount(); //Initialize array and set it's size (equal to number of rows in List) arrIndex = new int[rowCount]; while (rsi.hasNext()) { //Get viewObject next row from RowSetIterator Row nextRow = rsi.next(); //Set this row as page iterator's current row iterList.setCurrentRowWithKey(nextRow.getKey().toStringFormat(true)); //Now get index of this row int indx = iterList.getCurrentRowIndexInRange(); //Add it to array arrIndex[i] = indx; i++; } rsi.closeRowSetIterator(); // Set as selected indices list.setSelectedIndices(arrIndex); }
All done, now run and check application , click on button and see what happens ?
Great, it's working :)
I have explained one more approach to set values in multi select component that makes use of component binding
check it - Set values in af:selectManyChoice programmatically - Oracle ADF
Sample ADF Application-Download
Cheers :) Happy Learning
You might also like:
Labels:
ADF Faces
,
af:selectManyCheckbox
,
af:selectManyChoice
,
af:selectManyListbox
,
af:selectManyShuttle
,
Multiple Selection
,
Oracle ADF
,
Programmatically
,
select all
,
set value
Wednesday 7 January 2015
Programmatically populate values in ADF Faces multiSelect component (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle)
ADF Faces provides some component to support multiple selection as af:selectManyListbox, af:selectManyCheckbox, af:selectManyChoice, af:selectManyShuttle
In this post we will see how to populate values in these component from managed bean using POJO
You can read my previous post on multiple selection that was about populating multiselect component using ADF BC and binding layer
Using Multiple Selection (selectManyListbox & selectManyCheckbox component) in ADF
Shuttle Component in Oracle ADF (Allow Multiple Selection)
See the step by step implementation-
In this post we will see how to populate values in these component from managed bean using POJO
You can read my previous post on multiple selection that was about populating multiselect component using ADF BC and binding layer
Using Multiple Selection (selectManyListbox & selectManyCheckbox component) in ADF
Shuttle Component in Oracle ADF (Allow Multiple Selection)
See the step by step implementation-
- Create a Fusion Web Application and a managed bean in viewController
- Create a variable of type java.util.List in managed bean, and generate its accessors
- This list contains value of type javax.faces.model.SelectItem; that is supported by af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox compoent
- See how to add this list reference to af:selectManyCheckbox component, just drag n drop component on page
- Set managed bean list reference to selectManyCheckbox component, records stored in this list will be populated in component
- Suppose I have to show some record as selected by default on page load so for this requirement created another List in managed bean and added it to value property of selectManyCheckbox component
Value property of component refers only selected records but selectItems component refers all records of component - Now run this application and see component on page
- Following same steps i have three more component on page , all 3 adf faces component support multiple selection
af:selectManyChoice-
<af:selectManyChoice label="Label 1" id="smc2" value="#{viewScope.ProgSelectManyComp.selectedValues}" simple="true"> <f:selectItems value="#{viewScope.ProgSelectManyComp.allValuesList}" id="si2"/> </af:selectManyChoice>
af:selectManyListbox-
<af:selectManyListbox label="Label 1" id="sml1" value="#{viewScope.ProgSelectManyComp.selectedValues}" simple="true"> <f:selectItems value="#{viewScope.ProgSelectManyComp.allValuesList}" id="si3"/> </af:selectManyListbox>
af:selectManyShuttle-
<af:selectManyShuttle label="Label 1" id="sos1" simple="true" value="#{viewScope.ProgSelectManyComp.selectedValues}" contentStyle="width:50px;"> <f:selectItems value="#{viewScope.ProgSelectManyComp.allValuesList}" id="si4"/> </af:selectManyShuttle>
- All 4 components on page are populated using same List, this is just an example to show that all 4 components share same strucutre, run this application and see
//List to show records in selectMany components List<SelectItem> allValuesList; public void setAllValuesList(List<SelectItem> allValuesList) { this.allValuesList = allValuesList; } public List<SelectItem> getAllValuesList() { return allValuesList; }
//List to show records in selectMany components List<SelectItem> allValuesList; public void setAllValuesList(List<SelectItem> allValuesList) { this.allValuesList = allValuesList; } public List<SelectItem> getAllValuesList() { if (allValuesList == null) { allValuesList = new ArrayList<SelectItem>(); allValuesList.add(new SelectItem(1, "India")); allValuesList.add(new SelectItem(2, "Australia")); allValuesList.add(new SelectItem(3, "America")); allValuesList.add(new SelectItem(4, "United Kingdom")); } return allValuesList; }
//List to show selected values in selectMany Component List selectedValues; public void setSelectedValues(List selectedValues) { this.selectedValues = selectedValues; } public List getSelectedValues() { if (selectedValues == null) { selectedValues = new ArrayList(); selectedValues.add(1); selectedValues.add(3); System.out.println("List is-" + selectedValues); } return selectedValues; }
See af:selectManyCheckbox source -
<af:selectManyCheckbox id="smc1" value="#{viewScope.ProgSelectManyComp.selectedValues}"> <f:selectItems value="#{viewScope.ProgSelectManyComp.allValuesList}" id="si1"/> </af:selectManyCheckbox>
Thanks, Happy Learning :)
Download- Sample ADF Application
You might also like:
Labels:
ADF
,
ADF Faces
,
af:selectManyCheckbox
,
af:selectManyChoice
,
af:selectManyListbox
,
af:selectManyShuttle
,
Managed bean
,
Multiple Selection
,
Oracle ADF
,
POJO
,
populate
,
Programmatically
,
values
Subscribe to:
Posts
(
Atom
)