<-----Google Analytics Code Start----> <-----Google Analytics Code Close---->
Skip to content

Green

color

Default screen resolution  Wide screen resolution  Increase font size  Decrease font size  Default font size  Skip to content Default color Pink color Green color Green color

Who's Online

We have 1 guest online

Related Items

Home
This website has now moved to http://apps2fusion.com





LOV in Mobile Web Applications - Part 1 | Print |  E-mail
Written by Senthilkumar Shanmugam   
Friday, 15 February 2008

Handling LOVs in Mobile ApplicationsImage

In this article, we will see how to handle LOV bean in MWA.
In this example, we will create an LOV which displays the list of users from fnd_user ptable starting with ‘S’.
You can use these code snippets and make changes to the Hello world Sample Program which was published earlier and test it out.
The following are the steps to be performed.


Step 1:

In CustomTestPage.java, declare the variable for LOV, set properties like prompt, ID, Listener and add a handler method to the LOV

LOVFieldBean mUserNames;
mUserNames = new LOVFieldBean();
mUserNames.setName("TEST.LOV");
mUserNames.setPrompt("User LOV");

addFieldBean(mUserNames);
mUserNames.addListener(fieldListener);

public LOVFieldBean getUserLOV()
{
return mUserNames;
}


Please note that the handler method will be used in Listener Class to get handle of the bean.


Step 2:

Getting the List of Values for LOV. As we know LOV is nothing but a result set of a query. This result set can be attached to the LOV by 2 ways.

  1. By SQL Query.

  2. By a PLSQL package which executes the query and gives the result set as OUT parameter (via REF CURSOR)


In this example, we are going to use the following PLSQL package. This package basically gets all the users from FND_USER starting with the alphabet provided as a input parameter. The Code is as follows:

create or replace package XXX_MWA_LOV_TEST AS
    TYPE t_ref_csr IS REF CURSOR;
    PROCEDURE XXX_USERS_LOV (x_users OUT NOCOPY t_ref_csr
    ,p_user_name IN VARCHAR2);
end XXX_MWA_LOV_TEST;



create or replace package body XXX_MWA_LOV_TEST AS
PROCEDURE XXX_USERS_LOV (x_users OUT NOCOPY t_ref_csr
,p_user_name IN VARCHAR2
)

IS
BEGIN
OPEN x_users FOR
select user_id,user_name,description
from fnd_user
where user_name like p_user_name;

EXCEPTION
WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR IN USER LOV '|| SQLERRM);
END XXX_USERS_LOV;

end XXX_MWA_LOV_TEST;



Step 3:

In CustomTestListener.java, as we know there are two methods “fieldEntered” and “fieldExited”.

In FieldEntered, we have to execute PLSQL procedure and get the results and display it to user.

In FieldExited, we have to get the values selected by the user in the LOV.


public void fieldEntered(MWAEvent mwaevent)
        throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException {

ses = mwaevent.getSession();

String s = UtilFns.fieldEnterSource(ses);

 

if (s.equals("TEST.LOV")) {

userLOVEntered(mwaevent);

return;

 

}

}




public void fieldExited(MWAEvent mwaevent) throws AbortHandlerException,InterruptedHandlerException, DefaultOnlyHandlerException {

ses = mwaevent.getSession();

String s = UtilFns.fieldEnterSource(ses);

if (s.equals("TEST.LOV")) {

userLOVExited(mwaevent);

return;

 

}

}






In the above code, we call the custom methods userLOVEntered() and userLOVExited() to handle the events.


public void userLOVEntered(MWAEvent mwaevent) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException

{

 

UtilFns.trace("User LOV Entered");

try{

Session session = mwaevent.getSession();

//set the package and procedure name to be called

pg.getUserLOV().setlovStatement("XXX_MWA_LOV_TEST.XXX_USERS_LOV");


//Parameter Type, parameters and Prompts of the field in LOV

// C – cursor, AS/S – String, N – Numeric, AN - AlphaNumeric


String paramType[] = {"C", "AS" };

String parameters[] = {" ", "S%" };


//Set the prompts and visible fields for LOV result table

//We don’t want user id to be displayed in result table. So we //are setting it to false.

//These fields directly map to the selected columns in SELECT //statement of REF CURSOR

String prompts[] = { "USER_ID", "User Name", "Description" };

boolean flag[] = { false,true,true };


//Associate the properties to the LOV bean

//Properties for SQL Query

pg.getUserLOV().setInputParameterTypes(paramType);

pg.getUserLOV().setInputParameters(parameters);


//Properties for LOV Result Table

pg.getUserLOV().setSubfieldPrompts(prompts);

pg.getUserLOV().setSubfieldDisplays(flag);


}

catch(Exception e){

UtilFns.error("Error in calling LOV");

}

}

 

 


In the above code, we have pointed out the PLSQL procedure to be executed for List of Values and also we set the parameters, parameter types. Also, we mentioned the prompts for LOV results table and also what are all the visible fields available to user.


In this example, we have hardcoded the input parameter to “S%” so that the result set will have all users from FND_USER starting with “S”. In real time scenario, we can link this parameter dynamically to any variables.


