How to execute a method after page Load?

My question is very similar to what was discussed in following thread:
How to execute a method after page Load?
My requirement is that I want to run a method in backing bean of a page, immediately after the page gets loaded. In that method I want to invoke one of the method action included in the pagedef of this page, conditionally.
I tried using the approach given in the above thread, i.e to use <f:view afterPhase="#{backing_security.setPermPriv}">, but the problem is that our page is not using 'f:view' , so I explicitly added one f:view with afterPhase property set , but it is not working, page it self is not getting loaded, it is throwing the error:
Root cause of ServletException.
java.lang.IllegalStateException: <f:view> was not present on this page; tag [email protected]e8encountered without an <f:view> being processed.
     at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:108)
     at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:733)
     at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
     at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:71)
     at oracle.adfinternal.view.faces.taglib.UIXQueryTag.doStartTag(UIXQueryTag.java:41)
     at oracle.adfinternal.view.faces.unified.taglib.UnifiedQueryTag.doStartTag(UnifiedQueryTag.java:51)
     at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
     at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:262)
     at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
     at oracle.jsp.runtimev2.ShortCutServlet._jspService(ShortCutServlet.java:89)
     at oracle.jsp.runtime.OracleJspBase.service(OracleJspBase.java:29)
     at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:665)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:387)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:822)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:746)
Please help to resolve this issue, or am I doing anything wrong?

