XPages application events: Create your own ApplicationListener (2)

There is another interface available which provides the additional method applicationRefreshed. This event is always raised if the method refresh() of the Application-Object is fired.

Instead of implement the interface described in the previous posting, you have to use the interface named com.ibm.xsp.application.events.ApplicationListener2.

package ch.hasselba.jsf.debug;

import com.ibm.xsp.application.ApplicationEx;
import com.ibm.xsp.application.events.ApplicationListener2;

public class MyApplicationListener implements ApplicationListener2 {

    public void applicationCreated(ApplicationEx arg0) {
        System.out.println("applicationCreated()");
        System.out.println("ID: " + arg0.getApplicationId());
     }

    public void applicationDestroyed(ApplicationEx arg0) {
        System.out.println("applicationDestroyed()");
        System.out.println("ID: " + arg0.getApplicationId());
    }

    public void applicationRefreshed(ApplicationEx arg0) {
        System.out.println("applicationRefreshed()");
        System.out.println("ID: " + arg0.getApplicationId());
    }

}

You can fire the refresh of the application manually. Here is a simple example how to do this:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
   <xp:button value="Label" id="button1">
      <xp:eventHandler event="onclick" submit="true"
         refreshMode="complete">
            <xp:this.action>
               <![CDATA[#{javascript:
                  facesContext.getApplication().refresh()
               }]]>
            </xp:this.action>
        </xp:eventHandler>
   </xp:button>
</xp:view>

By clicking the button, the refresh is fired:

Dieser Beitrag wurde unter Extensibility API, Java, JSF, XPages abgelegt und mit , , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

5 Antworten zu XPages application events: Create your own ApplicationListener (2)

  1. David Marko sagt:

    I can’t get it to work. I put everything in place and cant see no messages on console. I’m testing on Domino 8.5.3. Is the META-INF/… file all the requitred configuration to ge it to work? Dont you have any simple db as working demo?

  2. David Marko sagt:

    Just got it to work, I realized, thet txt file must be named com.ibm.xsp.core.events.ApplicationListener … but the ApplicationListener is in package com.ibm.xsp.application.events.ApplicationListener (see the .core. vs. .application.)

  3. Vedran Krtalic sagt:

    Hi,
    I can’t get this application listener in Domino 8.5.2.
    I need it for implementing some java libraries/frameworks and destroying that resources on app destroy.
    Do you know „trick“ for 8.5.2?

    Thanks
    Vedran

  4. Vedran Krtalic sagt:

    One more thing, I tried ApplicationListener(1) method and it doesn’t work.

Schreibe einen Kommentar zu Vedran Krtalic Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.