Calling backing bean method from HttpSessionListener

Hi,
I am detecting session expiration through HttpSessionListener's sessionDestroyed() method. I have a logout() method in my backing bean which does all the session clean up. If the user clicks the logout link, then I call the logout method and do the clean up. But when the user closes the browser, then I believe that the HttpSessionListener's sessionDestroyed() method will be called. How do I call the logout() method of my backing bean from from sessionDestroyed() method of HttpSessionListener.

I did as you said, but the finalize method is never called. I can see the session timing out and sessionDestroyed() method being called, but not the finalize() method. Here is the code for sessionDestroyed()
    public void sessionDestroyed(HttpSessionEvent sessionEvent){
        System.out.println("Session Destroyed Called");
        HttpSession session = sessionEvent.getSession();
        session.invalidate();
        System.gc();
    }and for finalize()
    public void finalize() throws Throwable{
        System.out.println("In Finalize Method");
        FacesContext ctx = FacesContext.getCurrentInstance();
        Object requestObject = ctx.getApplication().getVariableResolver().
                               resolveVariable(ctx, "databaseCon");
        DatabaseCon databaseCon = (DatabaseCon) requestObject;
        Connection con = databaseCon.getConnection();
        String sql = "DELETE FROM TEMP WHERE EX_ID = ?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setInt(1,this.getExId());
        pstmt.executeUpdate();
        super.finalize();
    }

