Tag Archives: howto

Android Development – made simple


Android Development

This tutorial is target for those who knows basic smartphone usage and then knows to program in java, others can also checkout this tutorial after knowing concepts of java

the installation includes downloading the Android Studio, checking for proper SDK, connect your phone through USB using the ADB driver
make sure you have it installed before starting to develop an application

Next is the Architecture
1st the Application layer is where all your application sits
2nd layer is the framework layer which interacts with the application for different purpose and services.
3 layer includes the libraries used for different operations such as media, graphics etc. this layer also contains Android Run time components
4 layer is the linux kernel as android is built on top of linux shell

Components of Android
Activities – user interaction with the smartphone
services – background process for the application
broadcast Receivers – system events and communications between os and the application
content providers – data related management

Fragments – portion of the ui within an activity. you need to open a contact us page within activity
view – UI element drawn in the screen. you want a rectangle filled with red colour with rounded corner
layouts – screen formats for the views.  – linear layout, grid layout etc
intents – interaction between components. eg. u need to call the camera service from your application or dial a phone number
resources -storage for all strings, values , constants styles etc. value pair
manifest – this is the configuration file for your application. some thing like a web.xml in J2ee application

To know more see this video

Download the presentation from here

Advertisements

How to in Jdeveloper ADF – increase the inputcomboboxlistofvalues dialog width


Problem:

To increase the width of the af:inputcomboboxlistofvalues dialog box.

Solution:

Recently I have been challenged to increase the width of the af:inputcomboboxlistofvalues dialog box. using contentStyle or inlinestyle will increase the width of the component and the dialog box will remain the same. So i thought of playing with the CSS file and could possibly achieve the width with the following hack.


<af:resource type=”css”>
.adf_dialog_main{
   min-width: 500px;
}
</af:resource>

How To in Jdeveloper ADF – To call a VO from another VO or from AM method


Scenario:
How to set an Attribute value from one VO into another VO?

Solution: 

//in you Application module Impl file have the follwing code written inside the method which will set the value for another vo
//lets say UploadView is the View object that you would want to set the value
ViewObject vo = findViewObject("tUploadView");
//if its not in Application Module, you will have to get the VO instance either from iterator if you are using this code in the bean
//get the rowset of UploadView
RowSet rs = vo.getRowSet();
//iterate through
while(rs.hasNext()){
//get the row
Row r = rs.next();
//set the value
r.setAttribute("ValueItem", value); //ValueItem is the Attribute that you want to set
}
}

How to in Jdeveloper ADF–Single row table selection


Scenario:

How to enable single row table selection?

Solution:

This seems an obvious question but newbie’s miss to understand this and will find difficulties in fixing this.

So what exactly we do to make the selection happen and confirm that it points to the current row of the af:table.

first, make sure that you have the following entries added to the af:table component of your page

selectedRowKeys="{bindings.Customers.collectionModel.selectedRow}"
selectionListener="#{bindings.Customers.collectionModel.makeCurrent}"
rowSelection="single"

Note: Customers is the tree binding for the table in the page definition file.

So what these entries do?

selectedRowKeys – the state of the selection is stored in this property. This property identifies the current selected row in the collectionModel of the table.

selectionListener – this is a listener that corresponds to the selection of the row. we bind it to the makeCurrent method of the table bindings collectionModel

rowSelection – we make it single row selection.

How To in Jdeveloper ADF Tutorials – Add Date based on another Date


Scenario:

How to calculate the datefield by considering another datefield that’s entered in by the user.
If you have entered a datefield “Today” as 12/04/2012
Now the requirement is to calculate another datefield’s date as 12/04/2012 + 30 days?

Solution:

  • Have two fields in the page. inputDate1 and inputDate2 bounded to the value in the bean as date1 and date2.
  • set inputDate1 autosubmit=true, and inputDate2 partialTrigger is set to the id of the inputDate1

<af:inputDate label="Date 1" id="id1" value="#{bean.date1}" autoSubmit="true"/>
<af:inputDate label="Date 2" id="id2" value="#{bean.date2}" partialTriggers="id1"/>

in the bean for the date fields. have getter and setter

in the getter of the date2 field have the following code


private Date date1;
private Date date2;

public void setDate1(Date date1) {
this.date1 = date1;
}

public Date getDate1() {
return date1;
}

public void setDate2(Date date2) {
this.date2 = date2;
}

public Date getDate2() {
if(date1 != null){
Calendar cal =Calendar.getInstance();
cal.setTime(date1);
cal.add(Calendar.DATE, 30);
date2 = cal.getTime();
}
return date2;
}

The source code is downloaded from here, for Jdeveloper 11.1.2.2.0

How To in Jdeveloper ADF Tutorials – creates new row in af:panelist


Scenario:

How to make a panellist that reads data from a database and according to the number of records in the database creates new row in the panellist?

Solution:


