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);

  

No comments:

Post a Comment