Thursday, November 27, 2014

MAF : Problem in connecting Nexus 7 tablet for debugging MAF Application

With the Nexus7 , 1st generation tablet i often come across missing driver problems and it was not getting recognised by jDeveloper and thus debugging MAF Applications would be not possible.

ERROR:

When i deploy to device from the jdeveloper i was getting an error in the console saying that, no devices are recognised ,please restart abd server.

Here just restarting the abd server might not help since the driver was missing.

FIX:

Download the driver from here:

http://developer.android.com/sdk/win-usb.html#download

and go to device manager , find the device NEXUS7 ,right click and  go to its properties, hit the update Driver Button . Browse the folder location where the driver was downloaded.

It may not work if tried to deploy soon after the update, So restart the system and retry and it works for me.

Thanks, Happy Debugging !!!


Friday, July 25, 2014

Operations Of Viewobject in ADF

This post explains the use of all the available operations of Viewobject in ADF.

These can be seen when you create a Viewobject in the Model project and expand the
Viewobject -> Operations folder in Datacontrols palette.




1) Create

This operation opens a slot for a new record in the collection.
The new record is added to the collection after the page is submitted.

Works with ADF Form (af:panelFormLayout).
In ADF Table it does not show the new row inserted in the Table.
Does not require cleanup task when the user abandons the form.



2) Create Insert

The new empty record is inserted into the collection as part of the operation. This means that even if the user never submits the page, the row will still be in the collection.

Works with both ADF Table and the ADF From.
In ADF Table it shows the new row inserted in the Table.
Require cleanup task when the user abandons the form.



3) CreateWithParams

This operation is same as CreateInsert and only difference is that we can assign default values on CreateInsert.
CreateWithParams operation allows us to define parameter to assign it to the new row for some specific attribute.

How To Do: Insert “NamedData” inside ExecuteWithParams action binding in pagedef , give the "key" and "value" attribute. 

Pagedef Entry:
<action IterBinding="EmployeesView1Iterator" id="CreateWithParams" RequiresUpdateModel="true" Action="createWithParams">
<NamedData NDName="FirstName" NDType="java.lang.String" NDValue="Hari"/>
</action>



4) Delete

Deletes the first row in the rowset unless is it directed to a particular row.
In order to delete a selected row, we have to make it as a current Row and then execute the Delete Operation.

How To Do: For ex. In a table check “Row Selection as Single” while dropping the table on the page or use any other operations such as setCurrentRowWithKey, setCurrentRowWithKeyValue etc.



5) Execute

Executes the VO.



6) Execute With Params

Execute the VO by passing values to the Bind Variables.

How To Do: Drag the operation on to the page. Edit the operation in the pagedef and pass the parameters to the bindVariables



7) Find

Used to search some record in the VO.

How To Do: Drop a VO as a form in the jsff , Drop “Find” and “Execute” operations in the jsff.
Click find to initialize the inputTexts, Enter the Record to be searched in the inputtext and click Execute.



8) First

Navigates to the first record/row in the rowset. ( For Ex. In a panelFormLayout)



9) Last

Navigates to the last record/row in the rowset. ( For Ex. In a panelFormLayout)



10) Next

Navigates to the next record/row in the rowset. ( For Ex. In a panelFormLayout)



11) NextSet

Navigates to the next set of record/rows based on the rangesize value in the iterator binding in pagedef.

For ex: in the rangeSize=5, in initial rowset (1-5), clicking on nextSet will display the 6th record.



12) Previous

Navigates to the previous record/row in the rowset. ( For Ex. In a panelFormLayout)



13) PreviousSet

Navigates to the previous set of record/rows based on the rangesize value in the iterator binding in pagedef.

For ex: in the rangeSize=5, in final rowset (10-15), clicking on previous will display the 9th record .



14) RemoveRowWithKey

Takes the serialized String of a row ("#{row.rowKeyStr}") as a parameter and deletes the currentrow

How To Do: Drag the operation as a button “Delete” to a column in a table and pass the parameter in pagedef as below,

Pagedef Entry:
<action IterBinding="EmployeesView1Iterator" id="removeRowWithKey" RequiresUpdateModel="false" Action="removeRowWithKey">
<NamedData NDName="rowKey" NDType="java.lang.String" NDValue="#{row.rowKeyStr}"/>
</action>

Click of “Delete” Button will delete the current row. This can be done easily by checking “Row Selection as Single” while dropping the table on the page . However this will be usefull if you stamp out the collection in a af:iterator or af:foreach



15) setCurrentRowWithKey

Takes the serialized String of a row ("#{row.rowKeyStr}") as a parameter and sets the row as the currentrow

How to Do: Drag the operation as a button “Make Current” to a column in a table and pass the parameter in pagedef as below

Pagedef Entry:
<action IterBinding="EmployeesView1Iterator" id="setCurrentRowWithKey" RequiresUpdateModel="false" Action="setCurrentRowWithKey">
<NamedData NDName="rowKey" NDType="java.lang.String" NDValue="#{row.rowKeyStr}"/>
</action>

