Thursday, October 7, 2010

autoSuggestBehavior using Database Query

autoSuggestBehavior is new addition in oracle ADF 11g used to display suggestedItems in a drop down box for an editable component in webpage based on user input on that. In this post what I am trying to show is an implementation of autoSuggestBehavior. Weblog for the AMIS Technology corner has a very good post for that. I am trying to leverage database persistence with autoSuggestBehavior. Data which is displayed as suggestedItems can be taken from backing bean (we can refer (http://technology.amis.nl/blog/6581/adf-11g-the-native-autosuggest-behavior for that methodology) or we can use data from database tables. In this post I have implemented that.

Below is the output of that implementation.


I have created a SQL script for creating country table and inserting values to that table. Please refer http://www.box.net/shared/g6hm06lbvd for downloading that script.

To achieve this only unlike other ADF projects we need not to create any Entity object, view object, Application Module. We can directly start working on webpage. As discussed earlier autosuggestBehavior shows suggestedItems for editable component in webpage. So we have used an inputText and attach viewscope managed bean procedure to the suggestedItems.



The Procedure is as follows


Used getCountries () procedure is as follows


I have used JDBC connection from managed bean to retrieve all country details. Below procedure is used for that.


Above method shows the Implementation without using any ADF Components like Entity, View, and ApplicationModule. But we can achieve same using a view object named "CountryEntityObjectView" and expose that view in Application Module. So that It will reflect in data control.


After that we need to create an Iterator in Page Definition file like below


Make sure that Its Range Size is Sufficient enough to capture all country names. We need to use this Iterator in our Managed Bean Procedure for suggestedItems (showed in 3rd Screen Shot here) as below


download link for Managed Bean java code is http://www.box.net/shared/or2olv7ftz , for webpage is http://www.box.net/shared/g71rrk6lc2and for page definition file is http://www.box.net/shared/zmpt2fh0ms/

Thursday, September 23, 2010

ADF Coding Standard Document Template

I have created an ADF coding standard document template,please refer below URL for that. Hope it will help and please give your feedback about that.

http://www.box.net/shared/na4o2rvtdm

Friday, August 27, 2010

Bounded Task Flow In Popup and Resetting Field data in Popup using popupFetchListener

In my older post (Insert Into Multiple Tables using Bounded TaskFlow in ADF ) the use case I had shown is having a drawback like data from table got automatically populated (as Shown Below) as user navigates to the bounded taskflow region from main page for creating a new Employee. In this blog I am trying to make some modification in my ViewController project so that the issue got resolved.



Step1: Create a Bounded task flow and make sure that 'Create Train' is selected.


Step 2: Drag View from Component palate and rename it likes below. Please follow my previous post (Insert Into Multiple Tables using Bounded TaskFlow in ADF and refer Figure 2 to Figure 6 ) to create those pages. Make sure those page extension should be *.jsff instead of *.jspx.

Add train Button and Train Button Bar for all pages in Task Flow like below


After completing all jsff pages bounded task flow will look like below.



Add valid name for all View id in Task Flow document source (task-flow-definition.xml)



Step 3: Modify Employee.jspx page

In my previous post (Insert Into Multiple Tables using Bounded TaskFlow in ADF) we have used Command Links for creating Employees Please refer to Figure 1 for this post. Now we can make it more fancy by using images and user can click on it to navigate to taskflows.

I have used images like for (AddProfile.PNG) Adding Employee, for searching Employee, for editing Employee


We can use popupFetchListener and attach it to our managed Bean using a method so that the method will execute at the time the popup rendered


  1. public void fetchPopupListener( PopupFetchEvent popupFetchEvent) {
  2. System.out. println ("In Fetch PopUP Listener"); //Create Insert For Baisc Info
  3. BindingContainer bindingsbasic = BindingContext . getCurrent() . getCurrentBindingsEntry() ;
  4. OperationBinding operationBindingbasic = bindingsbasic. getOperationBinding ("CreateInsertBasic");
  5. Object resultbasic = operationBindingbasic. execute() ; //Create Insert For Contact Info
  6. BindingContainer bindingscontact = BindingContext . getCurrent() . getCurrentBindingsEntry() ;
  7. OperationBinding operationBindingcontact = bindingscontact. getOperationBinding ("CreateInsertContact");
  8. Object resultcontact = operationBindingcontact. execute() ; //Create Insert For Master Info
  9. BindingContainer bindingsmaster = BindingContext . getCurrent() . getCurrentBindingsEntry() ;
  10. OperationBinding operationBindingmaster = bindingsmaster. getOperationBinding ("CreateInsertMaster");
  11. Object resultmaster = operationBindingmaster. execute() ; //Create Insert For Baisc Info
  12. BindingContainer bindingsedu = BindingContext . getCurrent() . getCurrentBindingsEntry() ;
  13. OperationBinding operationBindingedu = bindingsedu. getOperationBinding ("CreateInsertEducation");
  14. Object resultedu = operationBindingedu. execute() ; //Create Insert For Job Info
  15. BindingContainer bindingsjob = BindingContext . getCurrent() . getCurrentBindingsEntry() ;
  16. OperationBinding operationBindingjob = bindingsjob. getOperationBinding ("CreateInsertJob");
  17. Object resultjob = operationBindingjob. execute() ;
  18. }

But Make sure that you are having below bindings created in


Drag newly created task-flow-definition to the dialog and it will display the dialog below


We can test the page and it comes like this

Sunday, August 15, 2010

ADF tree navigation to third level and Workaround for “ADF Tree Not Inside Container”

Step 1: Create view object based on Product table. Structure of this table is shown in Figure 1.



Figure: 1

Create view object "CategoryViewObj" based upon below query on above product table.



Figure: 2

Create view object "ProducerViewObj" based upon below query on above product table.



Figure: 3

Create view object "ProductViewObj" based upon below query on above product table.



Figure: 4

Step 2: Create view link between CategoryViewObj and ProducerViewObj using CategoryId and ProducerViewObj and ProductViewObj using ProducerCode



Figure: 5



Figure: 6

Step 3: Wrap all ViewObjects and ViewLinks in application module like below.

Drag "CategoryViewObj" under ProductAppModule and named it CategoryViewInstance. Drag the viewlink immediate below it and put it under CategoryViewInstance and renamed it to "ProducerInstance" and drag the view link immediate below of "ProducerViewObj" and put it under "ProducerInstance".




Figure: 7

Step 4: Create ADF tree table by dragging "CategoryViewInstance" from data control palate and add its two level of children by clicking green add button adjacent to it. We can select our own display attributes for each level like below.



Figure: 8



Figure: 9



Figure: 10

Modify nodestamp facet under ADF treetable component like below.



Figure: 11

Add columns like below



Figure: 12

While testing the page we face this error.


<RegistrationConfigurator><handleError> Server Exception during PPR, #1
java.lang.IllegalStateException: ADFv: Not inside a container.
at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.exitContainer(FacesCtrlHierBinding.java:672) at oracle.adfinternal.view.faces.model.FlattenedTreeCollectionModel.getRowIndex(FlattenedTreeCollectionModel.java:109)
at oracle.adfinternal.view.faces.renderkit.rich.TreeRendererUtils$1.getRowIndex(TreeRendererUtils.java:552)
at oracle.adfinternal.view.faces.renderkit.rich.TreeTableRenderer.handleExpand(TreeTableRenderer.java:520)



This will come because we did not set any key attribute in our view objects and ADF tree table is not able to find row index. So we need to set key attributes to our view objects like below.



Figure: 13



Figure: 14



Figure: 15

While testing we get our desired output.

Sunday, July 18, 2010

Display Data as Tree format using Popup in ADF

Step1: Setting up Database Objects

  • // CREATING TABLES
  • CREATE TABLE JAVATOPIC (
  • TOPICNAME VARCHAR2(150 BYTE) NOT NULL,
  • TOPICINDEX NUMBER(2)
  • )

  • CREATE TABLE JAVA_TOPIC_DETAILS (
  • TOPICINDEX NUMBER(2),
  • SUB1 VARCHAR2(50),
  • )
  • Figure 1: Datbase Details

    Step 2: Creating EntityObjects, ViewObjects, ViewLinks

    Step 2.1 Create Entity Objects (JavaTopicEntityObject, TopicDetailsEntityObject)



    Create Entity Objects for JAVATOPIC database table.

    Create Entity Objects for JAVA_TOPIC_DETAILS database table.


    Step 2.2: Create View Objects (JavaTopicEntityObjectView, TopicDetailsEntityObjectView)

    Create View object for JavaTopicEntityObject


    Figure 4: Create View for JavaTopicEntityObject

    Create view object for TopicDetailsEntityObject

    Figure 5: Create TopicDetailsEntityObjectView view object

    Step 2.3 Create ViewLink

    We can create a view link between two created views shown in step 2.2. Corresponding query will be



    Select b.sub1 from JAVATOPIC a, java_topic_details b where a.topicindex = b.topicindex and a.topicindex = :topicindex







    Step 3: Wrap ViewObjects and ViewLinks in ApplicationModule

    Step 4: Create a Popup and attach it with CommandLink

    //Step 4.1 Creating Empty Popup
    1. <af:popup id ="trainpopup"> //Add contents here </af:popup> //Step 4.2 Attach a Command Link with a PopUp
    2. <af:commandLink text ="Training Contents" binding ="#{TrainingFeedbackBean.showContent}">
    3. <af:showPopupBehavior popupId ="trainpopup" align ="afterStart"/>
    4. </af:commandLink>
    Step 5: Create Tree Binding:

    Tree Model for Source Data

    Figure 6: Create ADF Binding Tree

    Tree Model for Target Data





    1. <tree IterBinding ="JavaTopicEntityObjectView2Iterator" id ="JavaTopicEntityObjectView2"> //Parent Node Definition
    2. <nodeDefinition DefName ="com.emerson.javatraining.model.view.JavaTopicEntityObjectView" Name ="JavaTopicEntityObjectView20">
    3. <AttrNames>
    4. <Item Value ="Topicname"/>
    5. </AttrNames>
    6. <Accessors>
    7. <Item Value ="TopicDetailsEntityObjectView"/>
    8. </Accessors>
    9. </nodeDefinition> //Child Node Definition
    10. <nodeDefinition DefName = "com.emerson.javatraining.model.view.TopicDetailsEntityObjectView" Name ="JavaTopicEntityObjectView21">
    11. <AttrNames>
    12. <Item Value ="Sub1"/>
    13. </AttrNames>
    14. </nodeDefinition>
    15. </tree>


    Step 6: Use Tree Binding in Popup
    1. <af:popup id ="trainpopup">
    2. <af:dialog okVisible ="false" cancelVisible ="false">
    3. <af:panelHeader text ="Training Contents" inlineStyle ="height:379px;width:400px;">
    4. <af:tree value ="#{bindings.JavaTopicEntityObjectView2.treeModel}"
    5. var ="node" selectionListener ="#{bindings.JavaTopicEntityObjectView2.treeModel.makeCurrent}"
    6. rowSelection ="single" id ="t1" visible ="true">
    7. <f:facet name ="nodeStamp">
    8. <af:outputText value ="#{node}" id ="ot1"/>
    9. <f:facet>
    10. </af:tree>
    11. </af:panelHeader>
    12. </af:dialog>
    13. </af:popup>


    Step 7: Output:

    Figure 7: View Output



    Please try to find similarity between data displayed as child node with Java_topic_details and data displayed as Root node with javatopic database objects (refer figure 1).

    Sunday, July 4, 2010

    Updatable View and Read Only View in ADF 11.1.1.2.0

    Difference in Components


    Both Types of views have some common components like ViewAttribute and DesignTime .Updatable View uses Underlying Entity objects where as Read only view doesn't require any underlying Entity Object as it uses SQL Query. Below snap shows the difference between an Updatable view based on "ExpertiseAreas" database object and a read only view for same (ExpertiseAreas) object from its component's stand point.



    DesignTime components are common in both types of view but <Attr> is having different values.

    Updatable View

    Read Only View

    <DesignTime>

    <Attr Name="_codeGenFlag2"

    Value="Access|VarAccess"/>

    </DesignTime>

    <DesignTime>

    <Attr Name="_isExpertMode" Value="true"/>

    </DesignTime>


    Updatable View uses Underlying Entity objects where as Read only view doesn't require any underlying Entity Object as it uses SQL Query.

    Updatable View

    Read Only View

    <EntityUsage

    Name="ExpertiesAreas"

    Entity="model.ExpertiesAreas"/>


    <SQLQuery>

    <![CDATA[SELECT ExpertiesAreas.PROD_ID,

    ExpertiesAreas.USER_ID,

    ExpertiesAreas.EXPERTISE_LEVEL,

    ExpertiesAreas.NOTES

    FROM EXPERTISE_AREAS ExpertiesAreas]]>

    </SQLQuery>


    As it is a read only view it contains two attributes IsUpdateable and IsPersistent and their value is set to false. Updatable view have EntityAttrName and EntityUsage as it is dependent on underlying entity Objects to represent a column where as Read Only View is using Type, ColumnType, Expression and SQLType to represent same. Please refer below table where an Updatable View having column ProdId represents it and same thing is represented in Read Only View.

    Updatable View

    Read Only View

    <ViewAttribute

    Name="ProdId"

    IsNotNull="true"

    PrecisionRule="true"


    EntityAttrName="ProdId"

    EntityUsage="ExpertiesAreas"

    AliasName="PROD_ID">

    </ViewAttribute>

    <ViewAttribute

    Name="ProdId"

    IsNotNull="true"

    PrecisionRule="true"


    IsUpdateable="false"

    IsPersistent="false"


    Type="oracle.jbo.domain.Number"

    ColumnType="NUMBER"

    AliasName="PROD_ID"


    Expression="PROD_ID"

    SQLType="NUMERIC">

    <DesignTime>

    <Attr Name="_DisplaySize" Value="22"/>

    </DesignTime>

    </ViewAttribute>

    Sunday, June 27, 2010

    Weblogic throws "java.sql.SQLException: ORA-01005: null password given" Work Around

    After Installing Weblogic server 10.3 when I am trying to run an deployed ADF application, then AdminServer.log in $WLS_HOME/user_projects/domain/<domain_name>/Server/AdminServer/logs shows below error. The application I had deployed having all JDBC credentials but still Weblogic is not able to find proper credentials.

    note: please click on each image to get full size





    As work around I have used property (-Djps.app.credential.overwrite.allowed = true) in JAVA_PROPERTY section of setDomainEnv.sh script file in $WLS_HOME/user_projects/domain/<domain_name>/bin directory.






    After modifying Weblogic server needs to be restarted.



    And I get my desire output