Step 1 :
Create LOV & Call to Item
Step 2 :
Create Ajax Callback
Name : EMP_LOV
PL/SQL CODE :
DECLARE
V_FIRST_NAME VARCHAR2 (250);
V_LAST_NAME VARCHAR2 (50);
V_SALARY Number(10);
CURSOR cur_c
IS
SELECT LAST_NAME, SALARY
FROM EMPLOYEES
WHERE FIRST_NAME = APEX_APPLICATION.g_x01;
BEGIN
FOR c IN cur_c
LOOP
V_LAST_NAME := C.LAST_NAME;
V_SALARY := C.SALARY ;
END LOOP;
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<body>');
HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
HTP.prn ('<item id="'||APEX_APPLICATION.g_x02||'">'|| V_LAST_NAME || '</item>');
HTP.prn ('<item id="'||APEX_APPLICATION.g_x03||'">'|| V_SALARY || '</item>');
HTP.prn ('</body>');
EXCEPTION
WHEN OTHERS
THEN
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<body>');
HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
HTP.prn ('<item id="'||APEX_APPLICATION.g_x02||'">'|| SQLERRM || '</item>');
HTP.prn ('</body>');
END;
Step 3 :
Create Dynamic Action on the LOV Item (My LOV Item is P7_FIRST_NAME)
Action Name : CALL_EMP_LOV_AJAX
Action : Execute JavaScript Code
Code :
apex.server.process ("EMP_LOV", //You must write Ajax Callback Name//
{
x01: $v('P7_FIRST_NAME'),
x02: 'P7_LAST_NAME',
x03: 'P7_SALARY',
},
{
dataType: 'xml',
loadingIndicator: '#P7_LAST_NAME,#P7_SALARY',
success: function(gReturn)
{
var l_Count = gReturn.getElementsByTagName("item").length;
for(var i = 0;i<l_Count;i++){
var l_Opt_Xml = gReturn.getElementsByTagName("item")[i];
var l_ID = l_Opt_Xml.getAttribute('id');
var l_El = apex.item(l_ID);
if(l_Opt_Xml.firstChild){
var l_Value = l_Opt_Xml.firstChild.nodeValue;
}else{
var l_Value = '';
}
if(l_El){
if(l_El.tagName == 'INPUT'){
$s(l_ID,l_Value);
}else if(l_El.tagName == 'SPAN' &&
l_El.className == 'grabber'){
l_El.parentNode.innerHTML = l_Value;
l_El.parentNode.id = l_ID;
}else{
$s(l_ID,l_Value);
}
}
}
}
});