Wednesday

Inserting Date and Time in database

I want to insert date and time into a field of a Oracle table whose data type is "Date".

To do so, I have used the below command.


to_date('2011/12/12 11:15:00', 'yyyy/mm/dd hh24:mi:ss')

Example:

Table definition: 
create table ATG(local_id varchar2(50) primary key,Last_Sale Date, Last_Sale_Value varchar2(50),Total_12_month_Value  varchar2(50));

In the above table, I want to insert data and time to "Last_Sale field".

Insert data:

insert into ATG values ('9986',to_date('2011/12/12 11:15:00', 'yyyy/mm/dd hh24:mi:ss'),'£319.99','£1,234,96');

Tuesday

Accessing Session Scope and Request Scope objects in ADF


We can access the session Scope objects in ADF by using ADFContext class.

The syntax for this is:

ADFContext.getCurrent().getSessionScope().get(obj);

Where obj is the object name configured in the session scope.

In the same way, we can also access the objects in request scope by using the below syntax:

ADFContext.getCurrent().getRequestScope().get(obj);

Wednesday

Fetching values of a list object of ADF bindings from Java


Before giving the solution, let me explain my scenario. I have JSF binding object “internalProfile” which is a list of a class. The definition of the object is like below.

List<KeyValue> internalProfile=new ArrayList<KeyValue>();

KeyValue is a bean with two String properties key and value.
A binding is created for the “internalProfile” and input fields are created for its values as below in JSF page.

//code in the JSF
<af:forEach items="#{bindings.internalProfile.rangeSet}" var="row" varStatus="sdiIndex">
<af:inputText value="#{row['value']}" label="#{row['key']}"                            id="it_${sdiIndex.index}"></af:inputText>
            </af:forEach>

We can see the bindings of the page below.





Now, I need to fetch all these text fields in my bean which is achieved by using the below code snippet.

BindingContainer bc =BindingContext.getCurrent().getCurrentBindingsEntry();
            oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding list = (oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding)bc.get(BINDING_INTERNAL_PROFILE);
            Row[] allRowsInRange = list.getAllRowsInRange();