LOV's in humantask (part 1 of 2) figuur5

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.

LOV's in humantask (part 1 of 2) figuur1

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">
    <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">
    <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.

LOV's in humantask (part 1 of 2) figuur2

 

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

LOV's in humantask (part 1 of 2) figuur3

 

Specify a Default Package (LOV). Press finish.

LOV's in humantask (part 1 of 2) figuur4

 

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.

LOV's in humantask (part 1 of 2) figuur57

 

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.

LOV's in humantask (part 1 of 2) figuur61

 

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.

LOV's in humantask (part 1 of 2) figuur71

 

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

LOV's in humantask (part 1 of 2) figuur8

 

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

LOV's in humantask (part 1 of 2) figuur9

 

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

LOV's in humantask (part 1 of 2) figuur101

 

The Result.

LOV's in humantask (part 1 of 2) figuur111

 

View Accessor

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

LOV's in humantask (part 1 of 2) figuur121

 

Specify a dummy query.

LOV's in humantask (part 1 of 2) figuur13

 

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

LOV's in humantask (part 1 of 2) figuur142

 

The result.

LOV's in humantask (part 1 of 2) figuur152

 

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

LOV's in humantask (part 1 of 2) figuur162

 

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

LOV's in humantask (part 1 of 2) figuur172

 

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.

LOV's in humantask (part 1 of 2) figuur182

 

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.

LOV's in humantask (part 1 of 2) figuur192

 

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

LOV's in humantask (part 1 of 2) figuur202

 

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

LOV's in humantask (part 1 of 2) figuur211

 

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

LOV's in humantask (part 1 of 2) figuur221

 

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

LOV's in humantask (part 1 of 2) figuur231

 

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.

LOV's in humantask (part 1 of 2) figuur241

 

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’.

LOV's in humantask (part 1 of 2) figuur251

 

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.

LOV's in humantask (part 1 of 2) figuur261

 

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.

LOV's in humantask (part 1 of 2) figuur271

  LOV's in humantask (part 1 of 2) figuur281

 

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’.

LOV's in humantask (part 1 of 2) figuur291

 

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

LOV's in humantask (part 1 of 2) figuur301

Deploy the Project.

 

In part 2 of this blog I will describe the LOV feeded via a webservice (https://technology.amis.nl/2012/04/06/lovs-in-human-task-part-2-of-2/).

2 Comments

  1. Pedro Pereira June 20, 2012
    • Marcel van de Glind July 1, 2012