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:selectManyShuttle. Show all posts
Showing posts with label af:selectManyShuttle. 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
Friday, 2 May 2014
Pre-populate selected values in viewObject based shuttle component (multiple selection)- Oracle ADF
Hello All,
This post talks about a common development requirement
while using shuttle component sometimes we need to show some values on selected side of af:selectManyShuttle , so to do this normally we use a custom shuttle component that is populated from managed bean code
but when i have all data in a viewObject so why should i iterate viewObject to get all data in managed bean and then set some values in an arrayList to populate selected shuttle values.
it is time consuming and requires lot of coding, so for viewObject based shuttle we can do it in efficient way.
This post talks about a common development requirement
while using shuttle component sometimes we need to show some values on selected side of af:selectManyShuttle , so to do this normally we use a custom shuttle component that is populated from managed bean code
but when i have all data in a viewObject so why should i iterate viewObject to get all data in managed bean and then set some values in an arrayList to populate selected shuttle values.
it is time consuming and requires lot of coding, so for viewObject based shuttle we can do it in efficient way.
- In this example I'm using Departments table of HR schema to populate af:selectManyShuttle, i think you all know how to create a shuttle in ADF
- So next is to populate selected shuttle values on some event, created a fusion web application using Departments table
- It's time to drop Departments ViewObject on page as shuttle component
- So suppose on a button click i want to set selected values in shuttle, so i have created a actionEvent for button in managed bean and binding of af:selectManyShuttle, so basic structure of page is like this
- See the code of actionEvent , create an arrayList and add all values in it that you want to set as selected values and then just set the value in shuttle using binding
- Now run this page and test your shuttle component
<af:selectManyShuttle value="#{bindings.Departments1.inputValue}" label="#{bindings.Departments1.label}" id="sms1" size="15" binding="#{pageFlowScope.ShuttleSelectBean.shuttleBind}" partialTriggers="b1"> <f:selectItems value="#{bindings.Departments1.items}" id="si1"/> <f:validator binding="#{bindings.Departments1.validator}"/> </af:selectManyShuttle>
/**Method to set selected values in af:selectManyShuttle * @param actionEvent */ public void selectValuesShuttle(ActionEvent actionEvent) { DCIteratorBinding iter = (DCIteratorBinding) getBindingsCont().get("Departments1Iterator"); ViewObject vo = iter.getViewObject(); RowSetIterator rsi = vo.createRowSetIterator(null); ArrayList listVal = new ArrayList(20); while (rsi.hasNext()) { Row nextRow = rsi.next(); if (nextRow.getAttribute("DepartmentId") != null) { listVal.add(nextRow.getAttribute("DepartmentId")); } } shuttleBind.resetValue();// Reset Shuttle Component System.out.println("Setting values -" + listVal); shuttleBind.setValue(listVal.toArray()); // Setting selected values AdfFacesContext.getCurrentInstance().addPartialTarget(shuttleBind); }
Cheers- Happy Coding
- But this method works only when you have to set values on some action or other event after page load, because before page load , binding of shuttle component will not be accessible
- So if you have a requirement of setting selected values on page load then you must use a list defined in managed bean and bind it to value property of shuttle component, value property denotes selected values of shuttle
- And just write same code on getter of List, in this case selected values in shuttle are populated on page load
List pageLoad = new ArrayList(20); public void setPageLoad(List pageLoad) { this.pageLoad = pageLoad; } public List getPageLoad() { DCIteratorBinding iter = (DCIteratorBinding) getBindingsCont().get("Departments1Iterator"); ViewObject vo = iter.getViewObject(); RowSetIterator rsi = vo.createRowSetIterator(null); while (rsi.hasNext()) { Row nextRow = rsi.next(); if (nextRow.getAttribute("DepartmentId") != null) { pageLoad.add(nextRow.getAttribute("DepartmentId")); } } return pageLoad; }
Cheers- Use both method as per your requirement :-) Download Sample App
You might also like:
Labels:
11g
,
ADF
,
ADF Faces
,
af:selectManyShuttle
,
In ADF
,
List
,
Multiple Selection
,
populate
,
Programmatically
,
Selected Values
,
Shuttle Component
,
values
,
ViewObject
Wednesday, 21 November 2012
Shuttle Component in Oracle ADF (Allow Multiple Selection), Get Selected values from Shuttle Component
Hello All
Hope you all are doing well :)
Shuttle component supports multiple selections at Runtime, when we need to select multiple records at runtime then we can use Shuttle Component.
Now we see how to use shuttle component (af:selectManyShuttle) in Oracle ADF
Follow these steps-
- Prepare model for Employees table of HR Schema(Create EO,VO and AM)
- Now drag Employees ViewObject from DataControl to page and select multiple selection-->ADF Select Many Shuttle-
- Now edit binding for this Shuttle Component, choose attribute that you want to show and also base attribute-
- Now it will look like this, drag a button to get selected attribute of this shuttle component
Now write code on button's actionEvent to get selected value from Shuttle-
import oracle.adf.model.BindingContext; import oracle.binding.BindingContainer; /*****Generic Method to get BindingContainer of current page, fragment or region**/ public BindingContainer getBindingsCont() { return BindingContext.getCurrent().getCurrentBindingsEntry(); }
public void getSelectedValue(ActionEvent actionEvent) { //Get Binding Continer of Page BindingContainer bc = this.getBindingsCont(); //Get shuttle binding from pagedef JUCtrlListBinding listBindings = (JUCtrlListBinding)bc.get("Employees1"); //Get Selected Values Object str[] = listBindings.getSelectedValues(); //Iterate over selected values for (int i = 0; i < str.length; i++) { System.out.println(str[i]); } }
You might also like:
Labels:
ADF
,
ADF Bindings
,
ADF UI
,
af:selectManyShuttle
,
BindingContainer
,
How to
,
Jdeveloper 11g
,
Multiple Selection
,
Oracle ADF Tutorial
,
Shuttle Component
Subscribe to:
Posts
(
Atom
)