You are on page 1of 14

In this article we are going to create Dependent Poplist in a region other than a Table

region.

For this exercise we have created three poplist viz. State, County and City where
State is an Independent poplist while County is dependent on state and City is
dependent on both State and County.

Brief Steps:-

1. Create Application Module


2. Create View Object for poplists.
3. Create PVO * to handle PPR**
4. Create UI Components
5. Create Controller.

* Property View Object


** Partial page rendering

Detailed Description

Step 1: First create Workspace, Project and create an Application Module to interact
with Database.

Step 2: Create three ViewObjects for poplists (state, county and city) as shown below.

♣ PayUsStatesVO

http://oracleanil.blogspot.com/
http://oracleanil.blogspot.com/
♣ PayUsCountiesVO

♣ PayUsCityNamesVO
Step 3: Create a Property View Object to handle PPR event.

Add two Transient Attribute of type Boolean i.e.

♣ RenderCounty
♣ RenderCity

http://oracleanil.blogspot.com/
Add all VOs to DependentPoplistAM

http://oracleanil.blogspot.com/
Step 4: Build the Poplist Page with three poplist under MessageComponentLayout
region as shown below.

http://oracleanil.blogspot.com/
Make sure you set the Picklist View Instance Property not Picklist View Definition.

http://oracleanil.blogspot.com/
http://oracleanil.blogspot.com/

Attach SPEL Syntax to the Rendered property of County and City poplist and
FirePartialAction event with State and County

♣ State

♣ County
http://oracleanil.blogspot.com/

♣ City
http://oracleanil.blogspot.com/

Step5: Create page controller to handle PPR and to execute VO query.

Controller Code

package anil.oracle.apps.pay.webui;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import
oracle.apps.fnd.framework.webui.beans.layout.OAMessageComponentLayoutBea
n;
import
oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.jbo.Row;
/**
* Controller for ...
*/
public class DependentPoplistCO extends OAControllerImpl
{
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean
webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am =
(OAApplicationModule)pageContext.getApplicationModule(webBean);

//Calling below method to Initialize PVO


am.invokeMethod("initPVO");
}
http://oracleanil.blogspot.com/

/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean
webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am =
(OAApplicationModule)pageContext.getApplicationModule(webBean);

// This event gets called when user select a State


if("ChangeState".equals(pageContext.getParameter(EVENT_PARAM)))
{
OAMessageComponentLayoutBean mclb =
(OAMessageComponentLayoutBean)webBean.findChildRecursive("MainRN");
OAMessageChoiceBean mcb1 =
(OAMessageChoiceBean)mclb.findChildRecursive("State");
String stateCode = (String)mcb1.getValue(pageContext);
Serializable params[] = {stateCode};
am.invokeMethod("ChangeState",params);

}
// This event gets called when user select a County
if("ChangeCounty".equals(pageContext.getParameter(EVENT_PARAM)))
{
OAMessageComponentLayoutBean mclb =
(OAMessageComponentLayoutBean)webBean.findChildRecursive("MainRN");
OAMessageChoiceBean mcb1 =
(OAMessageChoiceBean)mclb.findChildRecursive("State");
String stateCode = (String)mcb1.getValue(pageContext);
OAMessageChoiceBean mcb2 =
(OAMessageChoiceBean)mclb.findChildRecursive("County");
String countyCode = (String)mcb2.getValue(pageContext);
Serializable params[] = {stateCode,countyCode};
am.invokeMethod("ChangeCounty",params);
}
}
}
http://oracleanil.blogspot.com/

Application Module Code

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import anil.oracle.apps.pay.poplist.server.PayUsStatesVOImpl;
import anil.oracle.apps.pay.poplist.server.PayUsCountiesVOImpl;
import anil.oracle.apps.pay.poplist.server.PayUsCityNamesVOImpl;
import oracle.jbo.Row;

public void ChangeState(String stateCode)


{
PayUsCountiesVOImpl vo =
(PayUsCountiesVOImpl)getPayUsCountiesVO1();
/* This Method calls PayUsCountiesVOImpl method*/
vo.initQuery(stateCode);
String countyCode = null;
handleChangeEvent(stateCode,countyCode);
}

public void initPVO()


{
String stateCode = null;
String countyCode = null;

DependentPoplistPVOImpl vo =
(DependentPoplistPVOImpl)getDependentPoplistPVO1();
if(vo != null)
{
if(!vo.isPreparedForExecution())
{
vo.executeQuery();
}

Row row = vo.createRow();


vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
handleChangeEvent(stateCode,countyCode);
}
}

public void ChangeCounty(String stateCode,String countyCode)


{
PayUsCityNamesVOImpl vo =
(PayUsCityNamesVOImpl)getPayUsCityNamesVO1();

/* This Method calls PayUsCityNamesVOImpl method*/


vo.initQuery(stateCode,countyCode);
handleChangeEvent(stateCode,countyCode);
}
http://oracleanil.blogspot.com/
/* This method is getting called from Application Module itself for
rendering the poplist beans based on the poplist events */
public void handleChangeEvent(String stateCode,String countyCode)
{

DependentPoplistPVOImpl vo =
(DependentPoplistPVOImpl)getDependentPoplistPVO1();
if(vo != null)
{
if (stateCode != null && countyCode == null)
{
vo.getCurrentRow().setAttribute("RenderCounty",Boolean.TRUE);
vo.getCurrentRow().setAttribute("RenderCity",Boolean.FALSE);
}
else if(countyCode != null)
{
vo.getCurrentRow().setAttribute("RenderCounty",Boolean.TRUE);
vo.getCurrentRow().setAttribute("RenderCity",Boolean.TRUE);
}
else
{
vo.getCurrentRow().setAttribute("RenderCounty",Boolean.FALSE);
vo.getCurrentRow().setAttribute("RenderCity",Boolean.FALSE);
}
}
}
}

PayUsCityNamesVOImpl Code

public void initQuery(String stateCode,String countyCode)


{
setWhereClause(null);
setWhereClauseParams(null);
setWhereClauseParam(0,stateCode);
setWhereClauseParam(1,countyCode);
executeQuery();
}

PayUsCountiesVOImpl Code
public void initQuery(String stateCode)
{
setWhereClause(null);
setWhereClauseParams(null);
setWhereClauseParam(0,stateCode);
executeQuery();
}
Finally the page will look like as below

Thanks
--Anil
http://oracleanil.blogspot.com/

You might also like