LOV’s in humantask (part 1 of 2)

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.

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

&lt;af:<strong>inputText</strong> 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;
    &lt;f:validator binding="#{bindings.Geslacht.validator}"/&gt;
&lt;/af:inputText&gt;

Replace this code with the following code:

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

 

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.

 

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

 

Specify a Default Package (LOV). Press finish.

 

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.

 

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.

 

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.

 

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

 

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

 

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

 

The Result.

 

View Accessor

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

 

Specify a dummy query.

 

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

 

The result.

 

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

 

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

 

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.

 

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.

 

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

 

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

 

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

 

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

 

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.

 

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

 

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.

 

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.

  

 

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:

&lt;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}"&gt;
           &lt;f:validator binding="#{bindings.ViewAttr1.validator}"/&gt;
&lt;/af:inputComboboxListOfValues&gt;

Change this into:

&lt;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}"&gt;
           &lt;f:validator binding="#{bindings.ViewAttr1.validator}"/&gt;
&lt;/af:inputComboboxListOfValues&gt;

 

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

 

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

Deploy the Project.

 

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

Share.

About Author

As a SOA and BPM professional, Marcel is an experienced consultant in the field of process design and process modeling. Within this field system integration and IT-transcending business processes have Marcel's special interest.

2 Comments

    • Marcel van de Glind on

      Hi Pedro,

      By referencing the JNDI name of the datasource (database) the solution becomes location independent.
      So the answer to your question is: Yes.

      Kind Regards,
      Marcel van de Glind

Leave a Reply