Skip to Main Content

Java Development Tools

Oracle-ADF inlineFrame initializing view scoped bean twice

omarfarApr 30 2015 — edited Apr 30 2015

I am facing strange issue related with af:inlineFrame component. Trying to display/render ADF page inside of af:popup within af:inlineFrame component. The weird thing is when the popup displayed; view scoped bean's @PostConstruct method called twice. That means bean is initialized twice. However it needed to be initialized once since bean is referenced from the page that is going to be displayed inside af:inlineFrame.

Correct flow gotta be:

  1. Click to button openPopup() method called.
  2. openPopup() sets URI then opens popup.
  3. inlineFrame source property set as it's going to display framePage.jspx.
  4. JSF scans framePage.jspx code finds out there is a reference to FrameBean inside af:outputLabel
  5. Construct FrameBean then call @PostConstruct method.
  6. Call appropriate getter and render page.

What happens in my case:

  1. Click to button openPopup() method called.
  2. openPopup() sets URI opens popup.
  3. inlineFrame source property set as it's going to display framePage.jspx.
  4. JSF scans framePage.jspx code finds out there is a reference to FrameBean inside af:outputLabel
  5. Construct FrameBean then call @PostConstruct method.
  6. Call appropriate getter and render page.
  7. Construct FrameBean then call @PostConstruct method.
  8. Call appropriate getter and render page.

Popup located like:

<af:popup id="mainPopup" binding="#{mainBean.mainPopup}">

<af:dialog id="mainDialog">

  <af:inlineFrame source="#{mainBean.URI}"> </af:inlineFrame>

  </af:dialog>

</af:popup>

Showing popup via af:button action="#{mainBean.openPopup}":

public void openPopup() {

this.setURI("http://localhost:7001/app/framePage.jspx");

  RichPopup.PopupHints hints = new RichPopup.PopupHints();

this.getMainPopup().show(hints);

}

framePage.jspx:

<?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:af="http://xmlns.oracle.com/adf/faces/rich"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <jsp:directive.page contentType="text/html;charset=UTF-8" />

<f:view>

<af:document title="Frame Demo" id="demoDocument">

  <af:form id="demoForm">

<af:outputLabel value="#{frameBean.commonId}">   </af:outputLabel>

  </af:form>

  </af:document>

</f:view>

</jsp:root>

FrameBean:

@ManagedBean

@ViewScoped

public class FrameBean {

private String commonId;

  @PostConstruct

  public void afterInit() {  } 


  public String getCommonId() {

return commonId;

  }


public void setCommonId(String commonId) {

this.commonId = commonId;

  }

}

Making FrameBean @SessionScoped solves this issue since bean is kept with session but I don't want to keep it within session. Also setting source property of af:inlineFrame in jspx as hardcoded not fixing the problem.

Post Details
Locked on May 28 2015
Added on Apr 30 2015
0 comments
1,015 views