LOV’s in humantask (part 1 of 2)

LOV’s – List Of Values in humantask

In this blog I will describe the use of LOV’s in Humantasks. I will describe three different type of LOV’s.

   1. LOV with fixed values

   2. LOV feeded by the content of a database table

   3. LOV feeded via a webservice

The blog is devided into two part. In this first part I will descibe the first two types. In the second part I will descibe the third type.

1. LOV with fixed values

As an example I will add a LOV with the values: Male, Female and Unknown to a Gender (geslacht in dutch) field. In this blog the terms Gender and Geslacht are sometimes mixed. In both cases the same thing is meant.

image1

The generated source code of the gender field is shown below:

<af:inputText> value="#{bindings.Geslacht.inputValue}"
              label="#{bindings.Geslacht.hints.label}"
              required="#{bindings.Geslacht.hints.mandatory}"
              columns="#{bindings.Geslacht.hints.displayWidth}"
              maximumLength="#{bindings.Geslacht.hints.precision}"
              shortDesc="#{bindings.Geslacht.hints.tooltip}"
              id="it97"&gt;
    <f:validator binding="#{bindings.Geslacht.validator}"/></af:inputText>

Replace this code with the following code:

<af:selectOneChoice value="#{bindings.Geslacht.inputValue}"
                    label="#{bindings.Geslacht.hints.label}"
                    required="#{bindings.Geslacht.hints.mandatory}"
                    shortDesc="#{bindings.Geslacht.hints.tooltip}"
                    id="it97"&gt;
    <af:selectItem label="Male" value="M" id="si6"/><af:selectItem label="Female" value="F" id="si4"/><af:selectItem label="Unknown" value="U" id="si3"/></af:selectOneChoice>

2. LOV feeded by the content of a database table

As an example I will add a LOV with the values: Male, Female and Unknown to a Gender field.
Instead of using fixed values I will now get these values from a database table. For this purpose I created the following table:

CREATE TABLE "MOA_UTILS"."MOA_GENDER"                            // in dutch MOA_GESLACHT
(   "ABBREVIATION"   VARCHAR2(1 CHAR) NOT NULL ENABLE,           //          AFKORTING
    "GENDERNAME"     VARCHAR2(20 CHAR) NOT NULL ENABLE           //          GESLACHTNAAM
);

Loaded some data:

INSERT INTO MOA_GENDER (ABBREVIATION,GENDERNAME) VALUES ('M','Male');
INSERT INTO MOA_GENDER (ABBREVIATION,GENDERNAME) VALUES ('F','Female');
INSERT INTO MOA_GENDER (ABBREVIATION,GENDERNAME) VALUES ('U','Unknown');

2.1. Create View Objecten

To make use of the LOV, a View Object to access the data is required. We also need a View Accessor to Access this View Object from the humantask. This View Accessor can add additional filters to the LOV.

Start by creating an ‘ADF Model Project’ for the View object’s.

Project creation

Create an ‘ADF Model Project’ in the same application as the humantask is located.

image2

This ‘Model Project’ is used to create the ADF Business Components. Specify the Project name (LOVViews). Press Next.

image3

Specify a Default Package (LOV). Press finish.

image4

View Object

The first ADF BC will be a View Object. A View Object is used here to select data.
Create the View Object within the LOVViews project.

image5

The View Object is getting it’s data from a database. For this purpose, the next step will be to setup a connection with this database.

image6

After this. A wizard is started for the creation of the View Object.
Specify a View Object name (GeslachtView or GenderView) with ‘Read-only access through SQL query’. Press Next.

image7

This View Object is used to construct the LOV. Specify the Select Query. Ater that press three times Next.

image8

In step 6 ‘Attribute Settings’ check ‘Key Attribute’ for the Afkorting / Abbreviation attribuut. Press NextNext

image9

Now we reached step 8 ‘Application Module’.
Check-on ‘Applicatie Module’. Specify an Application Module name (AppModule) and press Finish.

image10

The Result.

image11

View Accessor

Create a second View Object with name GeslachtAccessor/GenderAccessor in the LOVViews project.
Set  ‘Read-only access through SQL query’. Press Next.

