Saturday, 23 May 2015

JSF changes get picked up on a running server explained

Let's first check out the steps an application goes through when deployed on a server:
==============================================================

When the application is built and deployed on server, the application is in an uninitiated state.

When a client makes an initial request a web page, the application's Facelets application is compiled.

The compiled Facelets application is executed, and a new component tree is constructed for the the application and placed in a FacesContext.

The component tree is populated with the component and the managed bean property associated with it.

A new view is built, based on the component tree.

In the rendering phase, the view is rendered to the requesting client as a response.

The component tree is destroyed automatically.

On subsequent (postback) requests, the component tree is rebuilt, and the saved state is applied.


So it's quite evident as during postback requests, the component tree is rebuilt, JSF changes will get picked up. But if new variables are added and bound to some JSF component, it will not reflect as the association happens just once in the deployment cycle.

Wednesday, 20 May 2015

ADFBC: ADF Design Structure to represent the flag type of Data

To display the check box or radio type UI component on  user interface to represent the flag type of data (true/false,Y/N etc). Following is the design in ADF :
================================================

Data Model  Design
==================
 -->Add the column which with values Y/N which indicates the Flag condition
       Column_name  VARCHAR2(1)

EO Level Design
=================
--->Add attribute in EO
          Attribute_name  Type String

VO Level Design
=================
-->Add Attribute in VO
         Attribute_name  Type String

Now before rendering this  data to UI  it should get converted into Boolean data .

The problem is how  are we going to convert the string into the  Boolean .

There are three  solutions to this problem :

  I. Use JSF converter to convert the string to Boolean
 II. Create the Button Binding in PageDef
III. Add transient Attribute to VO with  Boolean Type

 Solution Approach  I. JSF Converter
 ===========================
  *Code Re-usability
 1. In this  approach use the  JSF converter to convert the data from String type to boolean
 e.g.
  <af:selectBooleanCheckbox value="#{row.bindings.Disabled.inputValue}"
                          label="#{bindings.VipUserVO.hints.Disabled.label}"
                          converter="YNConverter" 
                          id="sbc1"/>


   Converters are  of two types :
   Server Side  converter:
   
   Client Side  converter
   To implement  the client side converter use following link
            client  side converter implementation 
 Client Side Vs Server Side approach difference

.  You should generally implement both Client side and server side converters. 
You don’t have to worry about the availability of JavaScript or not as ADF won’t work without JavaScript 


However, you do have to worry about the theoretical possibility of an HTTP request that bypasses the JavaScript in come way (for example the JS api is used to set the value on the client side instance of a component) - So you must always have the Server side converter no matter what.

Solution Approach II . Create the Button Binding in PageDef
==============================================
Create and use a button binding in the PageDef instead of an AttributeValue binding. The definition of the binding specifies which value is mapped to "true" and which is mapped to "false"


Solution Approch III. Add transient Attribute to VO with  Boolean Type
==========================================================
Create a transient VO attribute of datatype Boolean and bound the checkbox to it. Override attribute's getter and setter method (in the VO's RowImpl class) to get and set the value from/to your String VO attribute (by converting the String value to a boolean value and vise versa);