Similar Messages

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • How to call Backing Bean method from href tag in JSF. -- URGENT

    Hi guys,
    i am new to JSF. i want one option. how to call a backing bean method from href.
    I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
    If anyone knows pls help me. Its Urgent. If u can, give me the code also.
    Suggestions will be appreciated.
    Thanks
    Rajesh

    You can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
    You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html].

  • How to call Backing bean method from JS

    I want to call commandlink action from JS,
    I'm trying document.getElementById('formPageInfo:btnCreateQuote').click() in javascript.
    But it is not working any ideas around?
    Code is for commandlink : <h:commandLink action="#{ManagedController.businessListActions.createNewQuote}" accesskey="C" title="Start Quote" id="btnCreateQuote"> <h:outputText value="Start Quote" /></h:commandLink>
    Any help/Suggestions around?

    I think that not exist a specific way to do it with jsf. Maybe you should ask in other forum more related with javascript, as a tip, if you can use jQuery in your environment, jQuery.trigger() can simulate a click on a button or command link. I have used it with a h:commnadLink and worked fine.

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to call backing bean method when user tabs out of af:inputListOfValues field

    Hi,
    I am using jdev 11.1.2.4.
    I want to call a backing bean method based on the value selected in the af:inputListOfValues field.
    The requirement is similar as Frank Nimphius-Oracle has demonstrated here  https://blogs.oracle.com/jdevotnharvest/entry/how_to_notify_the_server but with Input List of Values component.
    The fields I want to call method from is
    <af:inputListOfValues id="appealNameId"
                          popupTitle="Search and Select: #{bindings.AppealName.hints.label}"
                          value="#{bindings.AppealName.inputValue}"
                          label="#{bindings.AppealName.hints.label}"
                          model="#{bindings.AppealName.listOfValuesModel}"
                          required="#{bindings.AppealName.hints.mandatory}"
                          columns="#{bindings.AppealName.hints.displayWidth}"
                          shortDesc="#{bindings.AppealName.hints.tooltip}"
                          binding="#{backingBeanScope.backing_Donation.appealNameId}"
                          autoSubmit="true" clientComponent="false">
                          <f:validator binding="#{bindings.AppealName.validator}"/>
                          <af:autoSuggestBehavior suggestedItems="#{backingBeanScope.backing_Donation.onSuggestAppeal}"/>
                          <af:clientListener method="onBlurTxtField" type="blur"/>
    </af:inputListOfValues>
    <af:serverListener type="onBlurNotifyServer"
                       method="#{backingBeanScope.backing_Donation.onBlurNotify}"/>
    as you can see,  af:serverListener is outside the af:inputListOfValues which probably is the reason its not executing this method?
    public void onBlurNotify(ClientEvent clientEvent) {
       // get a hold of the input text component
       RichSelectOneChoice inputTxt =  (RichSelectOneChoice) clientEvent.getComponent();
       //do some work on it here (e.g. manipulating its readOnly state)
       //Get access to the payload
       Map  parameters = clientEvent.getParameters();
       System.out.println("SubmittedValue = "+parameters.get("submittedValue"));
       System.out.println("LocalValue =  "+parameters.get("localValue"));
    I've tried to put serverListener tag inside the <af:inputListOfValues> but getting below error
    "Server Listener is not valid child of Input List of Values"
    any ideas please?
    thanks

    As first, check to see that you are using correct type for af:serverListener (thet one you are queue in the javaScript onBlurTxtField function)
    If still does not work, go to directly to the page source code, and put af:serverListener "by hand", as a child for af:inputListOfValues.
    Because it is possible that these messages are false alarm...

  • ADF Faces Declarative Component onLoad event call Backing Bean Method

    Hello.
    We are trying to implement a declarative component, that will be used as Flex Fields for our application, ie, the components will be created dynamically through a database configuration, and who is responsible for organizing and creating the components, is the declarative components, and its own backing bean.
    The declarative component, will receive a List of custom components, and with this list it is possible to create the components dynamically. We want the components to be created as soon as the page is loaded. The developer could place this declarative component in any region of his page, and even in another tab if he wishes. The problem is, that we cannot register a load event in the declarative component, since it doesn't have a document Object, to call the declarative components backing bean method that is responsible for creating components.
    How could we simulate the onLoad (of the declarative components) so that the backing bean method (responsible for creating component, and putting it in the view tree) could be called ?
    I've tried with a RENDER_RESPONSE phaseListener, but the beforePhase has no objects in the tree, and the afterPhase has already rendered to the client.
    Any ideas on how to achieve this ?
    Thanks a lot.
    Regards,
    John

    Hi Frank, thanks for the response.
    I'm curious about the dynamic declarative component. Any place I could check it out ?
    Back to my scenario. I'll try to be more clear to what we need!
    We have to have dynamic creation of components, based on a database configuration. This will allow our customers to have custom flex fields, without the need of us developing custom pages for each customer.
    One solution we are trying out, is the declarative component. Why ? Because the developer (when developing the page), knows that this specific page, is possible of customization by the client (custom flex fields). With this, the developer would choose where on his page the custom flex fields will be placed. Note that at this point (design time), no component (input, buttrons, etc) is created. The idea of the declarative component, is just so the Developer knows where he wants the custom fields placed in his page (a tab, below the form fields, in a another panel group, and so on). The declarative component, has only a container, PanelFormLayout, and no other component.
    What we want, is a way of calling our managed bean (the managed bean of the declarative component, that now I did configure it in the adfc-config.xml file , thanks for the tip) method, that's responsible for creating the custom components. The declarative component, receives a list of all the custom fields that needs to be created, at design time, through an attribute. The developer is responsible for setting this list when he drags the declarative component on his page.
    Now that I've put the declarative components managed bean in the adfc-config.xml file, the @PostConstruct is called correctly, but I still have a problem. At this moment (postContstruct call), my component PanelFormLayout (that is binded to the managed bean), is null. So I cannot add any component to the PanelFormLayout.
    Am I way out of line here Frank ?
    Really appreciate your comments.
    Thanks a lot.
    John

  • Calling Backing Bean Method with h:outputLink

    Is there a way to call a backing bean using h:outputLink isntead of h:commandLink ?

    No, you can't. You however can just let it point to a JSF page and make use of the constructor of the involved request scoped managed bean.

  • How to call a bean method from html component in jsf

    hi all
    i need a solution for this problem of mine.. actually em working on a jsf application with contains a jsf-jsp having a span containg html button inside my javascript. i want to call a method on click of this button and fetch some data which i have already populated in my bean.how do i do this??? i hv attached a piece of code of d same...
    <script language="JavaScript" type="text/javascript">
    function test(form){
    var Title="DEBIT, gift, Request, TICK";
    var Span=document.createElement("Span");
    Span.style.position="absolute";
    Span.style.left=(parseInt(110)-5)+"px";
    Span.style.top=(+parseInt(274)-5)+"px";
    Span.style.backgroundColor='Red';
    var next=document.getElementById("forImage");
    next.innerHTML="<img src='http://127.0.0.1:9000/action=clusterserve2dmap&sourcejobname=myjob_clusters' />";
    Span.innerHTML="<[input type='button' >";
    document.getElementById("forImage").appendChild(Span);
    any help is highly appreciated

    Hi,
    this gonna be a hack, but here's how it could work
    - you create a Servlet that accesses the FacesContext to obtain a managed bean
    - you issue a XmlHttpRequest from the button to your servlet to obtain the payload
    - show the retrieved values in your HTML
    see http://www.thoughtsabout.net/blog/archives/000033.html for the middle part
    Frank

  • Accessing a JSF element from a back bean method

    Hi,
    short question, can I access the JSF element from a back bean method?
    So, for example, if I have the following JSF code:
    <h:panelGroup id="test1" rendered="#{bean.someMethod}">...</h:panelGroup>
    <h:panelGroup id="test2" rendered="#{bean.someMethod}">...</h:panelGroup>
    <h:panelGroup id="test3" rendered="#{bean.someMethod}">...</h:panelGroup>
    Can I found out in some way, which element (esp. which ID) calls the someMethod-method?
    Kind regards
    Matthias

    There are more possibilities as well. If you depend it on for example the User's rights/groups, then you can also do for example:
    rendered="#{user.admin}" // getter = public boolean isAdmin()
    rendered="#{user.groupName == 'admin'}" // getter = public String getGroupName()
    rendered="#{user.groupId > 1}" // getter = public int getGroupId()
    rendered="#{fn:contains(user.groups, 'admin')}" // getter = public String[] getGroups() or public List<String> getGroups()
    etc..I think it's after all just a matter of learning about the capabilities of EL a bit more.

  • Calling a backing bean method after load of fragment in adf

    I needed to call a backing bean method after page load of fragment in adf.
    I used the method suggested in:
    https://community.oracle.com/message/11044570
    only difference is im giving the if clause as:
    if (refreshFlag == RegionBinding.RENDER_MODEL ) {
    instead of
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    It was working fine, but page was not getting refreshed so used the code as mentioned in example:
    public void refresh() {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              String refreshpage = facesContext.getViewRoot().getViewId();
              ViewHandler  viewHandler =facesContext.getApplication().getViewHandler();
              UIViewRoot viewroot =  viewHandler.createView( facesContext, refreshpage);
              viewroot.setViewId(refreshpage);
              facesContext.setViewRoot(viewroot);
    Now issue is once page is loaded and backing bean method is called, the refresh code refreshes the page and upon page load, refresh method is called again in recursive fashion.
    please advise what to do in such scenario?
    I tried to do selective refresh using some variable(also with static) but it does not help as page wont be refresh at all or page will keep refreshing recursively.

    Use clientListener on the page load event
    <af:document id=”d1″>
        <af:serverListener type=”onloadEvent”
                           method=”#{<managedbean name>.<method name>}”/>
        <af:clientListener method=”onLoadClient” type=”load”/>
        <af:resource type=”javascript”>
        function onLoadClient(event) {
          AdfCustomEvent.queue(event.getSource(),”onloadEvent”,{},false);
          return true;
        </af:resource>

  • How to call the backing bean method through javascript

    Hi
    I have a command button associated with actionListener . Action Listener method associated with backing bean methods.
    I want to fire the event on command button and backing bean method should be invoked from javascript dynamically.
    can anybody help me asap

    JSF<h:form id="formId">
        <h:commandButton id="buttonId" value="submit" actionListener="#{myBean.action}" />
    </h:form>JSdocument.getElementById('formId:buttonId').click();

  • Call a backing bean method using h:selectBooleanCheckbox of jsf on select

    I want to call a backing bean method using h:selectBooleanCheckbox of jsf on select and deselect.
    I cannot use af:selectBooleancheckBox of adf and h:selectBooleanCheckbox doesnot have the property of autosubmit="true"

    User,
    please don't duplicate your posts on this forum ({thread:id=2369739})
    If you don't get an answer right away it might be that there is some information missing or nobody had time to work on the issue. Pleas be patience...
    We all have other work to do to get our bills paid.
    If you can't wait open a support request with support.oracle.com
    Timo

  • af:fileDownloadActionListener not calling the bean method

    Hello,
    I am using Jdev 11.1.1.6.
    I have a page where user can generate the report and download it. I am using <af:fileDownloadActionListener> for this on my jsff (implemented as region using BTF).
    The commandbutton with <af:fileDownloadActionListener> is calling a backing bean method. When user clicks the "Print" button, it is supposed to generate the report and allow user to download it.
    The issue here is that the control never goes to bean method after button press. The browser keeps showing busy but no control passed to bean method. Interestingly, after you close the browser, it immediately goes to bean method.
    I have tried waiting for long time (some times 15-20 min) but it never goes there during execution.
    What could be going wrong here?
    Code snippet from my jsff:
    <af:commandButton id="cb1"
                      textAndAccessKey="Print"
                      partialSubmit="false"
                      clientComponent="true">
                   <af:fileDownloadActionListener method="#{someMethod}"
                                                  filename="#{someName}"/>
    </af:commandButton>This is really frustrating as I have no clue what is going wrong here. The similar code works in other page but not here.
    I would highly appreciate help here.
    Thanks,
    Jai

    Like I said, it is working fine on my other pages and I tried on new page, just like yours, and it worked. It is not working where I need it.
    I know the issue is somewhere with my page [child or parent, explained later] and I am looking for help on finding the root cause. Some direction/tip which I can follow and figure out the issue.
    Other buttons are working fine on the page but <af:fileDownloadActionListener> does not work. The page seems to go in loop as it keeps printing generic messages that are generally printed when page is submitted.
    This will continue until you close the page/browser and then the control goes to bean method.
    Let me explain page structure:
    My application is based on UIShell and is basically based one page application. Every page (jsff) is implemented as region using BTF. When user clicks on menu, MainPage is opened. This MainPage represents main structure using layout components like panelGroupLayout, panelTabbed, showDetailItem etc. These layout components contains <af:region> implemented using BTF.
    The MainPage which has this issue is large page with almost 100+ BTF af:regions implemented under panelTabbed+showDetailItem combination.
    <af:fileDownloadActionListener> has been implemented on one of the <af:region>, which is part of this MainPage.
    Few Observations:
    1. If I move this button [with <af:fileDownloadActionListener>] to any of the af:region under current MainPage then it does not work.
    2. If I move this button [with <af:fileDownloadActionListener>] to any independent page or any <af:region> which is part of some other MainPage, then it works.
    3. Other MainPage where it is working fine is also a fairly large page with almost 150+ BTF af:regions
    4. All our MainPages are based on template, so there is very high level of consistency in behavior and other handlings.
    For whatever reason, it is not working on my current page and I would highly appreciate any input based on above info [or otherwise] to find a root cause for this issue.
    If I need to debug, where should I start? What could be causing that looping behavior, specially with <af:fileDownloadActionListener>.
    Thanks,
    Jai

  • How to call a bean method through a javascript function

    I dont discover any problems calling the bean method in this maner:
    <%= helpdesk.data() %>
    But, when I use a Button Onclick= to call the script function and which then is going call my bean method
    an error on the page is reported!
    I have include som code which gives you the idea of what Iam searching for. And is it possible to call
    the bean method without doing from a new jsp page?
    If you have any suggestions to why it doesnt work, please let me know.
    I use Apache Tomcat 4.0
    Best regards Micah.
    <jsp:useBean id='helpdesk' scope='application'
    class='helpdesk.testdb'/>
    <html>
    <head>
    <script language="javascript">
    function broadcast()
    helpdesk.data();
    </script>
    </head>
    <body>
    <input type="button" value="Broadcast" onclick= broadcast()>
    </body>
    </html>

    It's actually quite simple:
    Beans run server-side
    Javascript runs client-side
    So you will never be able to run server-side-code thru the client...

Maybe you are looking for

  • Pages 5.0 in Maverick causes Konica Minolta Bizhub Features to be deleted

    I have 2 schools which I administer and my own business. They all have BizHub Printers C360 C364 C451 C452 All have the latest drivers installed (UK site or eu site is best) All other apps including Word, Acrobat, Photoshop etc all print correctly, a

  • Photoshop CS3 - Opening File - Toolbar Freezes

    Hi, I have Photoshop CS3 on a Mac OS X. When I open Photoshop, click File > Open, then click on the image I want to open, Photoshop opens the image but everything is greyed out. I can click on the side tool bars and they are no longer greyed out but

  • WP8.1 GDR1 with Lumia Black update to Lumia Cyan F...

    Hello, I got Lumia 520 - WP8.1 GDR1 (Developer Preview)  with Lumia Black Firmware. How can i update only the Lumia Black Firmware to Lumia Cyan Firmware ? And i see on Nokia website that the status of the Cyan Update is available for my Lumia 520. I

  • Report To View Item Sales By Geography

    Hello All - I would like to see a report that shows how well our products sell by U.S. State.   Also, rather than see a list of individual items, I would like to see the cumulative totals of those items that have the same first four digits in the ite

  • HT4528 Routes 2 and 3 on Maps App does not consider traffic.

    Has anyone noticed that only route 1 considers traffic?  Is there a setting to make routes 2 and 3 estimate the time of travel with traffic?