Onload javascript

Is there any way to trigger an onload event. I would like for a method in one of my classes to get called when a particular jsp page is loaded.
So something like
<h:SOMETAG onload="#{mybean.myfunc}" />Or maybe there's a better way to do what I'm thinking: I want to be able to access the application using an external link (passing some parameters). I thought I'd use a regular servlet to handle the doGet method (where I set some parameters in the session), then send the redirect to this jsp page which will call the function I want when the page loads, and JSF will handle the actions from then on.
I know, it's kind of roundabout--but it would be nice to somehow have a way to access the request parameters, make the appropriate function calls & have JSF then forward to the right page based on the returned string. I don't know if this servlet->jsp forwarding to a function in my code is the best approach, or if that's even possible.
Thanks.

Use the constructor or a getter of the backing bean.

Similar Messages

  • Conflicting OnLoad javascript functions

    I am trying to implement two solutions in my application
    1) Controlling window scroll position on a submit and redirect to the same page
    which I have working successfully as per thread
    Control window scroll position on a submit and redirect to the same page
    This solution has the following code in the PAGE HTML Body Attribute
    onload="javascript:ScrollIt()" onscroll="javascript:setcoords()"
    I have 2 items on each page which hold the X,Y co-ords as I scroll. When the page reloads I return to these co-ords in the ScrollIt() onload process.
    2) Sticky Hide and Show Regions as described in the instructions At
    http://www.oracle.com/technology/products/database/application_express/packaged_apps/sample_code.html
    It uses an onload Application process that calls the packaged proc
    show_hide_memory.show_hide_collection_output();
    In the proc the following javascript is called:
    htp.prn('window.onload=function()
    PROBLEM: I can't get both working at the same time! I'm assuming that the OnLoad proc is overriding that other one.
    Any help please would be appreciated...
    regards
    Paul P

    Hello,
    Compile this as the Package Body. I will update the packaged code change in the next day or so.
    create or replace PACKAGE BODY show_hide_memory AS
      PROCEDURE show_hide_collection AS
      l_arr apex_application_global.vc_arr2;
      l_found boolean := FALSE;
      l_collection_name VARCHAR2(255) := 'SHOW_HIDE_COLLECTION';
      BEGIN
        IF(wwv_flow_collection.collection_exists(p_collection_name => l_collection_name) = FALSE) THEN
          htmldb_collection.create_or_truncate_collection(p_collection_name => l_collection_name);
        END IF;
        l_arr := apex_util.string_to_table(p_string => v('TEMPORARY_ITEM'),   p_separator => ']');
        -- If the array member count of l_arr < 3, then the following code will raise an exception
        FOR c1 IN
          (SELECT seq_id
           FROM apex_collections
           WHERE collection_name = l_collection_name
           AND c001 = l_arr(1)
           AND c002 = l_arr(2)
           AND c003 = l_arr(3))
        LOOP
          -- It exists, so delete it
          apex_collection.delete_member(p_collection_name => l_collection_name,   p_seq => c1.seq_id);
          l_found := TRUE;
        END LOOP;
        IF l_found = FALSE THEN
          apex_collection.add_member(p_collection_name => l_collection_name,   p_c001 => l_arr(1),   p_c002 => l_arr(2),   p_c003 => l_arr(3));
        END IF;
        COMMIT;
      END show_hide_collection;
      PROCEDURE show_hide_collection_output AS
      BEGIN
        htp.prn('<script type="text/javascript">' || CHR(10));
        htp.prn('<!--' || CHR(10));
        htp.prn('function pg(){' || CHR(10));
        FOR c1 IN
          (SELECT c003
           FROM apex_collections
           WHERE collection_name = 'SHOW_HIDE_COLLECTION'
           AND c001 = wwv_flow.g_flow_id
           AND c002 = wwv_flow.g_flow_step_id)
        LOOP
          htp.prn('htmldb_ToggleWithImage(''' || c1.c003 || 'img'',''' || c1.c003 || 'body'');' || CHR(10));
        END LOOP;
        htp.prn('}' || CHR(10));
        htp.prn('addLoadEvent(pg)' || CHR(10));
        htp.prn('//-->' || CHR(10));
        htp.prn('</script>' || CHR(10));
      END show_hide_collection_output;
    END;Carl

  • Form Onload Javascript error

    Form Onload Javascript error
    Hello,
    Receiving onload javascript error on the form (see attached file). Any one ever encountered this before ? (NewScale 2008.3, IE 7)
    Thanks in advance for any help!
    - Mihir

    use the MIcrosoft JavaScript debugger, it will show yo uthe line thats failing ...

  • In onLoad JavaScript, I'm getting "Error: Permission denied to access property 'classes'" when I access Components.classes; how do I enable that permission?

    I need to emulate several ActiveX functions in my client's web application. I have located several Mozilla web pages that describe how to do the things I need, and I have attempted to implement those instructions. However, I can't seem to get past the first line of code. In my web page, I am calling a JavaScript function using the onLoad attribute of the <body> tag. I am using the Navigator object to determine that the browser is Firefox. I then attempt to access the extension classes using the following code on lines 51 and 52 of the Download.js file:
    var C = Components;
    var CC = C.classes;
    The Web Console gives me these two messages:
    [13:51:55.621] The Components object is deprecated. It will soon be removed. @ http://distribution:781/NewDDI/DownLoad.js:51
    [13:51:55.621] Error: Permission denied to access property 'classes' @ http://distribution:781/NewDDI/DownLoad.js:52
    How do I enable adequate permission to be able to access the Components classes?

    I think Components is available only in extensions (or otherwise privileged code) and not in ordinary web pages.

  • OnLoad - javascript - where should I include the code?

    Hi, have searched the forum and found that the pleace to include onLoad call should be included in the HTML Body section but when I try to apply the changes I get the error message:
    1 error has occurred
    * You may not declaratively set cursor focus if you specify an ONLOAD in this attribute. You can programatically set cursor focus by using the following syntax:
    onload="mystuff(); first_field();"
    my call is:
    onload="alert('test')";
    Thanks

    Hi,
    Have a look at the Edit Page Attributes for your page. On there is a Cursor Focus setting - make sure this is set to "Do not focus cursor". You can only have one onload for the body tag, so you can't have your javascript and this set to "First item on page"
    Andy

  • How to execute a javascript function in the body onload?

    Hi everyone!
    As you know in the HTML body attribute. You must specify the value of onload
    What is the correct sintaxis for execute a function since in the onload body?
    I only want to do some like this, but only I do it in APEX:
    <body onload ="javascript:namefunction();" >
    I do not know how to use #ONLOAD# when you using want to set some value.
    Could u help me please ?
    Any help would be very appreciated.
    Thank u in advance
    Best Regards

    Hi Chris
    Thank you for your help
    I tried with the next code but it doesn´t work.
    Do you know for what?
    Best Regards
    I paste the next code in the HTML Header :
    <head>
    <script language="JavaScript" type="text/javascript">
    function addLoadEvent(func){
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
    window.onload = func;
    else {
    window.onload = function() {
    oldonload();
    func();
    function ejecuta()
    doSubmit('ACEPTAR_R')
    addLoadEvent( ejecuta );
    </script>
    </head>

  • Execute Javascript in SCRIPT_ITEM onload, but only once

    Hi,
    if I publish my webtemplate then the javascript function (executeJS_SET_ITEM_PARAMETERS_R) inside the script item is executed. The execution is done via onload="javascript:executeJS_SET_ITEM_PARAMETERS_R".
    Within the JavaScript I create some parameters to change some settings of the webtemplate. At then end the command is executed and the template is refreshed.
    1.The problem is that the Javascript is executed recursively (always onload). How can I ensure that the JavaScript is executed only once (the template only refreshed once)?
    2.Within executeJS_SET_ITEM_PARAMETERS_R these lines are commented:
      //To extract specific values of parameters refer to the following:
      //var key = currentState.getParameter( <b>PARAM_KEY</b>).getValue();
      //alert( "Selected key: " + key );
      What is meant by PARAM_KEY? Maybe I can use this parameter to create a condition that ensures to execute the code only once. Where can I found these PARAM_KEYs?
    Thanks for the info.
    BR, Andreas

    You might try this approach, using the following workflow...
    1) *Get Specified Finder Items* -- press the "+" sign, navigate to the target folder and choose it.
    2) *Set Folder Views* -- move the icon slider to 128, etc., and check "Apply Changes to Sub-folders."
    From Automator's File menu select Save As Plug-in > Plug-in for: Folder Actions.
    The AppleScript, located in the User > Library > Scripts > Folder Action Scripts folder, can then be modified:
    on adding folder items to this_folder after receiving added_items
    tell application "Macintosh HD:Users:username:Library:Workflows:Applications:Folder Actions:Make 128.app"
    run -- 'run' replaces 'open added_items'
    end tell
    end adding folder items to
    This has worked for me consistently (so far) using Mac OS 10.4.11; not tested in Leopard. Your results may vary.
    Good luck.

  • Javascript popups in an if-else jsp statement

    hey there!
    i got a question...how can i get a jsp popup box in my jsp if-else statement??
    if (rs.next()) {
    String dbValue = rs.getString("Password");
    if (password.equals(dbValue)) {
         response.sendRedirect("PersonalDetails.jsp");
    else {
         //say its wrong
    else {
         //say its not found
    that is my code. the popup boxes need to say user is not found or wrong.
    thanks!

    Try this.
    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD>
    <TITLE>Graduate Application Form</TITLE>
    </HEAD>
    <%
         Connection con      =      null;
         Statement st      =      null;
         ResultSet rs      =      null;
         String strOnLoadJS = "";
         try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con = DriverManager.getConnection("jdbc:odbc:fypproject","","");
              st = con.createStatement();
              String email = request.getParameter("email");
              String password = request.getParameter("password");
              String query = "SELECT * FROM Login_Details WHERE Email_Address = '" + email + "'";
              rs = st.executeQuery(query);
              if (rs.next()) {
              String dbValue = rs.getString("Password");
              if (password.equals(dbValue)) {
              response.sendRedirect("PersonalDetails.jsp");
              else {
              strOnLoadJS = " onLoad=\"javascript: alert ('User / Password Mismatch');\"";
              //return false;
              else {
              strOnLoadJS = " onLoad=\"javascript: alert ('User not Found');\"";
              //return false;
    %>
    <BODY <%=strOnLoadJS%>
    </BODY>
    <%
         catch (Exception exp)
         finally
              try
                   if (rs != null)
                        rs.close ();
                   if (st != null)
                        st.close ();
                   if (con != null)
                        con.close ();
              catch (Exception exp)
    %>
    </HTML>

  • Assigning a DataProvider filter value with JavaScript

    I have a "Fiscal Yr/Period" filter characteristic in my web application that I am assigning the value of the current month and year when the web application is loaded.  In other words, this filter is applied to the DataProvider when the application loads (code below):
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_DATA_PROVIDER"/>
             <param name="NAME" value="C_LPR_Q018"/>
             <param name="QUERY" value="C_LPR_Q018"/>
             <param name="INFOCUBE" value="ZPP_C01"/>
             <param name='FILTER_IOBJNM' value='0FISCPER'/>
             <param name='FILTER_VALUE' value='H12004010'/>
             DATA_PROVIDER:             C_LPR_Q018
    </object>
    As you can see above, the value for the '0FISCPER' object is hardcoded and thus requires me to change this monthly.  I have written some JavaScript code to calculate the current mo. and yr. however I can't get my JavaScript variable that holds the value I need assigned to the FILTER VALUE.  Can I even assign a JavaScript variable as the filter value?  Is there another way?  Any help would be greatly appreciated.

    Hi Allen,
    if you want to change any param of an object, try the function SAPBWOpenURL, which should be sent against the object you want to change. Documentation is at :
    http://help.sap.com/saphelp_bw33/helpdata/en/f1/0a5a2ee09411d2acb90000e829fbfe/frameset.htm -> Business Explorer ->
    Web Application ... -> Befehl URLs
    Concat the date in JavaScript and call
    SAPBWOpenURL(SAP_BW_URL_Get()+'&item=...&FILTER_IOBJNM="0FISCPER"&FILTER_VALUE="TheDateYouWant"') (I hope I set the " and ' correctly, better you should check).
    For example you can insert :
    <HEAD>
    <script>
        function callTheTableWithTheDate()
            SAPBWOpenURL(like above);
    </script>
    </HEAD>
    <BODY onload="JavaScript:callTheTableWithTheDate()">
    It's only a hint, adjust it for your requirements. You can save the date in a cookie too and reuse it whenever you want. You know how to handle cookies ?
        Bye
        Ralf

  • How to include javascript on form load

    Hello,
    I am new to JDeveloper. I wanted to include multiple javascript files in a jspx file. Then involve one of the functions in the javascript file. Below is what I am trying to do, but seems like the syntax is wrong:
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=windows-1252"/>
    <html>
    <head>
    <script language='JavaScript' src='jslib/script1.js' type='text/javascript'></script>
    <script language='JavaScript' src='jslib/viewer.js' type='text/javascript'></script>
    </head>
    <body onload="javascript:initializeViewer()">
    <f:view>
    <af:document>
    <af:form></af:form>
    </af:document>
    </f:view>
    </body>
    </html>
    </jsp:root>
    When using firebugs, I realized that the page takes only the first js file. Also, the onload event is deleted.
    Thanks for any help

    The following blog post demonstrates this:
    http://thepeninsulasedge.com/blog/2007/06/22/adf-faces-rc-more-on-javascript/
    --RiC                                                                                                                                                                                                                                                                       

  • Af:region, PPR and onload handler

    We develop custom JSF components that need some javascript counterpart on the client.
    These counterparts needs to be initialized (through some AJAX calls) when the page is ready to be displayed.
    In old technologies, this was done through an "onload" javascript handler placed on the page.
    In Apache Trinidad PPR, the page is already loaded when the components are rendered, and we need to register those scripts at render time (in encodeEnd) through :
    ExtendedRenderKitService service =  Service.getRenderKitService(context, ExtendedRenderKitService.class); 
    service.addScript(context, jsMethod);This method is available in ADF, so we can reuse this.
    However, since the default onload mechanism already calls the scripts, and we want the scripts to be called only once, we need to make sure we are in a PPR context by using something like
    reqContext.isPartialRequest(context);Now, in an af:region use case, we are not really in a PPR rendering (isPartialRequest returns false). What API should I use to check that the page is already loaded and we are just rendering a new region in that page ?

    I tried the AdfFacesContext.getCurrentInstance().isInitialRender() through layers of reflection, to keep independent at compile time from ADF.
    However, even when this "initialRender" flag is true, the page rendering (client side) still goes through ADF AJAX calls and does not happen directly in the browser window.
    I need in fact to detect, server side, whether the HTML I'm rendering will be executed directly in the browser (in that case, the "onload" happens) or through some indirection on the client where DOM elements such as "document" or "window" may not exist. In the latter case, I will register a script through the ExtendedRenderKitService class.
    Any idea on the way I can do this in case of an af:region ?

  • Hyperlink - How to execute it action function(Java) and then JavaScript

    Hi all, I have a hyperlink in a popup window. When the hyperlink is clicked I want it's action function to be executed. This works fine, the problem is when I put java code in the hyperlink's javascript onClick() function, only the onClick() gets called and not the action function.
    I need the onClick to close the window and submit the main form and I need the action function to set some session variable.
    Thanks in advance for any replies.

    Hi, thanks to anyone that read my post. I found a solution. I removed the code from the hyperlink's javascript onClick and placed it the body onload javascript function. I also set a flag to true when the hyperlink is clicked and only execute the code in the body onLoad() when the flag is true.

  • How to access via javascript with Oracle Maps to a external Geometry Cache

    If i've defined CTR_10000 as a Web map cache in mapviewer 10.1.3, what is Oracle Maps javascript code to access that
    Layer?
    I've tried:
    vat ctr10kLayer = new MVThemeBasedFOI('ctr10kLayer','CTR_10000');
    ctr10kLayer.enableAutoWholeImage(true);
    ctr10kLayer.setVisible(false);
    mapview.addThemeBasedFOI(ctr10kLayer);
    but dowsn't works,
    Any Suggestion?

    Here's an example (on 10133P5) using demis.nl's wms reference demo site.
    You will have to change the adapter class if you're using 10.1.3
    and use a proxy if necessary and set the tile_storage path
    for your environment
    map tile layer definition
    SQL> select name, is_internal, definition, base_map from user_sdo_cached_maps where name='DEMIS_
    NAME IS_I
    DEFINITION
    BASE_MAP
    DEMIS_WMS NO
    <map_tile_layer name="DEMIS_WMS" image_format="PNG" http_header_expires="168.0"
    concurrent_fetching_threads="3">
    <external_map_source url="http://www2.demis.nl/mapserver/wms.asp" request_met
    hod="GET" timeout="15000" adapter_class="mcsadapter.WMSAdapter" transparent="tru
    e" clipping_buffer="0">
    <properties>
    <property name="service" value="WMS"/>
    <property name="srs" value="EPSG:4326"/>
    <property name="format" value="image/png"/>
    <property name="layers" value="Countries,Borders,Coastlines"/>
    <property name="transparent" value="true"/>
    </properties>
    </external_map_source>
    <tile_storage root_path="/tilecache/"/>
    <coordinate_system srid="8307" minX="-180.0" minY="-90.0" maxX="180.0" maxY="
    90.0"/>
    <tile_image width="256" height="256"/>
    <zoom_levels levels="10" min_scale="5000.0" max_scale="5.0E7" min_tile_width=
    "0.003057205631621593" min_tile_height="30.572056316215935">
    <zoom_level level="0" name="" description="" scale="5.0E7" tile_width="30.
    572056316215935" tile_height="30.572056316215935"/>
    <zoom_level level="1" name="" description="" scale="1.7969068E7" tile_widt
    h="10.98702717691827" tile_height="10.98702717691827"/>
    <zoom_level level="2" name="" description="" scale="6457748.0" tile_width=
    "3.948532710638615" tile_height="3.948532710638615"/>
    <zoom_level level="3" name="" description="" scale="2320794.0" tile_width=
    "1.4190288973267207" tile_height="1.4190288973267207"/>
    <zoom_level level="4" name="" description="" scale="834050.0" tile_width="
    0.5099724714107979" tile_height="0.5099724714107979"/>
    <zoom_level level="5" name="" description="" scale="299742.0" tile_width="
    0.1832745860867039" tile_height="0.1832745860867039"/>
    <zoom_level level="6" name="" description="" scale="107721.0" tile_width="
    0.06586504956878192" tile_height="0.06586504956878192"/>
    <zoom_level level="7" name="" description="" scale="38713.0" tile_width="0
    .023670720323393343" tile_height="0.023670720323393343"/>
    <zoom_level level="8" name="" description="" scale="13912.0" tile_width="0
    .00850636894942392" tile_height="0.00850636894942392"/>
    <zoom_level level="9" name="" description="" scale="5000.0" tile_width="0.
    003057205631621593" tile_height="0.003057205631621593"/>
    </zoom_levels>
    </map_tile_layer>
    SQL>
    Html code to use it. Modify it for your installation and MV version
    <html>
    <head>
    <script language=javascript src="/mapviewer/fsmc/jslib/oraclemaps.js"></script>
    <script language=javascript>
    var mapview;
    function showMap()
    var baseURL = "http://localhost:8888/mapviewer";
    mapview = new MVMapView(document.getElementById("map"), baseURL);
    mapview.addMapTileLayer(new MVMapTileLayer("mvdemo.demis_wms"));
    var mapCenterLon = -100.45;
    var mapCenterLat = 39.6706;
    var mapZoom = 0;
    var mpoint = MVSdoGeometry.createPoint(mapCenterLon,mapCenterLat,8307);
    mapview.setCenter(mpoint);
    mapview.setZoomLevel(mapZoom);
    mapview.addNavigationPanel("EAST");
    var markerFOI = new MVFOI('markerfoi', mpoint, 'mvdemo.m.star',null,15,15);
    mapview.addFOI(markerFOI);
    mapview.display();
    </script>
    </head>
    <body onload="javascript:showMap();">
    <h2>WMS map tile example</h2>
    <div id="map" style="width: 100%; height: 70%"></div>
    </body>
    </html>

  • Javascript with Html-db (Apex)

    Hi everybody,
    My function is :
    <script language="JavaScript1.1" type="text/javascript">
    function desactiverElement(testString,item1,item2)
    { theTest= eval(testString);
    if(theTest)
    for (var i=1;i<4;i++)
    if (arguments)
    disItem = document.getElementById(arguments[i]);
    disItem.style.background = '#C0C0C0';
    disItem.disabled = true;
    else
    disItem = document.getElementById(arguments[i]);
    disItem.disabled = false;
    </script>
    on the page HTML Header, I put:
    OnLoad="javascript: desactiverElement(('document.getElementById(\'P32_ID_FEUILLET\').value != \'\'','P32_ID_FEUILLET','P32_NEQ');"
    It works. It works also when I refresh my page.
    But , when I click on my « create » button, my page is appears with the new data but my field are not still disable = false it comes enable.
    Can someone help me ?
    Thanks. Bye.

    Thank you very much Scott,
    It was my Character set of file that was set to Unicode. I change it to European.... and it works.
    I put my application "27331 - Feuillets" on dkubicek shema. My Onload is on page 32.
    I have some problem creating my tables. I have this message:
    ORA-01658: unable to create INITIAL extent for segment in tablespace FLOW_8897
    Thanks. Bye.

  • Recursive setTimeout becomes inactive through JavaScript console

    Hi,
    I'm using setTimeout() recursively in functions which stops working completely as soon as I trigger an alert-box (alert()) from the JavaScript console. Calling alert() from the document's code itself does not have this effect. Refreshing the site F5 or hard refresh Ctrl+F5 reloads the page but doesn't start the timers. The only way to restore the site completely and get setTimeout() to work again is to close and open the tab or browser again. This seems to be a bug, I think. I'm using Firefox 15.0.1 on Win 7 64-bit.
    See example below. The code below keeps displaying the time in the window's title after clicking the button. If you execute "alert('');" from the JavaScript console instead, it stops all setTimeout() functions and does not reactivate them even if you reload the page.
    Edit: Sorry, heres the code:
    <html>
    <head>
    <script>
    function init()
    callself();
    function callself()
    var now = new Date();
    document.title = now.toLocaleString();
    setTimeout("callself()", 100);
    </script>
    </head>
    <body onload="javascript:init();">
    <button onclick="javascript: alert('');">click me</button>
    </body>
    </html>

    Thanks for the info! Very useful to not become crazy while debugging it

Maybe you are looking for

  • How can I add a password to the saved password list? Or edit a password?

    I changed my password at a site but I cannot change it in the saved passwords.

  • Business Document Object image (OAER) in Smartform

    Hi folks, This topic has been raised before, but no definitive answer has been provided.  We have a Company Logo that has been loaded into the Business Documents repository via txn OAER for ALV Report headers.  We wish to use the same image in our cu

  • Clarification in ESS User Licensing

    Dear All, Greetings! We are to implement ESS in a R3 4.7 Ext 1.10 system through ITS and SAP NW EP 6.0/SP21. ESS Users will be using the portal system to verify their personal details and other functionalities. I have used SSO and User Mapping. As pe

  • Read Excel file and populate in a Table

    Hi, I have a requirement in which i have to read a Excel file and populate it thoroughly in a Table. The rows and column numbers are uncertain. Help me on this... Regards, Krish

  • Phase out of desk intelligence documents

    HEllo there, does anyone know when SAP-BO will phase out the use of Deskintelligence documents? will they keep the viewer active? I did't find any communication about that Many regards Thierry