Click of “Make Current” button will make the row as the current row. Then you can do other operations required on the current row (For ex. Delete, Edit)



16) setCurrentRowWithKeyValue

Takes the static Value (“1001”) / from an EL as a parameter and sets the row as the currentrow.
1001 should be the primary key identifying a particular row in the collection.

How to Do: Drag the operation as a button outside the table and pass the parameter in pagedef as below

Pagedef Entry:
<action IterBinding="EmployeesView1Iterator" id="setCurrentRowWithKeyValue" RequiresUpdateModel="false" Action=" setCurrentRowWithKeyValue">
<NamedData NDName="rowKey" NDType="java.lang.String" NDValue="1001"/>
</action>

The row with the primary key “1001” will be set as the current row and further operations can be performed on it.

Thursday, July 24, 2014

Implementing Internationalization in ADF using List Resource Bundle / Java Resource Bundles.

There are numerous posts on how to implement Internationalization using properties file. Here my post explains how to implement it using "List Resource Bundle".

Internationalization provides easy adaptation of the application to local languages.
As a simple example, people accessing the application in US will see the content in English (Assuming the browser language is set to English) and People in Italy will see the content displayed in Italian.
This can be achieved by not hardcoding the label String in pages, rather fetching it from resource Bundles.
There are 3 types of Resource Bundles:
  •         .properties files
  •        .xliff files
  •        .java files ( List Resource Bundles)

Here we going to discuss the step by step implementation of third type.
Creating and using List Resource Bundles.


a) Create a project and set the project properties.

  1. Create a ADF Project.
  2. Right Click on the Project and Open the Project Properties, Select Resource Bundle from the list in the left side.

  3. Radio button “One Bundle per project” will be selected by default and a default value will be already entered for the Resource Bundle Name. i.e ViewControllerBundle . Change the name according to your project naming standards.
  4. Select “List Resource Bundle” in the “Resource Bundle Type” dropdown. Click OK.




b) Create the Page /Page Fragment and Resource Bundles     


  1. Create / locate a Jspx Page / Jsff Page Fragment where you want to add the String from the ResourceBundle, add the required component to the page ( For Ex, Output Text).

  2. Open the property inspector and click the icon beside the value attribute field of OutputText to open the property Menu.

  3. In this property menu , select “ Select Text Resource” and a popup will be opened, Fill in the “Display Value” field as the String which need to be displayed and the “Key” field will be automatically filled up, Optionally Enter the “Description”. Click OK.

  4. A <Resource Bundle Name>.java file will be automatically created and the Key –Value pair array will be created in the java class.
    <Resource Bundle Name> is the name which you gave in the project properties, “Default Resource Bundle Name” field as explained earlier.
    The Java class Extends the class ListResourceBundle.java and implements the abstract method getContents().

  5. This will be the default Bundle for the project and if you need other Bundles to support other languages, you need to create .java files with the name format <Resource Bundle Name>_<Lang Code>.java
    For ex. ViewControllerBundle_it.java , “it” means “Italian” here.
    This java file need to extend the Base Class, Default Resource Bundle ( Here its ViewControllerBundle.java) , Add the Key-Value pair array with “Key” the same as Base Resource Bundle Key and the “Value” refers to the language specific String.

  6. Now the af:outputText in the page looks like below. Its value is referenced from the Resource Bundle and it is dependent on the language preference of the browser.


If English, it will display as “My Name”.

If Italian, it will display as “Il mio nome”.

c) Configure the faces-config.xml

  1. Next step is register the Locale and Resource Bundle in faces-config.xml. Open the faces-config.xml in the path WEB-INF/faces-config.xml in your Viewcontroller project.
     
  2. In the Overview tab, click Application. ( Image Below )
    Under the Resource Bundle Section add a row and enter the Fully Qualified Resource Bundle Name as the “Base Name” and a String say “res” in “Var Name”.

    Using the String "res" we can access the strings in the bundle using an EL #{res['MY_NAME']}

    Under the Locale Config Section , Enter the Default Locale . Here I enter “en” (English) and “it”(Italian) as Supported Locale because we have two .java resource bundle files, ViewControllerBundle.java( This is the default bundle and for English) and ViewControllerBundle_it.java (This is for Italian language, if you change the browser language settings) .
  3. In the same way you can add as many ViewControllerBundle_<lang> .java files and corresponding supported locale entries in faces-config.xml for supporting different languages.



d) Changing the Language preference of the browser and running the application 


  1. Change / Set the language preference in the browser. (Image Below)
    Here I change the preference of IE Browser to set English as the primary language by moving it to top. Then the String will be fetched from the default bundle for English.

    And also I add a new language Italian.
    If I move Italian language up and make it as a primary language, Then the String will be fetched from the <Resource Bundle Name>_it.java which is for Italian.

  2. This is the Screen when we set the Primary Language as “English” and run the application

  3.  This is the Screen when we set the Primary Language as “Italian” and run the application.