« ADF: Clearing cached data when working with Web Services in ADF | Main | ADF Faces: How-to smart filter the af:SelectOneChoice with JavaScript »
ADF Faces: Showing Reports
By frank.nimphius | September 11, 2007
In a previous blog entry I showed how to download files from a server for the user to save on his local client. Recently questions came up of how to integrate parameterized report pages in ADF Faces applications. While you could call the JavaServer Faces external context to redirect a JSF page request to a web report, to me this appeared to be a solution that is only second best. Ideally a report is shown in a popup dialog that doesn't make the user to navigate off the page from where the report is requested.
This blog documents a simple example of how to show dynamic and parameterized web pages - like Web Reports - in an ADF Faces dialog:
The ADF Faces application shown in the image above shows a launch button that shows my blog in a dialog window. The request URL is provided in the action method of the button and can be dynamically derived from user input to text fields.
-
public String commandButton_action() { FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("documentURL","https://thepeninsulasedge.com/frank_nimphius/2007/08/18/adf-faces-direct-file-download-through-managed-bean/");
-
return "dialog:open";
-
}
The action method actually puts a URL reference into a session scope attribute before navigating to the dialog. The line where it puts the URL into the session scope is where you would compose the Reports URL or whatever parameterized page you want to access.
The dialog page uses an iframe to show the referenced page (or Reports) content:
-
:view> -
:html> -
:head title="ShowAsDialog"> -
http-equiv="Content-Type"
-
content="text/html; charset=windows-1252"/>
-
:head>
-
:body> -
:form> -
:commandButton text="close" -
action="#{ShowDocumentInDialog.commandButton_action2}"/>
-
:form>
-
:verbatim> -
-
:verbatim>
-
:body>
-
:html>
-
:view>
Note that the iframe source uses expression language to read the URL stored in the sessionScope. An ADF Faces command button is added to close the dialog so focus and control is returned to the calling page. This is important for the JSF application to recognize what has happened, which is the benefit of this approach compared to other solutions that navigate off the ADF Faces application.
The command button code to close the dialog is
-
public String commandButton_action2() {
-
AdfFacesContext.getCurrentInstance().returnFromDialog(null,null);
-
return null;
-
}
Finally, the JSF source of the calling page:
-
:body> -
:form> -
:commandButton text="open docucment" -
action="#{ShowDocumentInDialog.commandButton_action}"
-
windowWidth="500" windowHeight="500"
-
useWindow="true"/>
-
:form>
-
:body>
Frank
Topics: ADF Faces | No Comments »
Comments are closed.