Using AJAX with ApEx

Hi All,
I'm new to Ajax and I'm trying to create an alert that prompts the user if the information that they entered into a form results in a primary key violation. The problem is that the application procedure that I created is not returning a value when it should be, because I am not receiving the alert when I violate a primary key...I don't know what I am doing wrong. Any help would be much appreciated.
My javascript code is as follows:
function checkNull(){
var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=P3PK',0);
get.add('P3_MEMIMPNUM',$x('P3_MEMIMPNUM').value);
get.add('P3_ACTIONDATE',$x('P3_ACTIONDATE').value);
get.add('P3_ACTION',$x('P3_ACTION').value);
ajaxresult = get.get();
if (ajaxresult)
alert("Primary Key Violation!");
get = null;
The application process P3PK is processed On Demand and the PL/SQL Block is as follows:
DECLARE
str_memimpnum varchar2(15);
BEGIN
SELECT memimpnum
INTO str_memimpnum
FROM tblaction
WHERE memimpnum = :P3_MEMIMPNUM AND
actiondate = :P3_ACTIONDATE AND
action = :P3_ACTION;
HTP.prn(str_memimpnum);
END;
Finally, the save button is set to redirect to a URL and the URL target is as follows:
javascript:onclick=checkNull();
Note: There is more to the checkNull function, but I only included the section that I felt was applicable to this issue.
Thanks in advance!

Hello,
Most likley it's an issue with your OnDemand Process.
Change your alert to
alert(ajaxresult);
And then in your process change it to with a htp.prn('Hello World'); to make sure your calling the right thing.
Then output the item values.
htp.prn(:P3_MEMIMPNUM);
Just work your way through it.
Also you can easily debug these returns using Firebug addon in Firefox. http://www.getfirebug.com
then
Regards,
Carl
blog : http://carlback.blogspot.com/
apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

Similar Messages

  • Problems using Ajax with Apex 3

    Hi folks,
    I've got a client website biult with Application Express on a Oracle Database System. I attached some Ajax funtionallities on fields and there are standard Interactive Reports which are biult on Ajax as well.
    When I try to access the site normally (http) there are occuring no problems at all. But when I try to access the site via https, the Ajax functionallity doesn't work right.
    For example: There is a field named P37_STD_ERFASSTER_WERT which has an onblur javascript event: onblur="viertelstunde_runden(this)". This calls the following javascript function.
    The Java Script code calls an Application Process which calls a PL/SQL function on my database.
    JavaScript code:
    +function viertelstunde_runden(obj) {
    var std = obj.value;
    std = std.replace(".", ",");
    var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=rundStdErfassterWert',0);
    get.add('P37_STD_ERFASSTER_WERT', std);
    result = get.get();
    obj.value = result;
    }+
    So I'm filling '2.4' into the field. After the Process i get the following response: "<html><body><p>2,5</p></body></html>". Does somebody have a clue, why the response is packed into the html tags?
    As a proxy I've got an Apache2 server on a Ubuntu Server 8.1. Is there something wrong defined in the Apache2 Config?
    Thanks for all tips and other helping responses.
    Greetings
    Sandro

    Hi Roel,
    Thx for your quick answer.
    The App-Process looks like this:
    declare
    l_std_erfasster_wert number;
    begin
    l_std_erfasster_wert := br_stunden.runde_viertelstunde(v('P37_STD_ERFASSTER_WERT'));
    htp.prn(l_std_erfasster_wert);
    end;
    And the PL/SQL Procedure on the DB like this:
    -- erfasste Stunden auf Viertelstunde-genau runden
    FUNCTION runde_viertelstunde (
    i_std_erfasster_wert IN stunden.std_erfasster_wert%TYPE
    RETURN NUMBER
    IS
    l_std NUMBER;
    l_min NUMBER;
    BEGIN
    l_std := TRUNC (i_std_erfasster_wert);
    --Rest von Stunden sind Hundertstel-Minuten
    l_min := (i_std_erfasster_wert - l_std) * 100;
    --Hundertselminduten runden auf 25/50/75 oder 100
    l_min := ROUND (l_min / 25) * 25;
    --wenn Minuten aufgerundet auf volle Stunde (100), gibt es eine Stunde mehr
    --und Minuten sind 0
    IF l_min = 100
    THEN
    l_std := l_std + 1;
    l_min := 0;
    END IF;
    RETURN l_std + (l_min / 100);
    END runde_viertelstunde;
    :Sandro

  • Using JQuery with Apex

    Hello, I have a question for those of you who are using JQuery with Apex:
    This is my HTML header:
    <script type="text/javascript" src="&WORKSPACE_IMAGES.jsapi.js"></script>
    <script type="text/javascript">
    google.load("jquery", "1.3.2");
    </script>
    The problem is that JQuery still loads from Google and since the Company Intranet has the cookies blocked the privacy icon appars in IE. I am sure somebody will one day notice this and it's gonna be a "big" problem.
    I suspect that something must be changed below to make the privacy icon dissapear,
    if (!window['google']) {
    window['google'] = {};
    if (!window['google']['loader']) {
    window['google']['loader'] = {};
    google.loader.ServiceBase = 'http://www.google.com/uds';
    google.loader.GoogleApisBase = 'http://ajax.googleapis.com/ajax';
    google.loader.ApiKey = 'notsupplied';
    google.loader.KeyVerified = true;
    google.loader.LoadFailure = false;
    google.loader.Secure = false;
    google.loader.GoogleLocale = 'www.google.com';
    Any ideas how to change this code and if this is going to work?
    George

    Hi,
    If you do not like use jQuery from Google, discard your code
    <script type="text/javascript" src="&WORKSPACE_IMAGES.jsapi.js"></script>
    <script type="text/javascript">
    google.load("jquery", "1.3.2");
    </script>and use e.g. this guide to integrate jQuery to your Apex apps
    http://www.oracleapplicationexpress.com/tutorials/66-integrating-jquery-into-apex
    Br,Jari

  • Values having html tags not getting populated while using AJAX in APEX

    Hi,
    I am using AJAX to populate certain values in a tabular report.
    I have a java script of this form (I have taken this example from Denes's example http://apex.oracle.com/pls/otn/f?p=31517:241:1400877312570049)
    <script language="JavaScript" type="text/javascript">
    function f_set_multi_items_tabular(pValue, pRow){
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=Set_Multi_Items_Tabular',0);
    if(pValue){
    get.add('TEMPORARY_APPLICATION_ITEM',pValue)
    get.add('T_ROWNUM',pRow)
    }else{
    get.add('TEMPORARY_APPLICATION_ITEM','null')
    gReturn = get.get('XML');
    if(gReturn){
    var l_Count = gReturn.getElementsByTagName("item").length;
    for(var i = 0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("item");
    var l_ID = l_Opt_Xml.getAttribute('id');
    var l_El = html_GetElement(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'){
    l_El.value = 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{
    l_El.innerHTML = l_Value;
    get = null;
    </script>
    And I have the application process as follows
    BEGIN
    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="f05_000' || :T_ROWNUM || '">' || :TEMPORARY_APPLICATION_ITEM || '</item>');
    HTP.prn ('</body>');
    END;
    If I have :TEMPORARY_APPLICATION_ITEM as 'Vikas' it gets displayed properly but if I have '&lt;b&gt;Vikas&lt;b&gt;' it shows null. if it has any HTML tags function l_Opt_Xml.firstChild.nodeValue is not working properly .Please tell me what modiifcation can I use in function l_Opt_Xml.firstChild.nodeValue to get Values with HTML tags also to get displayed.
    Thanks,
    Vikas

    Vikas,
    Try escaping special characters: htf.escape_sc(:TEMPORARY_APPLICATION_ITEM)Regards,
    Dan

  • Integrate AJAX  with Apex 3.2

    Hi
    I am new to APEX we are doing enhancements to User Interface using Apex 3.2.
    I want to add generic AJAX tool tip code for similar components in all the pages in apex.
    where do i write the code and how to integrate with with apex pages.
    your help in resolving this issue is highly appreciated.
    Edited by: 817204 on Dec 1, 2010 4:09 AM

    Hi,
    I think this blog post is quite simple for start learn Ajax in Apex
    http://www.oracleapplicationexpress.com/tutorials/68
    Regards,
    Jari

  • Use Ajax with OAF developed in JDeveloper 9i for Oracle Apps 11.5.10.2

    Hi,
    I am looking to use Ajax to have the same Google type functionality to be impelmented in OAF pages.
    Example : Searching of employee names, organization etc.
    JDeveloper version is 9i
    Oracle Apps - 11.5.10.2
    Please advice.
    Thanks,
    Anirban

    I dont think thats possible using OAF. OAF is not designed with AJAX in mind.

  • Using ajax with struts 1.2.9

    Hello Experts ,
    First of all I am sorry if I have posted question in a wrong forum but I have tried posting my problem in struts forum also but didn't get reply & I am pretty new to struts.
    I am trying to use ajax in struts 1.2.9.I have used 1 dependent combo.When I am changing value in 1 combo it will call an action class which will fetch data for 2nd combo .My problem is ,action class "success" has to be forwarded to some particular jsp.But I want to refresh only a part of page not the whole page.How to refresh just a part of page?? Any idea or any link which can help me.Any help in this will be highly appreciated.Many many Thanx in advance.

    Hello Shasi,
    Lets take the sample code for one combo box (College) , one change of which I want to display the information of that college in the textboxes below it.So on change of college combo I am calling the action class which is retrieving info of college.My problem is now how to send this data to jsp & what should be the success & failure forward for my action class.
    In my JSP I have written something like this....
                           createXMLHttpRequest();
                            queryString2 ="retrieve_college_info.do?";
                            queryString2 = queryString2 + "selcollege="+document.forms[0].college_name.options[document.forms[0].college_name.selectedIndex].value;
                            xmlHttp.open("GET", queryString2, true);
                            xmlHttp.onreadystatechange = handleCollegeRetrieve;
                            xmlHttp.send(null);My action class code goes like this
    package ibm.tgmc_nextyear.actionclass;
    import ibm.tgmc_nextyear.businesslogic.*;
    import ibm.tgmc_nextyear.formbean.*;
    import java.io.PrintWriter;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForward;
    import java.sql.*;
    import java.util.ArrayList;
    import org.apache.struts.util.LabelValueBean;
    public class CollegeRetrieveInfoAjaxAction extends org.apache.struts.action.Action {
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
                   String optionSelected = request.getParameter("selcollege");    
                   String responseText="";
                   Connection conn = null;
                   Statement stmt = null;
                   ResultSet rs = null;
                   TeamDetailsForm team_frm = null;
                   try {
                        conn = getDataSource(request).getConnection();
                        stmt = conn.createStatement();
                rs = stmt.executeQuery("select name , address  , city , pincode , ph_no , hod_name , principal_name , alt_no , website from user.college_table where college_id=" + optionSelected);
    *//what after this ???*
            } finally {
                if (rs != null) {
                    rs.close();
                if (stmt != null) {
                    stmt.close();
                if (conn != null) {
                    conn.close();
             *//what should be the value os success forward*
           return(mapping.findForward("success"));
    }

  • Can I use Ajax with jsf

    Hi All,
    Is JSF 1.1 supports AJAX or not???
    Please tell me..

    JSF RI 1.1 = Java Server Faces Reference Implementation 1.1.
    It is the Sun reference implementation of JSF. There are also 3rd party implementations of JSF available, like MyFaces, Tomahawk, IceFaces, ADF, etcetera.
    If you aren't limited to JSF RI version 1.1, I recommend you to use version 1.2. It provides more features and benefits.
    Here are some links:
    https://javaserverfaces.dev.java.net
    http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/
    http://jsftutorials.net
    http://java.sun.com/javaee/5/docs/tutorial/doc/ (starting at chapter 9)
    http://jboss.org/projects/jbossAjax4jsf (most widely used AJAX library for JSF)

  • Using alerts with ApEx 2.2

    I want to use alerts from an ApEx application (after I insert to a table for example), the problem is that alerts can only be run as the apps account.
    Is there a way to make alerts work?

    The question was misunderstood.
    Because Oracle apps uses a different security scheme then apex you'll really have to code for it within your alert. Any user that updates/inserts/deletes on the table you would base your alert on will fire the trigger not just "apps" user. However because the apex users are not apps and not in fnd_user table the transaction would get recorded as anonymous user (user_id = -1). Probably the best you could do would be put some "if" statements in your alert to check for user not found in fnd_user then make a v('APP_USER') call to get the apex user_name. Because your dealing with two different security schemes you can't do anything but work around's.
    Todd

  • Best Practices of using AJAX with JSF : BluePrints or  Ajax4Jsf ?

    am a newbie to AJAX4JSF . I think it provides Rapid Application Development (RAD) just by using tags like a4j: without the need to develop complex JSF Custom Components as shown in BluePrints Catalog
    https://bpcatalog.dev.java.net/ajax/jsf-ajax/
    I understand the purpose of developing JSF Custom components as Reusable for using with AJAX. But its complex and requires lot of coding i.e. PhaseListeners and Managed Beans. There should be easy way to do this especially our project needs RAD tool like AJAX4JSF.
    Any suggestions will be highly appreciated
    Regards
    Bansi

    Bansi, you are trying to compare orange-to-apple. Blue print catalog is a historical retrospection about what people thought about AJAXifying JSF in the past. Currently, the playground has been moved to the jsf-extension project. Look for DynaFaces there.

  • Problem while using Ajax in APEX.

    Hi All,
    I am using the this function in my application to overcome the && problem.. here is the query
    DECLARE
    l_counter NUMBER;
    l_o_name VARCHAR2 (2000);
    BEGIN
    FOR rec IN (SELECT distinct HTF.ESCAPE_SC (atct_attr_type) a,HTF.ESCAPE_SC (atct_attr_type) b
    FROM t_new
    WHERE atct_atcl_code =:F41_ATCL_ATT_TYPE_REP_CODE )
    LOOP
    --HTP.prn ('<option value="' || rec.b || '">' || rec.a || '</option>');
    dbms_output.put_line('<option value="' || rec.b || '">' || rec.a || '</option>');
    end loop;
    END;
    it is working fine with out any issues..
    But i want to show atct_attr_type in upper case..
    How to use upper case in the above query..
    Thanks,
    Anoo..

    Whats the problem with using the UPPER Function
    HTF.ESCAPE_SC (UPPER(atct_attr_type)) in the SQL Query(for loop inline cursor)

  • Using Port with apex

    I need some help...
    I need some examples using port(serial, usb or paralelo) any execise please send it... to [email protected]
    i want do a lot of things with it... or if you know where are there examples on the web.. please tell me
    Thank u,

    HTML is NOT really meant to do ANYTHING with the ports, you would need to look at Java or another higher level language.. What exactly ar eyou looking to do with the Ports?
    Also, isn't this a duplicate of your other posting from today? Help in Apex3.2
    Please try not to double post about the same topic..
    Thank you,
    Tony Miller
    Webster, TX

  • Anyone use AJAX with Learning Management Systems

    I recently upgraded to Dreamweaver CS3. After looking at it
    briefly the thought occured to me that the AJAX functionality might
    be applied to Learning Management System courses. Typically,
    courses fired through a Learning Management System (LMS) use AICC
    or SCORM compliant JavaScript in order to achieve the user scoring
    interactions.
    Has anyone employed the AJAX functionality in Dreamweaver CS3
    to enhance LMS functionality? Any Thoughts?
    Thank you,
    TPK

    It should be perfectly fine to include it in head - depending on wha you want.
    Try to use Firebug for firefox to debug errors.
    You can add plugins to wordpress that makes it easier to include scripts.

  • I am Using Ajax with DWR while running the application i am getting error?

    Hi,
    I am using DWR concept while running the program i am getting the following error:
    uk.ltd.getahead.dwr.util.CommonsLoggingOutput info INFO: Exec[0]: Demo.sayHello()
    and also all the methods that are there in that Java class. Plz anybody help me how to overcome this problem

    Hi Rameshkumar,
    The workaround mentioned by Chris will not be required in future versions of TopLink 10.1.3. We have removed our dependency on the 3-arg javax.xml.namespace.QName constructor that is not present in the WebLogic 8.1 distribution of the QName class.
    -Blaise

  • Which FrameWork is Best Suitable For Using AJAX with JAVA

    And what are other differences between AJAX And Java Script other Than XMLHttpRequestObjects..i would be glad for any help or guidence given...

    And what are other differences between AJAX And Java Script other Than XMLHttpRequestObjects..i would be glad for any help or guidence given...

Maybe you are looking for

  • SWF movie export on frame-by-frame basis WITH actionscript

    Hi there, I know they're two ways of exporting flash movies: Export the whole timeline. This only allows timeline animations and gets messy because you have to cram up everything on the main timeline. Realtime-Export via Quicktime. This is a "full bl

  • Regarding BDC

    Hi What is the difference between GUI_DOWNLOAD & WS_DOWNLOAD... and GUI_UPLOAD & WS_UPLOAD

  • Tree In TableView Using Iterator

    Can I creat a Tree in a TableView using Iterator( Which is implemented as a local class in a Model Class)

  • My iphone 4 is block

    Good afternoon, I'm French. Ok here is my problem. My iphone 4 is block, and he was power on not long before he block. I sent a sms and locked the iphone, 5 minutes after, i want to check if i had a reply, and, i cannot do anything, the screen is pit

  • Loopback adapter and zonealarm

    Hi, I tried to install Oracle Enterprize Edition but i got problem with DHCP so i installed a loopback adapter.However I think that zonealarm causes problem .Is there any solution. Do I have to unistall it or can I do something else. Thanks