Sunday, May 12, 2013


Configuring Struts on Tomcat 7.*

I used to work on Tomcat 7.* for running JSP pages.

I was not aware not that we can configure Tomcat to run Struts.

I found the below wonderful article which clearly explained how to configure Struts on the Tomcat Server.

http://www.ntu.edu.sg/home/ehchua/programming/java/Struts2.html



Sunday, May 05, 2013

Dependent LOV

Concept : when we select a value from one LOV field ,based on that value, another LOV field will show filtered results.

Here, I have used two LOVs: one for PO Headers and another for PO Lines.
So first, user will select a PO Header Id from LOV1.
As we are making these dependent, so LOV2 will show only those PO Lines that are related to PO header Id selected.

1) Create a new OA page:
==========================
Right click on project (xxcus) --> New --> Web Tier --> OA Components --> select 'Page' item. Click OK. (This will open a popup window)
We are creating Dependent LOV page, so specify the details of page as below:
          Name: DependentLovPG
          Package: xxcus.oracle.apps.fnd.dpndntlov.webui

2) Create two new view objects (VO):
==========================

First for PO Headers

Right click (dpndntlov) --> New View Object (This will open a wizard having 7 steps).

Step 1
        Package: xxcus.oracle.apps.fnd.dpndntlov.lov.server
        Name: PoHeaderLovVO
        Choose the radio button 'Read-only Access' (as we are not performing  any DML operation). Click Next.

Step 2
       Enter the below query in 'Query Statement':
    select PO_HEADER_ID from po_headers_all where rownum <50

As there is no need to generate VOImpl/VORowImpl, keep defaults for step3, 4, 5, 6 & 7 and click Finish. Save All.

Second for PO Lines

Right click --> New View Object

Step 1
         Package: xxcus.oracle.apps.fnd.dpndntlov.lov.server
         Name: PoLinesLovVO
         Choose the radio button 'Read-only Access'. Click Next.

Step 2
        Enter the below query in 'Query Statement':
        select PO_HEADER_ID, PO_LINE_ID from po_lines_all

Keep defaults for step3, 4, 5, 6 & 7 and click Finish. Save All.

3) Create a new Application Module (AM):
==========================
Step 1
        Package: xxcus.oracle.apps.fnd.dpndntlov.server
        Name: DependentLovAM. Click Next.

Step 2
        Here we will add an instance of the VOs created in (2).
        Select PoHeaderLovVO & PoLinesLovVO from 'Available View Objects' and shuttle it to 'Data Model' using ">" button.

Keep defaults for all other steps (3, 4). Click Finish.

4) Creating the Page Layout & Setting its Properties:
==========================
1) Create a new region under pageLayout of type defaultSingleColumn.
2) Create 2 items under defaultSingleColumn region (messageLovInput, messageLovInput).

Now change the properties for each field from property inspector as shown below:

pageLayout:
         ID: pageLayoutRN
         AM Definition: xxcus.oracle.apps.fnd.dpndntlov.server.DependentLovAM
         Window Title: Dependent LOV Demo Page
         Title: Dependent LOV Demo

defaultSingleColumn: 
         ID: singleColRN; Text: PO Lines Dependent on PO Header

messageLovInput (for PO Header): 
         ID: poHearderLov
         Prompt: PO Header ID

messageLovInput (for PO Lines):
         ID: poLineLov
         Prompt: PO Line ID
  
Creating LOV regions:

Expand poHearderLov LOV, right click on region1 and create a new region using wizard.

Step 1
select 'DependentLovAM' from Application Module drop down and select 'PoHeaderLovVO1' in available view usages. Click Next.

Step 2
choose region style as 'table' from drop down. Click Next.

Step 3
Shuttle all the fields from available to selected attributes. Click Next.
Also modify the prompt to make it more user friendly (like PO Header ID).

This will create an item 'PoHeaderId' under 'PoHeaderLovVO1' table region.
Set search allowed property to TRUE for the item created.
      lovMap1:
            LOV region item: PoHeaderId
            Return item: poHearderLov
            Criteria item: poHearderLov

Similarly, create LOV region for poLineLov choosing DependentLovAM as AM and PoLinesLovVO1 as view object.
Modify the prompt to PO Lines ID.

This will create 2 items 'PoHeaderId1' & 'PoLineId' under PoLinesLovVO1' table region.
Set search allowed property of 'PoLineId' to TRUE.

      lovMap2:
            LOV region item: PoLineId
            Return item: poLineLov
            Criteria item: poLineLov

Here, in lovMap3, we are making this dependent on first LOV by setting criteria item as value of first LOV field.
      lovMap3:
            LOV region item:PoHeaderId1
            Criteria item: poHearderLov



