1. FOR FACES MESSAGE POPUP -To show
warning/error/info messages on view page
FacesContext fctx = FacesContext.getCurrentInstance();
FacesMessage msg=new FacesMessage(Severity,String Summary, String Message);
fctx.addMessage(inputText.getId(), msg);
For Eg:
FacesContext fc=FacesContext.getCurrentInstance();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Save It" ,"Before Navigating to details Click Save..");
fc.addMessage(null,msg);
2.TO GET OPERATION BINDING:
BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding
("CreateInsert2").execute();
OR
BindingContainer bindings = getBindings();
OperationBinding glOP = bindings.getOperationBinding("Commit");
glOP.execute();
if (!glOP.getErrors().isEmpty()) { //in case operation binding returns error
} else{
}
3.TO GET CURRENT ROW FROM ITERATOR BINDING:
BindingContext btx = BindingContext.getCurrent();
DCBindingContainer dcbct = (DCBindingContainer)btx.getCurrentBindingsEntry();
DCIteratorBinding binding = dcbct.findIteratorBinding("EmployeeIterator");
Row currentRow = binding.getCurrentRow();
OR
DCIteratorBinding iterBind= (DCIteratorBinding)dcbct .get("testIterator");
String attribute = (String)iterBind.getCurrentRow().getAttribute("empName");
OR
FacesContext ctx = FacesContext.getCurrentInstance();
ExpressionFactory exf = ctx.getApplication().getExpressionFactory();
ValueExpression vale = exf.createValueExpression(ctx.getELContext(), "#{bindings.EmployeeIterator.currentRow.dataProvider}", Emp.class);
Emp name= (Emp)vale.getValue(ctx.getELContext());
4.TO REFRESH THE PAGE:
protected void refreshPage() {
FacesContext fctx = FacesContext.getCurrentInstance();
String refreshpage = fctx.getViewRoot().getViewId();
ViewHandler ViewH = fctx.getApplication().getViewHandler();
UIViewRoot UIV = ViewH.createView(fctxc, refreshpage);
UIV.setViewId(refreshpage);
fctx.setViewRoot(UIV);
}
5.TO REFRESH (PPR) ANY UI COMPONENT:
AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponent);
6.TO OPEN A 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);
}
}
No comments:
Post a Comment