Wednesday, September 23, 2009

Thursday, September 17, 2009

ADF 11g: SelectOneChoice to display values based upon bind variable view criteria

*) When we have one of the attribute as LOV to other view's column, and we need to define a record based upon some criteria and also our LOV should display values based upon this criteria or BIND VARIABLE do the following.

Whe you create a view delatively,and creating an LOV on one of the attr in 1) overview tab, click on green + sign
2)In edit list of value, against List Data Source click green + sign to open view accessor
3) Shuffle required view object on the right, now this view object has bind variable associated with it so,
4)In View accessor click the Edit button and give the parameter value.

Give the value of this bind variable name of the current attribute to which it is binded so that both the parent and lov values a syncronized.


\

Wednesday, September 16, 2009

ADF 11g: Rowcount from Execute with parameter query programmatically

//Requirement: ADFUtils class,OnPageLoadBackingBeanBase class backing bean extending this(OnPage...) class, override onPageLoad method as below


public void onPageLoad() {
BindingContainer bindings = getBindings();
try
{
OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
Object result = operationBinding.execute();
System.out.println("Result"+result);
BindingContainer bindings1 = ADFUtils.getBindingContainer();
DCIteratorBinding dcitr =
(DCIteratorBinding)bindings1.get("Storetimings1View2Iterator");
//Fetch the number of rows returned
long count = dcitr.getDeferredEstimatedRowCount();
System.out.println("Rows returned:: "+count);
if(count == 0) {
OperationBinding operationBinding1 = bindings.getOperationBinding("Createwithparameters");
Object result1 = operationBinding1.execute();
}


}
catch(Exception e) {
System.out.println("The exception");

}

}

Wednesday, September 9, 2009

ADF 11g - Assign default value to attribute(from managed bean) while creating new record at runtime OR Execute with parameter ON PAGE LOAD

To assign default value to entity attribute at runtime:

At run time we want to assign value from a managed bean to an entity attribute while creating a new record

1) You need 3 files for this

1.1) ADFUtils.java

1.2) JSFUtiles.java

1.3) OnPageLoadBackingBeanBase.java

These can be downloaded from steve's undocumented list of application at (sample no. 58)



2) In backing bean (e.g NewShift.java) change it to extent OnPageLoadBackingBeanBase

public class NewShift extends OnPageLoadBackingBeanBase {


3) Now, goto NewShiftPageDef file, and in property section change the "Controller Class" property to the backing bean as in diag


(logic: whenever this page is called the backing bean will refer to the methods in parent class for on load functionality)
4) now you can modify beforePhase metod of OnPageLoadBackingBeanBase to set values of view objects using the JSFUtils class e.g
public void beforePhase(PagePhaseEvent event) { FacesPageLifecycleContext ctx = (FacesPageLifecycleContext)event.getLifecycleContext(); if (event.getPhaseId() == Lifecycle.PREPARE_MODEL_ID) { bc = ctx.getBindingContainer(); System.out.println("ON PAGE LOAD"); //JSFUtils.setExpressionValue("#{bindings.Locationid.inputValue}","20041");
JSFUtils.setExpressionValue("#{bindings.Locationid.inputValue}",UserDetailsPersist.pLocationId); onPageLoad(); bc = null; } }
thats it when your page is called the value from managed bean userdetailspersist is set into the location id attribute on your page
:-)

2) To execute query "execute with parameters" programmatically on page load
- Extend OnPageLoadBackingBeanBase in your page's backing bean
- override onPageLoad method as below.
- go to page definition and change controller class property to have value of this backing bean
(e.g Controller class= view.backing.StaffDetails)

public void onPageLoad(){


BindingContainer bindings = getBindings();

OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");

Object result = operationBinding.execute();

JSFUtils.setExpressionValue("#{bindings.Location.inputValue}","1024");

if (!operationBinding.getErrors().isEmpty()) {

}

}

ADF 11g - CreateInsert to display a blank form

Create two forms

1) Master form to call create new record form

2) New Record form


1) In adf-config.xml you need to drop a method call activity between these two pages

2) From Data Control pallette drag and drop Create Insert operation on this method activity

3) Set navigation parameters i.e for these pages and you will get the required output.