public void userLOVExited(MWAEvent mwaevent) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException

{

UtilFns.trace("User LOV Exited");

try{

 

//Get the selected row in a vector and print it


Vector v = pg.getUserLOV().getSelectedValues();

if(v!=null) {

UtilFns.trace("first " + v.elementAt(0).toString());

UtilFns.trace("second " + v.elementAt(1).toString());

UtilFns.trace("third " + v.elementAt(2).toString());

}

 

}

catch(Exception e){

UtilFns.error("Error in processing LOV");

}

}




In the above method, as soon as the user selects the values, we get the selected values in a Vector.

After that we print the user_id, user name and description of the selected user in the Log.

See the following screen shots for further understanding.


Fig 1: Mobile page with Text Bean and LOV

Image

Fig 2: When the user clicks LOV, result page is displayed in a different window.

Image


 

Fig 3: After the value is selected, the LOV field is populated with the selected value.

Image







Values printed in Log file:


[Fri Feb 15 14:50:11 CET 2008] (Thread-15) User LOV Entered

[Fri Feb 15 14:51:39 CET 2008] (Thread-15) CustomFListener:fieldExited:fldName = TEST.LOV

[Fri Feb 15 14:51:39 CET 2008] (Thread-15) User LOV Exited

[Fri Feb 15 14:51:39 CET 2008] (Thread-15) first 1589

[Fri Feb 15 14:51:39 CET 2008] (Thread-15) second SENTHILK

[Fri Feb 15 14:51:39 CET 2008] (Thread-15) third Shanmugam, SenthilKumar





The above error log is done by the code written in userLOVExited() method.




In this example, we have just printed the selected value in the Log file. In real time scenario, we can use this selected value to be the criteria for the next field or it will be used to do some validations etc.




Comments (8)add
LOV Parameter types
written by Ritesh M , February 21, 2008
Hi Senthil,

I'm working on Oracle Apps 11i manf modules along with MSCA. I've created 4 custom MSCA forms. One of the problem that i experienced is the Field width....generally if you create a MSCA screen and include two fields 1) TextField 2) LOVBean the width of both of fields varies...you can enter the larger value but lovfield dispalys lesser width than TextField. I raised an TAR too..but couldn't find any solution for this. Is there any way to control the LOV filed Size.

Regards,
Ritesh
upgrade AP CHECK PRINT in 11.5.7 to R12 XML publisher
written by sivakumar , February 21, 2008
We are migrating customized AP Check print report from RDF in 11.5.7 to R12 XML Publisher report. We have 18 reports to convert.
I have followed
http://oracle.anilpassi.com/xml-publisher-concurrent-program-xmlp-2.html

link to do the same.
I am facing the follwoing issue.
I am getting empty output after did all the changes as per the ablove link
But only modification i did is, as in R12 we ahve separate top for Payments. But we dont have Report folder under IBY_TOP. So I am keeping my RDF report in AP_TOP and I have created executable under ap_top then Program under Payment_top. Remaining are same.
But I am not getting the output.

Pl. let me know, what I did is same or how to proceed
this is very urgent. so expecting the reply at the earliest

...
written by SenthilKumar , February 21, 2008
Hi Ritesh,

If you want to restrict the size of input text, you can use oracle.apps.mwa.beans.InputableFieldBean.setLength(int) method.

However, in Mobile applications, the display unit will be too small and I really dont know how the length of a field would really be a concern.

Can you please brief your exact requirement?

Thanks and Regards,
Senthil
LOV
written by Ritesh M , February 22, 2008
Hi Senthil,

Actually if you will see the LOV display unit on Standard MSCA forms the unit size is same as of text field...but if you create any custom LOV its dispaly unit size is small as compare to TEXTFIELDBEAN. I tried my level best..but couldn't find any property.......if you know pls share ?

Regards,
Ritesh
Display values based on partial entry in field
written by brad , March 17, 2008
Hi Senthil,

Quick question. If I wanted to populate the LOV based on entering a partial value in the user field, how do I represent that partial value in the user field in the parameter array rather than the hard coded "S%"??

Thanks,
Brad
...
written by SenthilKumar , March 17, 2008
Hi Brad,

You can do that very well. You can get the value entered in any field and pass that value as a parameter to the method which is calling the PLSQL procedure. You can substitute that parameter value instead of hardcoded 'S%'.

Thanks,
Senthil
LOV value
written by Brad , March 17, 2008
Hi Senthil,

Can you show me some example code? I have been trying to figure out how to pass the partial value and can't seem to figure it out. I am a pl/sql programmer and have just rudimentary java skills. I've been looking at the LOV classes for examples, but I'm still puzzled.

Thanks!
Brad
...
written by SenthilKumar , March 23, 2008
Hi Brad,

please see my comments at

http://apps2fusion.com/contributors-mainmenu-58/senthilkumar-shanmugam-mainmenu-62/43-senthilkumar-shanmugam/226-lov-in-mobile-web-applications-part-1#comments

Regards,
Senthil
You must be logged in to a comment. Please register if you do not have an account yet.

busy