Monday, December 19, 2011

ADF TaskFlow Method Call On page load

In taskflow we can drop execute with parama e.g. employees with dept 10 from datacontrols. You can even right click and say create page definition and define operations there for taskflow.

The binding for this will be with method now you need to change this binding and update it to backing bean method (binding value: #{backingBeanScope.MethodCall.CalledMethod}) and now you can execute the execute this mehtod from operation binding as in below code

public void CalledMethod() {

DCBindingContainer dc = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding = dc.getOperationBinding("ExecuteWithParams");
operationBinding.execute();
}

In this way you intitialize your page.

Thursday, December 15, 2011

Passing values between ADF Task Flow

1) IF we have one taskflow inside another taskflow. The PageflowScope can be use to set values into variables i.e.
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("varName","varValue");
and select the child taskflow(this task flow should have relevant parameters defined) and in properties give value to parameter value as #{pageFlowScope.varName}
2) When we have Jsff (region) within which we have taskflow pulled and we need to pass value to this taskflow then go to pagedefinition for the page/region and select this taskflow from executables and in properties you provide value to particular variable like #{pageFlowScope.varName}

Sunday, December 4, 2011

Check Authentication & Get Logged in user id

Use this code in you application module Impl class in methods

1) SecurityContext securityContext = ADFContext.getCurrent().getSecurityContext();
// 2. authentication check
if(securityContext.isAuthenticated()){
String username = securityContext.getUserName();

2) String userName = ADFContext.getCurrent().getSecurityContext().getUserName();
if(ADFContext.getCurrent().getSecurityContext().isAuthenticated()){

Remove all rows from viewobject.

Define a method in Application Module Impl class.
Using below sample code you can delete all the rows in current resultset of view object
In Application Impl all the methods will have viewobject accessors(get and set viewobjects)

ViewObjectImpl employeesVO= getEmployees();
// 1. reset iterator to start before first row
shoppingCartVO.setRangeSize(-1);
Row[] rows = employeesVO.getAllRowsInRange();
// 2. iterate over rows and remove each instance
for(Row row: rows){
row.remove();
}
getDBTransaction().commit();

Saturday, December 3, 2011

Table Column Sum / Table Footer Displaying Sum of Column

Lets say we have employees table and we want sum on salary column.

Drag viewobject and create table normally.
Select Salary table -> Right Click -> Facet Column -> Footer
From structure pane for this column add output text filed and surround it with panel grouplayout (layout property as horizontal and halign as right)

You can have two view object viz one for just employees and secont view object to contain the sum query.

The output text should refer to the sum value of the second view.
Checout the attached application

https://docs.google.com/open?id=0B-zSRgGSIJgNMTIyMTk1Y2ItMDNjMS00N2Y5LWFkYWItNWI4YWY4YzUyZWQ2