Popup component shows a smart look of application, makes a more interactive page.
So in ADF we can use two ways to show popup.
1.) Using Show popup Behavior component :-
Drag Show Popup Behavior component from component palette to button.
Specify the Show Popup Behavior porperty......
>Popup Id:-Id of popup component that you want to show.
>Trigger type:-
>Align:-
So in ADF we can use two ways to show popup.
1.) Using Show popup Behavior component :-
Drag Show Popup Behavior component from component palette to button.
Specify the Show Popup Behavior porperty......
>Popup Id:-Id of popup component that you want to show.
>Trigger type:-
>Align:-
Now run your page......
When you click Add button popup will open.
2.)Using Code :-
Add following method in managed bean.
import javax.faces.context.FacesContext;
import oracle.adf.view.rich.component.rich.RichPopup;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
private void showPopup(RichPopup pop, boolean visible) {
try {
FacesContext context = FacesContext.getCurrentInstance();
if (context != null && pop != null) {
String popupId = pop.getClientId(context);
if (popupId != null) {
StringBuilder script = new StringBuilder();
script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ");
if (visible) {
script.append("if (!popup.isPopupVisible()) { ").append("popup.show();}");
} else {
script.append("if (popup.isPopupVisible()) { ").append("popup.hide();}");
}
ExtendedRenderKitService erks =
Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
erks.addScript(context, script.toString());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
import oracle.adf.view.rich.component.rich.RichPopup;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
private void showPopup(RichPopup pop, boolean visible) {
try {
FacesContext context = FacesContext.getCurrentInstance();
if (context != null && pop != null) {
String popupId = pop.getClientId(context);
if (popupId != null) {
StringBuilder script = new StringBuilder();
script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ");
if (visible) {
script.append("if (!popup.isPopupVisible()) { ").append("popup.show();}");
} else {
script.append("if (popup.isPopupVisible()) { ").append("popup.hide();}");
}
ExtendedRenderKitService erks =
Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
erks.addScript(context, script.toString());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Add Binding to popup
Add Action Listner to button.
Now call showPopup method in ActionListner of button
The ActionListner Code of button:-
or we can use below code for same with above showPopup method
RichPopup.PopupHints hints = new RichPopup.PopupHints(); this.getAddpopup().show(hints);}
Now Run your page
When you click Add button popup will open. .
No comments:
Post a Comment