Some ADF Tips


how to set a background image to a component
background-image:url(#{facesContext.externalContext.requestContextPath}/images/globe.png);
  Getting the binding container

BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();  
Getting ADF attribute value from an ADF page definition

AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("test");
attr.setInputValue("test");
 
Executing a MethodAction

OperationBinding method = bindings.getOperationBinding("methodAction1");
method.execute();
List errors = method.getErrors();
method = bindings.getOperationBinding("methodAction2");
Map paramsMap = method.getParamsMap();
paramsMap.put("param","value") ;
method.execute(); 
 
Getting the errors of an iterator

String error = iterBind.getError().getMessage();
Refresh an iterator

bindings.refreshControl();
iterBind.executeQuery();
iterBind.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);  
All the rows of an iterator

Row[] rows = iterBind.getAllRowsInRange();
TestData dataRow = null;
for (Row row : rows) {
dataRow = (TestData)((DCDataRow)row).getDataProvider();
}
 
Adding Action and Action Listener to a command component

RichCommandMenuItem menuPage1 = new RichCommandMenuItem();
menuPage1.setId("page1");
menuPage1.setText("Page 1");
menuPage1.setActionExpression(getMethodExpression("page1"));
RichCommandButton button = new RichCommandButton();
button.setValueExpression("disabled",getValueExpression("#{!bindings."+item+".enabled}"));
button.setId(item);
button.setText(item);
MethodExpression me = getMethodExpression("#{bindings."+item+".execute}");
button.addActionListener(new MethodExpressionActionListener(me));
footer.getChildren().add(button);


Adding Groovy expression to a component's attribute

RichInputText input = new RichInputText();
input.setValueExpression("value",getValueExpression("#{bindings."+item+".inputValue}"));
input.setValueExpression("label",getValueExpression("#{bindings."+item+".hints.label}"));
input.setId(item);
panelForm.getChildren().add(input);


Redirect to an other url

ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
String url = ectx.getRequestContextPath()+"/adfAuthentication?logout=true&end_url=/faces/start.jspx";
try {
response.sendRedirect(url);
} catch (Exception ex) {
ex.printStackTrace();
}
 
Getting an application module

private OEServiceImpl getAm(){
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{data.OEServiceDataControl.dataProvider}",
Object.class);
return (OEServiceImpl)valueExp.getValue(elContext);
}  
Change the locale


Locale newLocale = new Locale(this.language);
FacesContext context = FacesContext.getCurrentInstance();
context.getViewRoot().setLocale(newLocale);

Comments

Popular posts from this blog

Another user has changed the row with primary key oracle.jbo.Key[12 ].

weblogic windows JPS-01050: Opening of wallet based credential store failed. Reason java.io.IOException: Failed to lock cwallet.sso.lck

Working With File Throgh WebUtill