August 9, 2012

af:inputFile component


<af:inputFile /> component is useful to browse and select file to upload. Hence, whenever we want to accept files from users, we can display this component on the JSF page. But to get the selected values from this component the “usesUpload” attribute of the form should be set to “true”, otherwise it returns null always.

<af:form id="f1" usesUpload="true">

<af:inputFile label="Image File" id="if1" />

</af:form>

August 7, 2012

Getting current record of data control from program

By using the below code, we can get the current row from the data control.

BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry(); 
DCBindingContainer bindingsImpl = (DCBindingContainer)bindings; 
DCIteratorBinding iter =  bindingsImpl.findIteratorBinding(<binding iterator>); 
Row currentRow=iter.getCurrentRow();

Where <binding iterator> is the iterator name which data control is binded to the page and holds the data

Getting Request and Response Object of JSF page


By using the below statements we can get the Request and Response objects of the JSF page.

(HttpServletRequest)javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getRequest();

(HttpServletResponse)javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getResponse();

Accessing components from JSF without binding them


We can access the components and their values of JSF from program without binding them to any attribute of beans or Data Control by using the below statement.

FacesContext.getCurrentInstance().getViewRoot().findComponent(String name);

Where name is the id of the component which needs to be accessed.

Overwriting default functionalities like Save, Load of OPA


In OPA, we can modify the default functionalities like Save, Load etc. One example use case for the need of doing this is, by default in OPA if we click on Save, the data will be saved in an xml file, but if we want to save the data in other services like data base or BPM then we are required to overwrite the Save functionality of the OPA.

To overwrite the default functionalities of the OPA like Save, Load etc, follow the below steps

  • Write a java class by implementing an interface “com.oracle.determinations.interview.engine.plugins.data.DataAdaptorPlugin”
The interface contains the below abstract methods

public InterviewUserData load(SecurityToken securityToken, String string,
                                  InterviewRulebase interviewRulebase)
public String[] listCases(SecurityToken securityToken,
                              InterviewRulebase interviewRulebase)
public String save(SecurityToken securityToken, String string,
                       InterviewSession interviewSession)
public boolean dataAdaptorProvidesCaseID()
public InterviewSessionPlugin getInstance(InterviewSessionRegisterArgs interviewSessionRegisterArgs)

  • According to the functionality to be overwritten, we can choose the method and add the desired code to it. For example, if we want to change save functionality of OPA, write the code in the save() method
 
  • Make jar file to the project and copy the jar file to the path “\Release\web-determinations\WEB-INF\classes\plugins” of OPA project and run the OPA project

Note: If we implement the interface, it will overwrite all the functionalities it supports. The OPA expects us to implement those functionalities.