Skip to main content

ADF Multi select LOV

1. In this approach all the selected values will be inserted in separate rows in table.Ex. if you select 3 value out of 10 in LOV then 3 rows will be inserted in table. No need to create the LOV in ViewObject.

Create Entity and View for the table in which you want to store the multiple selected LOV values. Also create the read only view which has the LOV values which user will select.
Ex. 1. PropertiesVO - VO in which value will be stored
       2.PropertiesAvailableValuesRVO - VO in which provide LOV value.

2. First of all add af:selectManyChoice component to your page.

3. As shown in the below code create the binding,value and valueChangeListner in your bean and associate with this component.

4. Also create the f:selectItems and create the binding and value in bean same as done above.

<af:selectManyChoice label="#{caseviewcontrollerBundle.PROPERTIES}"
                                 id="cp1"
                                 value="#{pageFlowScope.ManagePerfected.propertiesCode}"
                                 binding="#{pageFlowScope.ManagePerfected.smPropertiesCode}"
                                 contentStyle="width:200.0px;"
                                 disabled="#{pageFlowScope.IsEditable eq 'Y'}"                      valueChangeListener="#pageFlowScope.ManagePerfected.savePropertiesListener}"
                                 autoSubmit="true" immediate="true">
    <f:selectItems value="#pageFlowScope.ManagePerfected.availablePropertiesCode}"
                              binding="#{pageFlowScope.ManagePerfected.siPropertiesCode}"
                              id="cp12"/>
            </af:selectManyChoice>


private List propertiesCode;
private List availablePropertiesCode
private RichSelectManyChoice smPropertiesCode;
private UISelectItems siPropertiesCode;

public void setPropertiesCode(List propertiesCode) {
    this.propertiesCode= propertiesCode;
    }
 
public List getPropertiesCode() {
    if (propertiesCode== null) {
           propertiesCode= attributeListForIterator("PropertiesVOIterator","PropertiesCode");
    }
    return propertiesCode;
    }

public void setsmPropertiesCode(RichSelectManyChoice smPropertiesCode) {
        this.smPropertiesCode = smPropertiesCode;
    }

public RichSelectManyChoice getsmPropertiesCode() {
                return smPropertiesCode;
    }

public void setSiPropertiesCode(UISelectItems siPropertiesCode) {
        this.siPropertiesCode= siPropertiesCode;
    }

public UISelectItems getSiPropertiesCode() {
        return siPropertiesCode;
    }

public void saveCasePropertiesListener(ValueChangeEvent valueChangeEvent)
   {
        ADFUtils.setCurrentTabDirty(true);
        valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
       DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
       DCIteratorBinding iterator =bindings.findIteratorBinding("PropertiesVOIterator");
     
     for (Row specialCode : iterator.getViewObject().getAllRowsInRange()) {
            specialCode.remove();
        }
        DCIteratorBinding dcItr = ADFUtils.findIterator("ParentVOIterator");
        Row row = dcItr.getViewObject().getCurrentRow();
        Object parentId = row.getAttribute("ParentId");
        int rcount =this.getPropertiesCode().size();
        String[] propertiesCode =new String[this.getPropertiesCode().size()];
        if (rcount > 0) {
            for (int k = 0; k < rcount; k++) {
                propertiesCode[k] =getPropertiesCode().get(k).toString();
                Row r = iterator.getViewObject().createRow();
                r.setAttribute("ParentId ", parentId );
                r.setAttribute("PropertiesCode",propertiesCode[k]);
                iterator.getViewObject().insertRow(r);
            }
        }

    }


public void setAvailablePropertiesCode(List availablePropertiesCode ) {
        this.availablePropertiesCode = availablePropertiesCode ;
    }

public List getAvailablePropertiesCode() {
  availablePropertiesCode =selectUniqueItemsForIterator("PropertiesAvailableValuesRVOIterator",
                    // iterator for displaying all items
                    "Value", // internal code for list item
                    "ShortDescription"); // display value for list item
     
        return availablePropertiesCode ;
      }


 public List<SelectItem> selectUniqueItemsForIterator(String iteratorName,
                                                               String valueAttrName,
                                                               String displayAttrName) \
{
              List<SelectItem> selectItems = new ArrayList<SelectItem>();
              HashMap<String, String> itemsMap = new HashMap<String, String>();

              DCIteratorBinding tsriter = ADFUtils.findIterator(iteratorName);
              ViewObject tsrvo = tsriter.getViewObject();
              tsrvo.executeQuery();

              // for (Row row : tsrvo.getAllRowsInRange()) {
              while (tsrvo.hasNext()) {
                  Row row = tsrvo.next();
                  String lovCode = row.getAttribute(valueAttrName).toString();

                  if (!itemsMap.containsKey(lovCode)) {
                      itemsMap.put(lovCode, lovCode);

                      String value = lovCode;
                      String finalDisplayValue =
                          (String)row.getAttribute(displayAttrName);
                      selectItems.add(new SelectItem(value, finalDisplayValue));

                  }
              }
              return selectItems;
          }




Comments

  1. I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
    Oracle Apps Technical Training in Bangalore

    ReplyDelete

Post a Comment

Popular posts from this blog

The file store "WLS_DIAGNOSTICS" could not be opened

WLS_DIAGNOSTIC ERROR weblogic.store.PersistentStoreException: [Store:280073]The file store "WLS_DIAGNOSTICS" could not be opened because it contained a file with the invalid version 1. A file of version 2 was expected. When you get this error while running your application on internal weblogic server delete the following file WLS_DIAGNOSTICS000000.DAT search the file in following path C:\jdev_work\system11.1.1.5.37.60.13\DefaultDomain this file is in DefaultDomain folder of your jdev. and delete the WLS_DIAGNOSTICS000000.DAT file . and run your applicatuon

Overview Editor for bc4j.xcfg

This is used to customize the configuration settings for the application pool, connection pool, and transactions. Select the Application Module, then select a configuration from the Configurations list. You can specify a Default Configuration from the dropdown to use with selected application module. Edit the name of the configuration in Details. Its having 3 tabs 1.Database and Scalability 2. Properties 3. Custom Properties Database and Scalability Tab : In Database and Scalability you can mention the JDBC data source definition for each application module. You can choose to connect to a JDBC data source or to a JDBC URL.The default connection type is the default data source. A data source is a vendor-independent encapsulation of a database server connection on the application server. 1. Data sources ( JNDI name) offer advantages over a JDBC URL connection because the data source can be tuned, reconfigured, or remapped without changing the deployed application. 2. JDB...

WebCenter Deployment Architecture

The main components of the deployment architecture are: • WebLogic Server • Portlets deployed in Portlet Container • Metadata storage for customization information • Enterprise Content Management solution with Content Adapters • WebCenter Services • WebCenter Search • Identity Management         WebLogic Server, which is a Java EE–compliant application server, is at the center of WebCenter. WebCenter applications are Java EE applications that are deployed to WebLogic Server. WebCenter Spaces is a prebuilt custom application using WebCenter Framework and Services. Portlets : WebCenter applications can consume portlets. Portlets are deployed into a Portlet Container and are accessed by various HTTP-based network protocols such as WSRP and SOAP. Oracle WebCenter supports several portlet APIs such as JSR 168 and PDK Java.   Metadata Services : WebCenter applications can be customized or personalize...