-
Use ADF faces dialog framework to create dialog
in application doesn't uses ADF controller and task flows
-
Enables display a page or series of pages in a separate
browser windows
-
If application uses fusion technology you should
use task flows to create popups
Create a control flow case and view activity in adfc-config.xml file as below.
Look at the dialog:syntax used.
Code for dia_view1.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">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="dia_view1.jspx" id="d1">
<af:form id="f1">
<af:button text="button
1" id="b1" action="dialog:toView2"
useWindow="true" windowModalityType="applicationModal"
windowHeight="200"
windowWidth="300"
launchListener="#{pageFlowScope.DialogBackingbean.launchListener}"
returnListener="#{pageFlowScope.DialogBackingbean.dialogReturnListener}"/>
</af:form>
</af:document>
</f:view>
</jsp:root>
The adf command button uses the properties highlighted .Also look into the launch listener and return Listener code.
dia_view2.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">
<jsp:directive.page
contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="dia_view2.jspx" id="d1">
<af:outputText value="First Name :
#{pageFlowScope.username}" id="ot1"/>
<af:form id="f1">
<af:button
text="Close" id="b1" immediate="true">
<af:returnActionListener/>
</af:button>
<af:button text="Cancel
" id="b2"
actionListener="#{pageFlowScope.DialogBackingbean.testAction}"/>
</af:form>
</af:document>
</f:view>
</jsp:root>
A close and cancel button is provided to demonstrate both ways of closing the popup.
The DialogBackingbean java bean code below.
package view.test;
import javax.faces.event.ActionEvent;
import
oracle.adf.view.rich.component.rich.output.RichOutputText;
import oracle.adf.view.rich.context.AdfFacesContext;
import org.apache.myfaces.trinidad.event.LaunchEvent;
import org.apache.myfaces.trinidad.event.ReturnEvent;
public class DialogBackingbean {
private
RichOutputText outTextBind;
public
DialogBackingbean() {
}
public void
listenerMethod(ReturnEvent returnEvent) {
System.out.println("Return Listener..");
//
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("testValue",
"Testing");
String
retVal = (String) AdfFacesContext.getCurrentInstance().getPageFlowScope().get("retVal");
System.out.println(retVal);
this.getOutTextBind().setValue(retVal);
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getOutTextBind());
}
public void
setOutTextBind(RichOutputText outTextBind) {
this.outTextBind = outTextBind;
}
public
RichOutputText getOutTextBind() {
return
outTextBind;
}
public void
testAction(ActionEvent actionEvent) {
User user =
new User();
user.setUsername("SuneeshVR");
AdfFacesContext.getCurrentInstance().returnFromDialog(user, null);
}
public void
launchListener(LaunchEvent launchEvent) {
System.out.println(" Launch Listener");
// Using the below code we can pass the parameter to the popup page.
launchEvent.getDialogParameters().put("username",
"suneesh");
}
public void
dialogReturnListener(ReturnEvent returnEvent) {
System.out.println("Inside dialog ret listener..");
User user
=(User)returnEvent.getReturnValue();
System.out.println(user.getUsername());
}
}
User bean is a simple java bean having the username property.
No comments:
Post a Comment