<af:iterator id="i3" value="#{emp.collectionModel}" var="row"> //emp.collectionModel is your collection
          <af:panelList id="pl1">
            <af:outputText value="#{row.empName}" id="ot3"/> // empName is the attribute to show
          </af:panelList>
        </af:iterator>

How To in Jdeveloper ADF Tutorials – set and get SelectOneChoice values


Imagine that you have a ViewObject added to the Application Module and you want to add this view instance as a selectonechoice for the base VO in your UI.

Setup:

Lets have a setup as ‘DeliveryRuleView’ VO as a base datasource and for the column ‘CapTrgTyp’ you are going to add a LOV list of values coming from ‘DeliveryTriggerType’ VO

The following screenshot will show a VO ‘SystemDictionaryView’ added to the AM as a View Instance ‘DeliveryTriggerType’. The ‘SysemDictinaryView’ will list the values based on the ‘Subcategory’ provided during runtime.

To Map this to a select one choice in the UI. You will have to have the list binding created as shown in the screenshot.

  • The Base Data Source is selected as ‘DeliveryRuleView’ and the List Data Source is selected as ‘DeleiveryTriggerType’.
  • The Data Mpping is done against the ‘CaptrgType’ from ‘DeliveryRuleView’ and the ‘SubCategory’ attribute from the ‘DeliveryTriggerType’.
  • The List Binding will have another attribute ‘Value’ as a Display Attribute. The binding is named as Deliverytrigger’
  • Have an iterator defined for the ‘DeliveryTriggerType’ View instance from AM and name it as ‘DeliveryTriggerTypeIterator’

in the jsff page you will have the selectonechoice code as


<af:selectOneChoice label="Trigger" id="deliveryTrigger" value="#{pageFlowScope.backing_bean.deliveryTrigger}" required="true" autoSubmit="true">
<f:selectItems id="si131" value="#{bindings.DeliveryTrigger.items}"/>
selectOneChoice>

When you look closely, the value of the selectonechoice is mapped to the deliveryTrigger value in the managed bean and we have the selectItems bounded to the pagedef list bindings as ‘#{bindings.DeliveryTrigger.items}’

Create Operation

So during Creation of a record in ‘DeliveryRuleView’ the list will be populated from ‘DeliveryTriggerType’ instance. The user selects the option in the list and presses the save button.

Since selectonechoice stores only the index value, the value that is stored will point to the index value within the selectonechoice. for e.g if the user select’s choice ‘Third Option in the list'(underlying SubCategory as ‘THIRD_VALUE’) then the value for deliverTrigger will store as 2 as the index starts from 0.

So how to map this to the correct selection?.

Have an actionlistner for the save button and have the following code that computes the correct selection for the select one choice

What this method does:

  • Get the iterator binding corresponding to the iterator name passed through ‘iteratorName’, in our case this will be ‘DeliveryTriggerTypeIterator’
  • Get the Row corresponding to the index passed , this will be ‘deliveryTrigger’ which holds the index value of the selectonechoice
  • Get the ‘SubCategory’ value from the corresponding row and return it.

private String getListValueFromIndex(int index, String iteratorName) {
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry()

DCIteratorBinding dciterContainer =
(DCIteratorBinding)bindings.get(iteratorName);

Row ri = dciterContainer.getRowAtRangeIndex(index);
String val = (String)ri.getAttribute("SubCategory");
return val;
}

The value returned will have the underlying subCategory value(‘THIRD_VALUE’) corresponding to the value selected in the UI as ”Third Option in the list”. Then the value can be saved to the ‘Captrgtyp’ column of the DB for ‘DeliveryRuleView’

Edit Operation

During the Edit operation of the record, we have to fetch the corresponding value for the selected record and populate for ‘Captrgtyp’ attribute in the selectonechoice.

What this method does:

  • The currentRow and the ‘Captrgtyp’ is passed as attribName to the method
  • Get the iterator binding corresponding to the iterator name passed through ‘iteratorName’, in our case this will be ‘DeliveryTriggerTypeIterator’
  • Get the RowSetIterator from the iiterator binding
  • Iterate over the record and check if the value is equal to the value of the ‘SubCategory’ from the rowSetIterator
  • If it’s equlal then save the index value to a variable ‘i’
  • Finally return the value ‘i’ which corresponds to corresct value in the selectonechoice

private Integer getListValueIndex(Row row, String iteratorName, String attribName) {
int i = 0;
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry()

DCIteratorBinding dciterContainer =
(DCIteratorBinding)bindings.get(iteratorName);

RowSetIterator rs = dciterContainer.getRowSetIterator();
Row ri = rs.first();
for(int index = 0;index < rs.getRowCount(); index ++){
String temp = (String)ri.getAttribute("SubCategory");
String ar = (String)row.getAttribute(attribName);
if(ar != null && temp.equals(ar.toString().trim())){
i = index;
}
ri = rs.next();
}

return i;
}