Shay Shmeltzer's Oracle Development Tools Tips

Java Class Data Control and ADF Binding Tricks Demo

Shay Shmeltzer
Director of Product Management - Oracle

This demo started from a simple request on the OTN forum asking how would you go about creating a JSF page that reads and writes a file content.

The quick answer I gave was that you can do this with a simple Java class that you expose as a datacontrol. But then I started thinking there will be some more tricky parts that you'll need to do in order to get the UI and binding to work exactly as you would like. The trick is to merge the result of one operation to be the input for the other operation. I played around with the solution I provided and decided to record this since there are a few steps here that will be useful to refer people to in the future.

The "Tricky Parts" that demo shows are:

1. Creating a data control from a simple Java class

2. Binding with ADF Parameter Form to invoke methods

3. Setting the value for method's parameters using the binding tab

4. Creating a backing bean for a JSF page

5. Modifying a default ADF method in a backing bean

5. Accessing an ADF binding control value in your backing bean

6. Binding an existing JSF components to a backing bean

7. Deleting a component from a JSF page without deleting it's binding

Here is the demo:

I hope this helps.

(And sorry that I got a phone call and an IM while recording :-) )

Note - some people requested to see the actual code - you can find the completed workspace here.

Join the discussion

Comments ( 19 )
  • husain Tuesday, August 4, 2009
    Thanks Shay !
    As always very simple and lucid explanation.
    1. One question though. Could we have populated the return value of 'readFile' directly (using EL declaratively) into the text box bound to the writeFile input variable? This would have eliminated creating a backing bean isnt it?
    2. I have not been able to understand binding API completely. How did the ControlBinding class for the 'Return' binding get converted into String used in setValue() method? Shouldnt it have needed 'inputValue' of Return binding? (just like we use in EL bindings.return.inputValue).
    Please advice.
    PS. ScreenToaster widget doent allow us to scroll thru the video and finding what we want sometimes requires us to go thru the entire tutorial :)
  • shay Tuesday, August 4, 2009
    The tricky part is that the return value from the read operation is in a "read-only" mode - so if you used that EL as the value for the inputTextItem for the writeFile - it would have turned it into an output text.
    I'm guessing this also explains the reason you didn't need the inputValue.
  • husain Wednesday, August 5, 2009
    You are right. I tried to use a richTextEditor to display a value from a java file and used EL #{bindings.return.inputValue} and the RTE was displayed as output text. However I tried to put the EL #{bindings.return} and it does seem to work now.
    Is it possible to share your code or is it possible that i send you my code that worked?
  • Matt Orsie Monday, November 16, 2009
    Did you post the project for this example anywhere?
  • shay Monday, November 16, 2009
    You can get the workspace for this blog here:
  • Stephane Wednesday, October 13, 2010
    Hi Shay
    Would you be able to push this solution to any ADF controls and would it make sense for you?
    Basically in the past we've been developing ADF application based on a DATA model and this is the regular way to do it. But sometimes you need to prototype how the application will look and you don't have yet the database model and teh middle tier. So could we imagine to use ADF controls with data that would be just populated in a bean or in a file (like you do) and redirect later the user interface to a real database model via the middle tier?
    In this context do you have more samples to point to, that you would know?
  • shay.shmeltzer Wednesday, October 13, 2010
    Stephane, for quick prototyping without an actual ADF data model we recommend using the ADF place holder data control.
    Some basic info here:
  • agungdmt Saturday, October 30, 2010
    hy Shay, that's nice tutorial...., but i have question
    1. with more binding between java class with jspx components, control data generated will be more. whether it will not affect the application ?
    2. why when I create a java class that the model> view object> class, there was an error [can not find the file DCX], my question, whether the data control can only be done in CiewController> ApplicationSource> class ..?.
    regard thanks ..:)
  • shay.shmeltzer Tuesday, November 2, 2010
    For 1 - I'm not sure what you mean here - yes there will be more meta-data created for the Java class, but what is the alternative? writing a managed bean to access the Java class? how is this any simpler?
    2. Again I'm not exactly sure what you are trying to do, but you should be able to access any java class, right click it and create a data control. Then as long as your view project is mapped to depend on the project that contains your model you should be able to see them in your data control palette.
    If you are running into specific problems try posting on the JDeveloper forum on OTN.
  • cosmoghurl Monday, December 13, 2010
    Hi Shay,
    I have a JSF page that has a datacontrol.. I convert to portlet using "Create Portlet entry" in Jdev 11g. is it possible to call the data control using a portlet parameter passed to my portletized app?
  • shay.shmeltzer Monday, December 13, 2010
    I'm not too familiar with portlets - so it might be best to post the question on the WebCenter forum - but in general from your binding you should be able to access anything that is in the scope of the page and refer to it in your data control parameters.
  • melih Thursday, May 26, 2011
    I have don't data controls palette in JDeveloper 11g. How I can add?
  • shay Thursday, May 26, 2011
    Melih, make sure that you are using the Studio Edition of JDeveloper and that you are in the default role under tools->preferences->roles.
  • melih Friday, May 27, 2011
    I did it. Thanks shay:)
  • Belal Monday, July 4, 2011

    Thanks Shay for this great demo.

    i have question, i want to use java class as model layer and JSF as presentation layer (it is very important to use JSF tags not ADF tags)

    I successfully made simple application with methods return String values but I need to use method return List to use it to fill JSF table (Again JSF table not ADF table), I can't use drag and drop cause it generate ADF tags, I need ur help

  • Shay Tuesday, July 5, 2011


    The drag and drop binding is provided by ADF both for ADF Faces and the Trinidad components see example here: http://blogs.oracle.com/shay/2009/02/using_trinidad_in_jdeveloper_1.html

    So if you can't use ADF Faces Trinidad is your option.

    If you can't use Trinidad either - then you'll need to use regular JSF binding by createing managed beans to hold your data.

    As a side note,

    Why can't you use ADF Faces? Is it because of licensing issues? if so note that using ADF Binding has the same license as ADF Faces - so you probably can't use that either.

  • belal Monday, July 18, 2011

    thanks for ur answer Shay,

    I have another problem (I am newbie) and I need your help

    in my application all users and roles must be created from the application, not form jdeveloper ,weblogic console or Active Directory.

    each created user will be assigned to

    - user name and password from Active Directory to authentication operation

    - group created in the application and has no relation with AD groups for Authorization operation

    in English: username and password from AD, groups and permissions from the application

    what I have to use, and if there any example will be great


  • guest Wednesday, September 14, 2011

    I am trying the input file and backing bean, for read/write the reader fails; would you please provide the code snippet and relevant printscreen

  • Shay Thursday, September 15, 2011

    guest - I added a link to the actual JDeveloper workspace that you can download and try -

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.