Use PopUp behaviour in ADF
Popup component shows a smart look of application, makes a more interactive page
Method to show PopUp-
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);
}
}
You have to import these in order to use this method
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
import javax.faces.context.FacesContext;
Simply call this method whereever you want to show popup. if you want to open PopUp on a button click then you have to follow these steps.
- Drag a popUp on page
- bind this popUp to bean
- Now on button click call above method Suppose your popUp binding name is declared as private RichPopup pop;, then call
showPopup(pop, true); to show popUp, when you click that button.
It will look like this
No comments:
Post a Comment