image12

Specify a dummy query.

image13

Select Next until step 8 is reached. Check ‘Applicatie Module’ again. Press Finish.

image14

The result.

image15

Now extend this View Object with a ‘transient attribute’ . For this, press the green sign.

image16

Specify the attribute (LovTargetViewAttr). Set Updatable op ‘Always’. Press OK.

image17

Selecteer this new added attribute and go into Edit mode by clicking the pencil.
Select Control Hints and change the ‘Control Type’ from default into ‘Input Text with List of Values’ . Press OK.

image18

 Connecting the View Accessor with the View Object

The created View Object and View Accessor must be connected with each other.
To do this, click the green plus sign in the  ‘List of Values’ section.

image19

Press the green plus sign again (now behind List Data Source) in new appearing screen.

image20

Shuttle GeslachtView/GenderView to the right side. Press OK.

image21

Select Afkorting/Abbreviation as ‘List Attribute’ in the List of Return Values.

image22

Select  the ‘UI Hints’ tab and shuttle both available attributes to the right. Press OK.

image23

As a finishing touch we need to change the datasource reference.

Open the AppModule.xml file and then select the Configurations tab. Go into Edit mode for the AppModuleLocal by clicking the pencil.

image24

Select JDBC Datasource als ‘Connection Type’. Now the ‘Datasource Name’ changes into java:comp/env/jdbc/MOA_UTILSDS. Manually change this into the JNDI name as specified on the WebLogic Server. In my case: ‘jdbc/MOAUtils’.

image25

2.2. Attach the LOV to a taskfield

Open the humantask where the LOV is needed. Drag and Drop the LovTargetViewAttr attribute (from the Accessor) on the taskDetails page. A popup menu appears.

image26

Choose ‘ADF LOV ChoiceList‘ (short lists) or ‘ADF LOV input‘ (long lists).
The ChoiceList type show a short list with the posibility to enter a Search(zoeken) popupscreen The input type directly start the Search popupscreen.

image27

image28

The LOV is now connected to the transient attribute. In my case it must be connected to the Gender/Geslacht attribute.

The source code of the ChoiceList type:

<af:inputComboboxListOfValues id="viewAttr1Id"
                              popupTitle="Search and Select: #{bindings.ViewAttr1.hints.label}"
                              value="#{bindings.Geslacht.inputValue}"
                              label="#{bindings.ViewAttr1.hints.label}"
                              model="#{bindings.ViewAttr1.listOfValuesModel}"
                              required="#{bindings.ViewAttr1.hints.mandatory}"
                              columns="#{bindings.ViewAttr1.hints.displayWidth}"
                              shortDesc="#{bindings.ViewAttr1.hints.tooltip}"><f:validator binding="#{bindings.ViewAttr1.validator}"/></af:inputComboboxListOfValues>

Change this into:

<af:inputComboboxListOfValues id="viewAttr1Id"
                              popupTitle="Zoek en Selecteer #{bindings.Geslacht.hints.label}"
                              value="#{bindings.Geslacht.inputValue}"
                              label="#{bindings.Geslacht.hints.label}"
                              model="#{bindings.ViewAttr1.listOfValuesModel}"
                              required="#{bindings.ViewAttr1.hints.mandatory}"
                              columns="#{bindings.ViewAttr1.hints.displayWidth}"
                              shortDesc="#{bindings.ViewAttr1.hints.tooltip}"><f:validator binding="#{bindings.ViewAttr1.validator}"/></af:inputComboboxListOfValues>

What has changed?

–       Title popup search screen
–       Input field lable
–       Attached field

2.3. Deployment

Before we can deploy the project, an Application property must change. Open the ‘Application Properties’.

image29

Switch off ‘Auto Generate and Synchronize weblogic-jdbc.xml Descriptors During Deployment’ .

image30

Deploy the Project.

In part 2 of this blog I will describe the LOV feeded via a webservice (https://myfmw.wordpress.com/2012/04/06/lovs-in-humantask-part-2-of-2/).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s