יום שני, 4 במרץ 2013

How to access data controls and data bindings

Hi,
In this post i will show how to access data controls and data bindings from the server side.
By accessing to data controls and data bindings, we can get any data\item that shown on our application. 

Each jsf page in our application have a bindings tab which shows all the bindings variables of the page.
So, how can we get all this variables ?
Suppose our page named "myTestPage.jsf".

Get binding container :
DCBindingContainer c = bindingContext.findBindingContainer("view_[myTestPage]PageDef");

Access data control :
AppModule am = (AppModule)bc.findDataControl("[name of data control]DataControl") .getDataProvider();


Access data bindings(for example access to binding iterator named "iterMe") :
DCIteratorBinding myIter = (DCIteratorBinding)bc.findIteratorBinding("iterMe").

and now we can get any attribute: 
String lastName = (String)myIter.getCurrentRow().getAttribute("LastName");


API for DCBindingContainer :

Eran Tzayzler

יום ראשון, 3 במרץ 2013

How to add service methods to application module

Hi,
In this post, i will explain how to add service methods to application module.
Basically, we define a method in application module implementation when the method performs a general operation and does not refer to a specific entity or view.

Steps:
1. open application module.
2. go to java options.
3. click at the right side on "edit java options".
4. generate application module class.
5. open the Impl java class of the application module.
6. add a method - you can add parameters and return value.
7. exposed the method to the application module interface instance.
8. now, you can use this method from the application Module client/instance(java)

For example(client):

For example(instance-java):


Eran Tzayzler

How to get Application Module's current instance

Hi ,
In this post, i will explain how to get the Application Module's current instance.
Basically by holding Application Module's current instance, we can get and modify any part of our application.

How to get Application Module's current instance:

BindingContext bindingContext = BindingContext.getCurrent();
DCDataControl dc  = bindingContext.findDataControl([name of the data control]);
AppModuleImpl appM = (AppModuleImpl)dc.getDataProvider();

Example for [name of the data control]:


Now, we can access any Entity or view and modify/add/remove their properties.

For Example(print view's field to the console):

[ViewLink/ViewObject] vl = appM.findViewLink/ findViewObject ([name of view instance from APM]);
Row r = vl.[getDestination() – for destination side/ getSource() – for source side].getCurrentRow();
System.out.println(r.getAttribute("[name of attribue]"));

Example for [name of view instance from APM]:




Eran Tzayzler