link refer
http://www.techartifact.com/blogs/2012/10/invoke-a-method-from-managed-bean-when-jspx-page-loads-in-adf.html
implements PagePhaseListener
public void beforePhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_MODEL_ID) {
onPageLoad();
}
}
public void afterPhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_RENDER_ID) {
// onPagePreRender();
}
}
public void onPageLoad() {
if (!AdfFacesContext.getCurrentInstance().isPostback()) {
// add your onPageLoad event here
// to set the View Criteria on the Iterator
doSomeOperation(); ///your custom method.
}
http://www.techartifact.com/blogs/2013/09/call-method-on-page-load-of-jsff-jsf-fragment-in-oracle-adf.html
implements RegionController
public boolean refreshRegion(RegionContext regionContext) // you need to override refresh region method.
{
int refreshFlag= regionContext.getRefreshFlag();
FacesContext fctx = FacesContext.getCurrentInstance();
//check internal request parameter
Map requestMap = fctx.getExternalContext().getRequestMap();
PhaseId currentPhase=(PhaseId)requestMap.get("oracle.adfinternal.view.faces.lifecycle.CURRENT_PHASE_ID");
if(currentPhase.getOrdinal()==PhaseId.RENDER_RESPONSE.getOrdinal()) // write custom logic of correct lifecycle phase.
{
Object showPrintableBehavior =
requestMap.get("oracle.adfinternal.view.faces.el.PrintablePage");
if (showPrintableBehavior != null)
{
if (Boolean.TRUE == showPrintableBehavior)
{
ExtendedRenderKitService erks = null;
erks =
Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
//invoke JavaScript from the server
erks.addScript(fctx, "window.print();");
erks.addScript(fctx, "window.close();");
}
}
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 String getName()
{
return null;
}
Not Work...generate exception
ReplyDelete