Saturday, September 4, 2010

Refreshing a task flow in ADF

Add the following code to refresh a taskflow from a managed bean.

BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = bctx.getCurrentBindingsEntry();
DCTaskFlowBinding taskflowBinding = null;
taskflowBinding = (DCTaskFlowBinding) bindings.get("--taskflow id here");
taskflowBinding.refresh();

CSV file displays on IE instead of Excel

In order to display the CSV file in excel, add the following MIME mapping to web.xml.
<mime-mapping>
     <extension>csv</extension>
    <mime-type>application/octet-stream</mime-type>
 <mime-mapping>
<mime-mapping>

<extension>CSV</extension>
<mime-type>application/octet-stream</mime-type>
<mime-mapping>

Activating Taskflow in ADF

Taskflow can be activated by setting the following properties.

activation = conditional
active = EL expression which returns true.

If there are multiple taskflows dropped as regions in the same jsff page as tabs. The page needs to be refreshed for every tab click.

Refresh Taskflow

protected void refreshPage(){
  FacesContext fc = FacesContext.getCurrentInstance();
  String refreshPage = fc.getViewRoot().getViewId();
  ViewHandler ViewH = fc.getApplication().getViewHandler();
  UIViewRoot UIV = ViewH.createView(fc,refreshPage);
   UIV.setViewId(refreshPage);
  fc.setViewRoot(UIV);
}