Now select a value (PO Header Id) from LOV1 such as 4 (as shown in above screenshot).

Perform a search on PO Line ID LOV. This will show only those lines whose header Id is 4.



regards 
Rekha Kasyap . 


Implementing Shuttle Region

Shuttle region allows users to move items between two lists as well as reorder the items in the list. When you implement a Shuttle region, you define two lists:


A Leading list (Available List) - from which user can select items from a given list of items
A Trailing list (Selected List) - user will select item from Leading list and move those to this trailing list.

Also we can implement a Shuttle region with just one list, to achieve only Reorder functionality, in that case only a Leading list is required.

We can also add buttons/icons in the footer below each of the Shuttle lists. By Simply defining Leading footer child or Trailing footer child in region creates a flowLayout region by default, to which we can add a button or image.

Here, I have created a simple page to implement shuttle region. User will select employee name from 'Available List' and move them to 'selected List'. A button is also added at footer of trailing list. Clicking on this button will show all the employees selected in a message.

1) Create a new OA page:
=========================
Right click on project (xxcus) --> New --> Web Tier --> OA Components --> select 'Page' item. Click OK. (This will open a popup window)
We are creating a page for implementing shuttle region, so specify the details of page as below:
          Name: ShuttlePG
          Package: xxcus.oracle.apps.fnd.shuttle.webui

2) Create a new view objects (VO):
=========================
Right click --> New View Object (This will open a wizard having 7 steps).

Step 1
         Package: xxcus.oracle.apps.fnd.shuttle.server
         Name: ShuttleVO
         Choose the radio button 'Read-only Access' (as there is no DML operation). Click Next.

Step 2
         Enter the below query in 'Query Statement':
               select ename from employee

Keep defaults for step3, 4, 5, 6 & 7 and click Finish. Save All.   

3) Create a new Application Module (AM):
=========================

Step 1
         Package: xxcus.oracle.apps.fnd.shuttle.server
         Name: ShuttleAM. Click Next.

Step 2
    Here we will add an instance of the VO created in (2). Select ShuttleVO from 'Available View Objects' and shuttle it to 'Data Model' using ">" button.

Keep defaults for all other steps (3, 4). Click Finish.

4) Create a new Controller (CO):
=========================
Right click on pageLayout region and create a new controller
            Name:ShuttleCO
            package: xxcus.oracle.apps.fnd.shuttle.webui


5) Creating the Page Layout & Setting its Properties :-
==========================


1) Create a new region under pageLayout of type shuttle. This will automatically create a region for leading list.
2) Add Trailing list: right click shuttle region --> new --> Trailing.
3) Add trailing footer to display button: Again right click on shuttle region --> new --> trailingFooter. This will create a flowLayout region under trailingFooter.
4) Add 'Display Items' button: Create an item of type submitButton under the flowLayout region.

Now change the properties for each field from property inspector as shown below:


pageLayout:
            ID: pageLayoutRN
            AM Definition: xxcus.oracle.apps.fnd.shuttle.server.ShuttleAM
            Window Title: Shuttle  Page
            Title: Shuttle 

shuttle:
           ID: shuttleRN
           Available Header: Available Employees
           Selected Header: Selected Employees


leadingList:
           Picklist View Definition: xxcus.oracle.apps.fnd.shuttle.server.ShuttleVO
           Picklist View Instance: ShuttleVO1
           Picklist Display Attribute: Ename
           Picklist Value Attribute: Ename

list2:
           Picklist Display Attribute: Ename
           Picklist Value Attribute: Ename

submitButton:
           ID: displayBtn
           Prompt: Display Items




We will catch the button event (displayBtn) in PFR method of controller and display a message showing all the employees present in selected list. If there is no item in selected list, throw an error message. Below is code for the same:

public void processFormRequest(OAPageContext pageContext,
                               OAWebBean webBean) {
    super.processFormRequest(pageContext, webBean);
     
    String message = "";
     
    if (pageContext.getParameter("displayBtn") != null) {
        OADefaultShuttleBean shuttle =
            (OADefaultShuttleBean)webBean.findChildRecursive("shuttleRN");
        String[] items =
            shuttle.getTrailingListOptionValues(pageContext, shuttle);
     
    if (items != null) {
            for (int i = 0; i < items.length - 1; i++) {
                message = items[i] + " , " + message;
            }
             
            message = message + items[items.length - 1];           
            throw new OAException("Items in trailing list are: " +
                                  message, OAException.INFORMATION);
        } else {
       throw new OAException("Please shuttle at least one item from available list.",
                                  OAException.ERROR);
        }
    }
}



regards 
Rekha Kasyap .