Thursday, February 28, 2013

Invalidate Cache in WebCenter

import oracle.webcenter.portalframework.sitestructure.SiteStructureContext;
import oracle.adf.controller.v2.lifecycle.PagePhaseEvent;
import oracle.adf.controller.v2.lifecycle.PagePhaseListener;
import oracle.adf.controller.v2.lifecycle.Lifecycle;

public final class CustomPhaseListener implements PagePhaseListener {

public void afterPhase(PagePhaseEvent pagePhaseEvent) {

if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_RENDER_ID) {
          try {

                SiteStructureContext ctx =
                SiteStructureContext.getInstance();


                ctx.getNavigationModel("/oracle/webcenter/portalapp/navigations/default-navigation-  model.xml").invalidateCache();
                } catch (ResourceNotFoundException ex) {
                   ex.printStackTrace();
                }
            }
       }



2 comments:

  1. Hi W!nkle!,

    interesting, but what was your use case for wanting to invalidating the cache of your naviation model? And why is it essential to do this in this particular phase?

    And do you do this for a particular page, or for all pages in your portal?

    regards,

    Jaap

    ReplyDelete
    Replies
    1. Hi Jaap,

      The use case is, When user clicked on Change language, the page needs to reload with selected language property bundle.

      The given part of code written in Custom Phase listener to render content on each page load.

      Rgds,
      W!nkle!

      Delete

Provide your thoughts !