Hi,
I assume that your view is a page fragment and here - indeed - the f:view tag cannot be used. If you use ADF then one option would be to use a custom RegionController on the binding layer to listen for the render phase to invoke the method. Another option would be to use a hidden field (output text set to display="false" and have this component value referencing a managed bean property. The managed bean property's getter method can now be used to invoke the method you want to run upon view rendering
Frank

Similar Messages

  • How to call java method on page load?

    How to call java method on page load?
    Thanks

    Hey Dan,
    Well, if you want to execute a java method when page is load, you need to put the clientlistener in af:document. Let me to show you an example (I can't find my post :P),
    JSPX page:
    <f:view>
    <af:document>
    <f:verbatim>
    <script>
        function loadPage(event) {
            alert('Hello World!');
    </script>
    </f:verbatim>
    <af:clientListener method="loadPage" type="load"/>
    </af:document>
    </f:view>If you try this code you can see that when the page has been load, you recieve the alert "Hello World!".
    Furthermore, this is the javascript AJAX function that let you to call a servlet:
    function ajaxFunction () {
        var httpRequest;
        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            httpRequest.overrideMimeType('text/xml');
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('GET', '/appname/servletname', false);
        httpRequest.send('');
    function alertContents(httpRequest) {
        if (httpRequest.readyState == 4) {
            if (!httpRequest.status == 200) {
                alert('Request error. Http code: ' + httpRequest.status);
    }Where 'appname' is your application name and 'servletname' is the name of the servlet that you want to call. Obviously, you can call any URL ;)
    JVN

  • How to execute a method when page is loaded

    hi ,
    I have a custom method in backing bean of a .jspx page. I want to execute it by default when the .jspx page is loaded.can anyone say how to do it?

    Hi,
    depends on what this is doing: You can call it in a PhaseListener, or from the page using a EL reference (e.g. output textfield that shows empty) or by customizing the ADF pagelifecyce.
    You may want to have a look at
    http://thepeninsulasedge.com/frank_nimphius/2007/08/09/jsf-hook-into-the-javaserver-faces-page-load/
    Frank

  • Adf faces: execute bean method after table is loaded

    Hi,
    How can I execute a method after an adf table is rendered on the page?
    This is what I want to do:
    I have a master/detail:
    - the master part contains a list of materials
    - the details contains a list of customers and volumes depending on the selected material.
    I tried to add totals on the details table:
    - I created an output text in the footer-facet of the colums containing volumes
    - I created a binding of the detail table to a CoreTable.
    - I created a method in a managed bean related to this CoreTable binding, so I can browse to all rows in the table and calculate the sum.
    - I then set the value of the output text to the total calculated in the managed bean.
    the problem is that I don't know how to execute the calculate procedure after the data in the detail table exists.
    What I tried:
    - call the calculate procedure in the setCoreTable method. --> at this point, there is no data in the table and this results in a nullPointerException when the pages is loaded.
    - call the calculate procedure on the valueChangeListener of the material list --> this doesn't work because totals are calculated for the previous details set.
    - I tried to add the call in one of the table listeners but I cannot find a listener that is executed after data is loaded in the table...
    for testing purpose only, I added a button: calculateTotals that calculates the totals. This works correctly.

    Hi,
    if you use page fragments exposed in an ADF region, you have two options I see
    1. Use a method call activity to call the managed bean
    2. Use a hidden UI component that references the setter/getter exposed in a managed bean and just use this as an indication for the page fragment being loaded
    Keragala

  • How to execute the method of a class loaded

    Hi,
    I have to execute the method of com.common.helper.EANCRatingHelper" + version
    version may be 1,2, etc
    if version = 1 the class is com.common.helper.EANCRatingHelper1;
    Iam able to load the class using following code.But iam unable to execute the method of the above class
    Can anybody help me how to execute the method of the class loaded.
    Following is the code
    String version = getHelperClassVersion(requestDate);
    String helperClass = "com.redroller.common.carriers.eanc.helper.EANCRatingHelper" + version;
    Class eancRatingHelper = Class.forName(helperClass);
    eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.
    Thanks

    eancRatingHelper.newInstance();Ok, that creates an instance, but you just threw it away. You need to save the return of that.
    Object helper = eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.Of course. eancRatingHelper is a Class object, not an instance of your EANCRatingHelper object. The "helper" object I created above is (though it is only of type "Object" right now) -- you have to cast it to the desired class, and then call the method on that.
    Hopefully EANCRatingHelper1 and 2 share a common interface, or you're up the creek.

  • How to do data validation after each load

    Hi all,
    How to do data validation after each load.
    please send to : [email protected]
    bhaskar

    Hi Bhaskar,
    Check these posts:
    Re: Validation of data in BW?
    Re: validate data
    Bye
    Dinesh

  • How to execute closing cockpit after completed the configuration?

    Hi Expert,
           Please help, how to execute closing cockpit after completed the configuration? or if who have a document it will be helpful.
    Best regards,

    components of closing cockpit
    Organizational Hierarchies (Company Codes, Controlling Area, Operating Concern, etc)
    Task List template (Preconfigured templates available)
    Task Lists: Derived from template and extremely crucial for successful definition of the month-end close.
    Dependencies between the tasks
    Monitor
    Detailed information
    5 steps for setting-up Closing Cockpit
    Conduct Planning and Research
    Create the basic template data
    Build the closing template hierarchy structure
    Configure individual tasks
    Change the template to an executable task list
    For delivering the Closing Cockpit successfully, you need to have a clear understanding of the current closing routines, the required tasks, who is responsible for each task, which tasks when executed should affect which level of the organization, and finally a clear process for review and documentation.

  • How to call a method after a page  complete load

    Hi,
    Environment: JSF1.2.12+Spring
    I have a startpage, i will call a methode after startpage complete load. (I do not want to use javascript)
    How can i implement it.
    Edited by: zlzc2000 on Nov 6, 2009 2:53 AM

    goal: optimize load startpage(accelerate to load startpage)
    in startpage i use sql to load user's information, that in startpage is required.
    in other page i need the complete User Object (hibernate load user Object).
    i want to after dispay startpage load the user Object whith Hibernet.
    if during load startpage with hibernate to load user object, that is too slow.
    concept: 1step: with sql load user information (not full, for example: id, forename, surname,...)
    2step: results display( load startpage )
    3step: after load complete startpage, call method to load user object(it include all information of user )
    then the user object can be uesed in anywhere in the future.
    but i dont know how to impement it.
    Edited by: zlzc2000 on Nov 6, 2009 3:37 AM

  • How to call a javascript method after table load on JSFF Fragment load?

    Hello,
    The usecase is to invoke a javascript method after table is done loading (fetching data) when user lands to a JSFF fragment. With JSPX pages I can achieve that by using PagePhaseListener. I have tried with RegionController as follows, and the problem i face is that I cannot prevent multiple calls to the Javascript call when user presses a tab or button in a screen, or changes drop-down value with autosubmit on.
    import javax.faces.context.FacesContext;
    import oracle.adf.model.RegionBinding;
    import oracle.adf.model.RegionContext;
    import oracle.adf.model.RegionController;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class MyListener implements RegionController{
    public MyListener() {
    super();
    @Override
    public boolean refreshRegion(RegionContext regionContext) {
    int refreshFlag = regionContext.getRefreshFlag();
    System.out.println("Render flag is: "+refreshFlag);
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    initializeMethod();
    regionContext.getRegionBinding().refresh(refreshFlag);
    return false;
    public boolean validateRegion(RegionContext regionContext) {
    regionContext.getRegionBinding().validate();
    return false;
    public boolean isRegionViewable(RegionContext regionContext) {
    return regionContext.getRegionBinding().isViewable();
    public void initializeMethod() {
    FacesContext f = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(f, ExtendedRenderKitService.class);
    service.addScript(f, "myJSFunction();");
    @Override
    public String getName() {
    return null;
    I need the javascript to be called only once after the table is done loading when user lands to a fragment (jsff).
    Any ideas appreciated?
    JDeveloper version is 11.1.1.5.0
    Thank you.
    Valon
    Edited by: Valon on Apr 11, 2013 3:10 PM

    One of the requirements is to compare every row with the next row and highlight the changes. There are other requirements as well where JavaScript solution is used.
    The question remains the same. Is it doable or not without changing the solution from JavaScript solution to server-side solution ? Can we call a JavaScript only once when the user lands to a jsff fragment ?
    Hope that is clear.
    Thanks.
    Valon

  • How to access the URL on page load and open it in the new tab of browser

    Hi All,
    I am using Jdeveloper 11.1.1.5 and i have one page "Hello.jspx" and one data control consist of two attributes :-one is "id" and other is "url".
    The datacontrol has been created from the WebService.
    Now my requirement is : -
    whenever i run the page "Hello.jspx" , then on page load the url attribute should get accessed and should be opened in a new window or tab of the browser.As the url contains the information about the document.
    Hello.jspx page doesn't contain any bindings of the url attribute.
    I had thought of using the PhaseListener class and use the onPageLoad method .But how do i get the url from the dataControl and open it in the other tab of the browser on page load.
    Please suggest!!!!
    Thanks.

    Hi,
    I don't think this can be done this way. I would think that you need to execute JavaScript upon Hello.jspx load to open a new window and pass the URL to it
    Frank

  • Using af:clientListener after page load

    Hi,
    I need to run a js function after* the page finishes loading.
    I tried to use <af:clientListener type="load" method="fillProjectList"/>, but the script starts running before the table on the page finished loading.
    The table has: clientComponent="true"
    How can I make the script to start runng only after all table components are loaded?
    Thank you,
    Nina

    Ah.. i guess it will not work as you cannot do any UI activity after the render response phase. May be try this
    Javascript into JSPX and run after page is loaded?

  • How to execute applets method from jsp?

    Hi ,
    I have a query.I have a jsp page
    on loading the jsp page the applet should be
    loaded.And i have a button in my jsp page on clicking
    the button a method written in the applet class should
    be executed .How can i do this.Iam attaching the
    classes also.There r two java files.One is EXPosApplet.java and other is EXPos.java
    In the EXPosApplet.java i have a method called
    RunNotepad().This method should be executed when i click the
    button in my jsp page.Pls provide me with some code to load the applet and execute the method of applet.It is a bit urgent.
    Thanks
    Naveen
    The following is my
    EXPos.java class.Following this is my EXPosApplet.java class.
    EXPos.java
    package SumberPutra.External;
    import java.io.*;
    public class EXPos extends Object {
         * Constructor
         public EXPos() {
    private static void RunIt(String fileName){
         try {
         Runtime.getRuntime().exec(fileName);
              catch (SecurityException e) {
    System.out.println("ExecFile: caught security exception: " + e) ;
    catch (IOException ioe) {
    System.out.println("ExecFile: caught i/o exception: " + ioe);
    public void RunNotepad(){
         String fname = "notepad.exe";
    RunIt(fname);
    EXPosApplet.java
    package SumberPutra.External;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class EXPosApplet extends JApplet {
         boolean isStandalone = false;
         private EXPos expos = new EXPos();
         JButton jButton1 = new JButton();
         JLabel jLabel1 = new JLabel();
         * Constructs a new instance.
         * getParameter
         * @param key
         * @param def
         * @return java.lang.String
         public String getParameter(String key, String def) {
              if (isStandalone) {
                   return System.getProperty(key, def);
              if (getParameter(key) != null) {
                   return getParameter(key);
              return def;
         public EXPosApplet() {
         * Initializes the state of this instance.
         * init
         public void init() {
              try {
                   jbInit();
              catch (Exception e) {
                   e.printStackTrace();
         private void jbInit() throws Exception {
              this.setSize(new Dimension(400, 156));
              jButton1.setText("jButton1");
              jLabel1.setText("jLabel1");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        jButton1_actionPerformed(e);
              this.getContentPane().add(jButton1, BorderLayout.NORTH);
              this.getContentPane().add(jLabel1, BorderLayout.SOUTH);
         * start
         public void start() {
         * stop
         public void stop() {
         * destroy
         public void destroy() {
         * getAppletInfo
         * @return java.lang.String
         public String getAppletInfo() {
              return "Applet Information";
         * getParameterInfo
         * @return java.lang.String[][]
         public String[][] getParameterInfo() {
              return null;
         static {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch(Exception e) {
                   e.printStackTrace();
    public void ExecNotepad(){
         expos.RunNotepad();
    /*     void jButton1_actionPerformed(ActionEvent e) {
    try
              Runtime.getRuntime().exec("notepad.exe");
              catch (SecurityException ex) {
    // strMsg = "ExecFile: caught security exception: " + e ;
    jLabel1.setText("ExecFile: caught security exception: " + ex) ;
    catch (IOException ioe) {
    // strMsg = "ExecFile: caught i/o exception: " + ioe;
    jLabel1.setText("ExecFile: caught i/o exception: " + ioe);

    Iam new to java .Can u please give me the code to load the applet and execute applets method
    Thankyou

  • How to execute Applet method from jsp?

    Hi ,
    I have a query.I have a jsp page
    on loading the jsp page the applet should be
    loaded.And i have a button in my jsp page on clicking
    the button a method written in the applet class should
    be executed .How can i do this.Iam attaching the
    classes also.There r two java files.One is EXPosApplet.java and other is EXPos.java
    In the EXPosApplet.java i have a method called
    RunNotepad().This method should be executed when i click the
    button in my jsp page.Pls provide me with some code to load the applet and execute the method of applet.It is a bit urgent.
    Thanks
    Naveen
    The following is my
    EXPos.java class.Following this is my EXPosApplet.java class.
    EXPos.java
    package SumberPutra.External;
    import java.io.*;
    public class EXPos extends Object {
    * Constructor
    public EXPos() {
    private static void RunIt(String fileName){
    try {
    Runtime.getRuntime().exec(fileName);
    catch (SecurityException e) {
    System.out.println("ExecFile: caught security exception: " + e) ;
    catch (IOException ioe) {
    System.out.println("ExecFile: caught i/o exception: " + ioe);
    public void RunNotepad(){
    String fname = "notepad.exe";
    RunIt(fname);
    EXPosApplet.java
    package SumberPutra.External;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class EXPosApplet extends JApplet {
    boolean isStandalone = false;
    private EXPos expos = new EXPos();
    JButton jButton1 = new JButton();
    JLabel jLabel1 = new JLabel();
    * Constructs a new instance.
    * getParameter
    * @param key
    * @param def
    * @return java.lang.String
    public String getParameter(String key, String def) {
    if (isStandalone) {
    return System.getProperty(key, def);
    if (getParameter(key) != null) {
    return getParameter(key);
    return def;
    public EXPosApplet() {
    * Initializes the state of this instance.
    * init
    public void init() {
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    this.setSize(new Dimension(400, 156));
    jButton1.setText("jButton1");
    jLabel1.setText("jLabel1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton1_actionPerformed(e);
    this.getContentPane().add(jButton1, BorderLayout.NORTH);
    this.getContentPane().add(jLabel1, BorderLayout.SOUTH);
    * start
    public void start() {
    * stop
    public void stop() {
    * destroy
    public void destroy() {
    * getAppletInfo
    * @return java.lang.String
    public String getAppletInfo() {
    return "Applet Information";
    * getParameterInfo
    * @return java.lang.String[][]
    public String[][] getParameterInfo() {
    return null;
    static {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception e) {
    e.printStackTrace();
    public void ExecNotepad(){
    expos.RunNotepad();
    /* void jButton1_actionPerformed(ActionEvent e) {
    try
    Runtime.getRuntime().exec("notepad.exe");
    catch (SecurityException ex) {
    // strMsg = "ExecFile: caught security exception: " + e ;
    jLabel1.setText("ExecFile: caught security exception: " + ex) ;
    catch (IOException ioe) {
    // strMsg = "ExecFile: caught i/o exception: " + ioe;
    jLabel1.setText("ExecFile: caught i/o exception: " + ioe);

    hie Naveen
    I don't have time to read your code.
    just telling you the way i did it.
    I used javascript for this
    apply onClick() event on button.
    function invokeApplet() {
    app = document.applets[0].methodName(param1,param2);
    hope this helps
    if you still face the problem
    I'll look in to your code

  • How to call a action on page load in jsf

    Hi all,
    i am having a JSF page where i want to display the records from the datatable. I have a method in bean which call database and gets the list of records. If i call this method from a link (action on this link) present on this page i can display the records on this page.
    But i want to display these records at the time of page load only. How we can do this? How to call a action at the time of page load?
    Thanks in adv.

    If i am calling the database class and get the list in constructor only i am able to display list in the datatable on page load. This works fine. But the requirment is that if there are no records in the list display a error page with message-No records found! . But how i can navigate from the constructor to error page?
    Like-
    class MyBeam{
    MyBean{
    private List requestVOList = null;
    MyDao dao = new MyDao() //for fetching list from DB
    List records = dao.getList()  //get list from dao class
    if(records==null)
        //Navigate to error page. How to do this navigation here?
    else
        requestVOList  = records;
    //setter/getters for requestVOList 
    }

  • Very simple question: Call JavaBean method on page load?

    Someone clicks on a URL that contains parameters like: http://server/page.jsf?param=b
    How do I trigger a JavaBean method to run during page load? I see many JSF examples where JavaBean methods get called during form clicks and that works great but here I want to run code on page load.
    This must be really simple; sorry I'm new to this technology.
    Must I use <% ... %> syntax or can I use actual JSF tags or configuration to accomplish this?
    Thanks very much in advance!

    Putting a lot of logic in getter( ) function is not the best idea considering that getter( ) could be called all over the place. Using constructor for same purpose is also a bad idea especially with request scope beans. This could also happen many times at different stages. You are right, having a page load concept could be useful. Unfortunately JSF framework does not support. You could architect around it in case desperate. Or if using JSF implementation of certain vendors like IBM, you can take advantage of their implementation that was extended to support pageLoad and postBack events (similar to .NET).
    Many postings on this forum dealt with topic. Feel free to review like this one:
    http://forum.java.sun.com/thread.jspa?forumID=427&threadID=541382

Maybe you are looking for

  • Apple TV Color Messed Up

    The past few days, something really strange has been going on with the colors on our Apple TV.  I've tried updating the software, resetting it, unplugging cords etc. Photo attached. Any ideas?

  • Upgrade to Reader DC and the icons preview inside teh folders stop working...

    On a win7 32 desktop I upgrade the new reader. I have also installed Adobe Acrobat 9 standard Italian Rel. 9.5.5 After the upgrade for the Reader DC the preview disappeared, I remove the reader but the problem remain...

  • Validation issues with XSD

    I'm trying to validate a xml file with this schema: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema     xmlns:xsd="http://www.w3.org/2001/XMLSchema"                xmlns="http://www.jeromedroz.org/etc/lexicon.xsd"                targetNamespace="h

  • Catalyst 2960 POE Switch Consumption Mode

    Hi, I'm curious how I can configure a 2960 to function in POE consumption mode. I know with other switches you can explicitly configure them to only give devices the power they consume and not power based on what class the belong to. I have read that

  • OWB 10gR2 ORA-01031: insufficient privileges

    Registering Users as Warehouse Builder +OWB When adding target schema (Global explorer=>User=>New) in the OWB, I am getting this error ORA-01031: insufficient privileges I have created this target and did grant DBA to this user. Still getting this er