Tuesday, June 25, 2013
Monday, June 24, 2013
open a static local pdf file in a popup ADF
http://technology.amis.nl/2011/07/28/adf-11g-show-pdf-in-a-popup/
create a http servlet in the view controller project of the application
create a http servlet in the view controller project of the application
Thursday, June 20, 2013
Wednesday, June 19, 2013
Friday, June 14, 2013
Thursday, June 13, 2013
Tuesday, June 11, 2013
Access a Managed Bean(of an Application) from another(Different Application) Bean ADF
Make an adfjar out of Application1 UI project and add it to the Dependent libraries of Application2 UI project
//Import the bean where you need to refer it
import com.application1.backing.beans.ExampleBean;
import com.utils.JSFUtils;
//Create an object
public class InitBean {
public static final String BEAN_ID = "initBean";//name used to register
private ExampleBean exampleBean;
public InitBean() {
super();
}
public String setParams() {
exampleBean = (ExampleBean)JSFUtils.getManagedBeanValue("exampleBean");
// exampleBean this is the name with which it is registered in the adfc-config with session scope of Application1
//Now we can set the values or call methods of ExampleBean from Application2 InitBean
exampleBean.setEmpName("Vijay");
exampleBean.setDeptName("Technology");
}
}
JSFUtils
/**
* Convenience method for resolving a reference to a managed bean by name
* rather than by expression.
* @param beanName name of managed bean
* @return Managed object
*/
public static Object getManagedBeanValue(String beanName) {
StringBuffer buff = new StringBuffer("#{");
buff.append(beanName);
buff.append("}");
return resolveExpression(buff.toString());
}
/**
* Method for taking a reference to a JSF binding expression and returning
* the matching object (or creating it).
* @param expression EL expression
* @return Managed object
*/
public static Object resolveExpression(String expression) {
FacesContext facesContext = getFacesContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, expression,
Object.class);
return valueExp.getValue(elContext);
}
//Import the bean where you need to refer it
import com.application1.backing.beans.ExampleBean;
import com.utils.JSFUtils;
//Create an object
public class InitBean {
public static final String BEAN_ID = "initBean";//name used to register
private ExampleBean exampleBean;
public InitBean() {
super();
}
public String setParams() {
exampleBean = (ExampleBean)JSFUtils.getManagedBeanValue("exampleBean");
// exampleBean this is the name with which it is registered in the adfc-config with session scope of Application1
//Now we can set the values or call methods of ExampleBean from Application2 InitBean
exampleBean.setEmpName("Vijay");
exampleBean.setDeptName("Technology");
}
JSFUtils
/**
* Convenience method for resolving a reference to a managed bean by name
* rather than by expression.
* @param beanName name of managed bean
* @return Managed object
*/
public static Object getManagedBeanValue(String beanName) {
StringBuffer buff = new StringBuffer("#{");
buff.append(beanName);
buff.append("}");
return resolveExpression(buff.toString());
}
/**
* Method for taking a reference to a JSF binding expression and returning
* the matching object (or creating it).
* @param expression EL expression
* @return Managed object
*/
public static Object resolveExpression(String expression) {
FacesContext facesContext = getFacesContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, expression,
Object.class);
return valueExp.getValue(elContext);
}
set Value to Transient Attribute in View Object ADF
Edit the attribute to select the expression
Requirement : EmpFullName(Transient Attribute) with Department
return First Name+ ". " + LastName + " (" + DepartmentName + ")";
Requirement : EmpFullName(Transient Attribute) with Department
return First Name+ ". " + LastName + " (" + DepartmentName + ")";
Wednesday, June 5, 2013
Use Transient Attribute to get a value in managed bean from a read only view object(ROVO) SOC
public void
onSubmit(ActionEvent actionEvent) {
DCBindingContainer dcBindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterBind =
(DCIteratorBinding)dcBindings.get("InsertReviewROVOIterator");
Row[] rows = iterBind.getAllRowsInRange();
for (Row row : rows) {
if (row.getAttribute("InsertStatus") != null) {
operationBinding.getParamsMap().put("tableName",
"INSERT");
operationBinding.getParamsMap().put("insertId",
row.getAttribute("insertId"));
operationBinding.getParamsMap().put("empId", getEmpId());
operationBinding.getParamsMap().put("commentRef",
row.getAttribute("insertStatus"));
operationBinding.getParamsMap().put("commentText",
row.getAttribute("Comments"));
operationBinding.execute();
// Insert into InsertStatus with ID and PENDING
if
(row.getAttribute("InsertStatus ").toString().equalsIgnoreCase("83"))
{
insertStatusBinding.getParamsMap().put("insertId",
row.getAttribute("insertId"));
insertStatusBinding.getParamsMap().put("statusCode",
"decline");
insertStatusBinding.getParamsMap().put("empId",
getEmpId());
insertStatusBinding.execute();
}
if (row.getAttribute("InspectionStatus").toString().equalsIgnoreCase("84"))
{
insertStatusBinding.getParamsMap().put("insertId",
row.getAttribute("insertId"));
insertStatusBinding.getParamsMap().put("statusCode",
"Hold");
insertStatusBinding.getParamsMap().put("empId",
getEmpId());
insertStatusBinding.execute();
}
if
(row.getAttribute("InsertStatus").toString().equalsIgnoreCase("2"))
{
insertStatusBinding.getParamsMap().put("insertId",
row.getAttribute("insertId"));
insertStatusBinding.getParamsMap().put("statusCode",
"PENDING");
insertStatusBinding.getParamsMap().put("empId",
getEmpId());
insertStatusBinding.execute();
}
PopupUtil.invokePopup(p2.getClientId(FacesContext.getCurrentInstance()));
}
}
OperationBinding saveOperation = ADFUtils.findOperation("Commit");
saveOperation.execute();
}
Pass Bind Parameter for View Object dynamically
For the View Accessor Pass the Value for the Parameter:
"Attribute(of VO)" > 0 ? "BindParameterValue1" : "BindParameterValue2"
If the Value for the Attribute is greater than 0 BindParameterValue1 is passed else BindParameterValue2 is passed
"Attribute(of VO)" > 0 ? "BindParameterValue1" : "BindParameterValue2"
If the Value for the Attribute is greater than 0 BindParameterValue1 is passed else BindParameterValue2 is passed
Subscribe to:
Posts (Atom)