JavaBeans Data Control / Managed beans interaction

Working in JDev/ADF 11g
I have an Application Scoped ADF managed bean that initializes some services for my ADF application. (These are non-database backed business services and so they do not integrate as tightly with Jdev as data controls). They require some constructor arguments and other initialization parameters and so they cannot be written as pure beans.
I wrote Java Beans to use as data controls that wrap these services. What I would like to do is to keep the creation of these services in the application scoped bean, so they can be used programmatically in other areas. When the data controls beans are initialized, I want to grab their underlying services from the application scoped bean via the ADFContext.
My issue is that at the time the data control beans are instantiated, the ADFContext returns null when accessing the application scoped bean - ie it has not been created yet.
What is the proper way to pass initialization data to JavaBean data controls? Ideally I could simply pass the data control a reference to its underlying service.
If Im going about this all the wrong way, with the application scoped bean holding the application wide business services, please feel free to advise me otherwise.
Thanks!

Okay - so I figured out one way to do this (detailed below), but my question still stands as to if there is a proper way to get information to a JavaBean data control when it is instantiated.
What I just learned is that although my application scoped bean does not exist when the data control is created, it can exist when the the data control is called by the .jspx. I say 'can' because it will only exist if the .jspx backing bean references the application scoped bean as a managed property. i.e. ADF will create the data control, create the page bean, create the application bean (b/c the page needs it), and then call the data control, at which point the data control will find the application scoped bean. This is sort of a hack, since it requires an unintuitive setting for it work. so I think my question still stands, how to pass data from the application scoped bean to the data control.

Similar Messages

  • Inserting and deleting with JavaBean Data Control

    Hi,
    I have been teaching myself how to use Data Controls with a Struts applications. In order to understand the fundamentals, I thought I could just use a simple javabean encapsulated in a Service facade to implement trivial CRUD operations.
    Upto this point I have the ability to Diplay a table of my objects, Edit a single object and display a single object using the Data control and struts. Unfortunately I am now stuck since all the help documents assume that either I am using a Database bound business object or an EJB to implement my CRUD use cases. These have a lot more operations on their data control that are unavailable to JavaBean data controls.
    How do I go about implementing create and delete use cases with plain JavaBeans? Presumably there are Oracle foundation classes that I can extend that would allow me to expose more operations to the Data Control Pallete.
    Thanks for the input
    Suhail

    For JavaBean DataControl, you will have to write custom methods in servicefacade class which will create, delete or update the collections.
    Though you are not using EJB, following tutorial, shows how custom methods which implement crud operations are used with sessionfacacde (EJB Session bean).
    http://otn.oracle.com/products/jdev/collateral/tutorials/9050/ejbdatabinding_tut.html
    Following thread has discussion on how to refresh the collections from JavaBean.
    10g ADF : how to update the binding values in the UI layer ?
    or
    10g ADF : how to update the binding values in the UI layer ?
    raghu
    JDev Team

  • Is it possible to implemnt af:query using JavaBean Data Control?

    Is it possible to implemnt af:query using JavaBean Data Control?

    Fortunately for you and me, Oracle documents this stuff.
    http://docs.oracle.com/cd/E17904_01/web.1111/b31974/appendix_datacontrols.htm#BABGECDA

  • UI Hints for JavaBean Data Controls

    According to the new features for 11.1.2, "Bean data control metadata management improvements now only generate xml if needed (sparse xml)".
    Oracle JDeveloper and Oracle ADF 11g Release 2 (11.1.2.x): New Features (http://www.oracle.com/technetwork/developer-tools/jdev/jdev-11gr2-nf-404365.html)
    So long story short, the JavaBean xml is not generated any longer. Instead, by going through the DataControls.dcx, you can create a PDefViewObject xml that will allow you to edit, among other things, UI hints.
    Tutorial: http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html
    In previous releases, I have been able to edit the 'precision' of an attribute within the JavaBean xml.
    <Attribute Name="address" Type="java.lang.String" Precision="40"/>However, the PDefViewObject xml appears to not allow you to edit the 'precision'. Display Width, yes, but not Precision.
    When using the Expression Builder while building a ADF jspx, precision is still a selectable hint.
    #{bindings.site.hints.precision}So, how do I set this value in 11.1.2?

    Thank you for the reply; unfortunately, I have tried those steps. An xml file is created but it is a PDefViewObject, which does not have the precision parameter, not a JavaBean.
    <?xml version="1.0" encoding="windows-1252" ?>
    <!DOCTYPE PDefViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <PDefViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="Site">
      <DesignTime>
        <Attr Name="_DCName" Value="olvims.datamodel.DataControls.ODPublicFacadeLocal"/>
        <Attr Name="_SDName" Value="olvims.datamodel.Site"/>
      </DesignTime>
    </PDefViewObject>In JDeveloper 11.1.1, that process would create a JavaBean xml.
    <?xml version="1.0" encoding="UTF-8" ?>
    <JavaBean xmlns="http://xmlns.oracle.com/adfm/beanmodel" version="11.1.1.55.36"
              id="Site" Package="olvims.dispatch.datamodel"
              BeanClass="olvims.dispatch.datamodel.Site" isJavaBased="true">
      <Attribute Name="address" Type="java.lang.String" Precision="40"/>
      <Attribute Name="baseCode1" Type="java.lang.String" Precision="4"
                 PrimaryKey="true"/>
      <Attribute Name="city" Type="java.lang.String" Precision="50"/>
      <ConstructorMethod IsCollection="true" Type="olvims.dispatch.datamodel.Site"
                         BeanClass="olvims.dispatch.datamodel.Site" id="Site"/>
      </ConstructorMethod>
    </JavaBean>If I try replacing the PDefViewObject a JavaBean, I get the following error:
    JBO-26051: Unrecognized XML element tag JavaBean found in meta object persdef.olvims.datamodel.Base.In reference to your question, "what precision does for a String attribute?" Nothing directly that I am aware of; however, i have been using it with text boxes.
    I have been using it in the maximumLength parameter of an <af:inputText> to prevent the user from typing any more that the specified precision. I use the displayWidth in the columns parameter so that I could make my textboxes slightly larger than the maximum allowed characters.

  • How can I load the data of Manager Beans into an Array?

    Hi all!
    I have a problem when use the ADF model layer (JDeveloper 10g). I want to load the data of a Manager Bean into Array(such as: Array in JavaScript).But I don't know any ways to do.
    Are there any ways to do that?
    Please, help me!
    Thanks so much!

    Hi,
    there is a fundamental difference between an array in Java and an array in JavaScript as the latter is added to the output page while the first sits in a Java class on the server.
    Populating a Java array from a managed bean is straight froward: Just create the Array, loop through the source of the data - ADF binding or the ADF Faces table component - and fill it.
    For a JavaScript Array I would suggest to write the array into a js file and reference it from the web page (which might cause concurrency issues).
    Frank

  • Share data between managed beans

    I used Sun Studio Creator for jsf before
    and there I can create a class extending AbstractSessionBean
    which had a function named getBean(String beanName)
    If this bean is in session scope, it could get any managed bean
    in session or in application scope and access those properties.
    But that facility is for studio creator only.
    How can I access a property of a managed bean from another managed bean, if both are in session scope?

    ok I found the solution in
    http://forum.java.sun.com/thread.jspa?threadID=596776

  • Bean datacontrols and managed beans

    Hi,
    When I use bean data controls, my bean from which the datacontrol is created is in session scope. In this case, should I be using another managed bean for the UI purpose or shall I use the "data control bean" ?
    For eg:
    I have a an EmployeeManager which returns a list of employees. Now I created a data control from my EmployeeManager. And I create a table of employees on my jspx. Suppose I want to keep the last selected employee record for some back end processing ( maybe a web service call to get the Employee Salary details) , shall I keep the selected Employee in my EmployeeManager or should I have a managed bean?
    If I keep this in managed bean, again I need it in my EmployeeManager for back end call. Please guide me.
    Thanks,
    Manoj

    Model layer binds presentation layer to business logic and data services and vise versa. In ADF applications the model layer is implemented as ADF DataControls + ADF Bindings. The presentation layer is implemented usually as UI. The business logic and data services may be implemented in various ways (ADF BC, EJB, POJO, Java Beans, Web Services, etc.). See this ADF architecture diagram.
    You should separate these layers from each other. In this way you will be able to replace the implementation of some layer without re-engineering the other ones (for example, to replace the bean-based data services with ADF based ones without re-engineering the user interface).
    Keeping track of the current records is responsibility of the model layer and the business/data services. The JSF managed beans are not a proper place to do it because they are part of the presentation layer. (In theory if you have good application architecture and you replace the implementation of the data service, then you should not be forced to modify the presentation layer too).
    ADF iterator bindings (defined in PageDefs) have a built-in funtionality for keeping track of current rows. In my opinion, they have this functionality regardless of the kind of the data services they are based on, so if you use ADF bindings you should have this functionality out-of-the-box even in case of a bean-based DataControl.

  • Managed Beans vs. POJO Data Control for sharing data

    Hi,
    I am currently using JAX-WS proxy client and POJO Data Controls to retrieve data from web services. This data needs to be shared across users. Normally I would use application scoped managed beans for this, but since I prefer using data controls and the binding layer, would using static POJO Data Control classes achieve the same thing?

    Hi,
    Data Controls don't exist across user sessions so in your use case use a managed bean in application scope. If you want to make this available from a Data Control
    - create a POJO
    - Use EL in the POJO to access the managed bean
    - Create a DataControl from the POJO
    This way the Data Control exposes the data as an API but itself always reaches out to the managed bean as a data store/cache
    Frank

  • Selected node in a tree table (via Data Controls and not managed bean)

    I am facing some problems in getting the selected row in a tree table.I have used data controls for creating the tree on the page.
    I have 3 POJO's,ex; Class AB which has a list of Class CD.And Class CD has a list of class EF. (Used for the tree table)
    Now i have a java class, called MyDelegate.java which has a list of AB.I generated data controls off this MyDelegate class and have dropped the ABlist as a tree table (also displaying CD and EF in the tree table).
    It displays fine with nodes of AB,CD (child of AB)and EF(child of CD)
    The tree table is not bound to any managed bean.
    For performing actions on the tree, i create a method - "doSomething() in the delegate class",generate data controls and drop it as a button.
    Inside doSomething(), i need acess to the selected node in the tree (it can be a node of type AB or CD or EF).
    The problem: I always get access to the node of type AB, and not the child nodes no matter what i click in the tree table.
    doSomething(){
    DCBindingContainer dcBindingContainer = (DCBindingContainer)ADFUtil.evaluateEL("#{bindings}");
    DCIteratorBinding dcTreeIteratorBinding = dcBindingContainer.findIteratorBinding("lstABIterator");
    RowSetIterator rowTreeSetIterator = dcTreeIteratorBinding.getRowSetIterator();
    DCDataRow rowTree = (DCDataRow)rowTreeSetIterator.getCurrentRow();
    if (rowTree.getDataProvider() instanceof AB) {
              //do something
              AB selectedAB = (AB)row.getDataProvider();
    } else if (rowTree.getDataProvider() instanceof CD){
              //do something
    } else if (rowTree.getDataProvider() instanceof EF) {
              // do something
    How do i access the "selected child node of the tree table" here in the delegate class method? Pls help.

    Hi Frank,
    Thanks for the response. In my case, i dont have a managed bean, so i am slightly unsure how to do it.
    There is a mention "Note that another way to access the treeTable component at runtime is to search for it in JavaServer Faces UIViewRoot. This latter option allows you to write more generic code and does not require to create a page dependency to a managed bean"
    How do i use this adf view root (without a managed bean) to get hold of the selected row in the tree table. Pls help.
    Thanks.

  • EJB, JPA E MANAGED BEAN WITHOUT DATA CONTROL

    How do I build a simple crud with no EJB without data controls. Exposing the methods of my bean class.
    Who can help me thanks.
    Edited by: 941064 on 15/06/2012 14:48

    You'll write managed beans that access your EJB service facade.
    You can use @EJB injection to get this working.
    http://biemond.blogspot.co.uk/2010/04/ejb-injection-in-jsf-managed-bean.html

  • Clear all rows in a Bean Data Control

    I am using JDeveloper 11.1.1.6
    In my use case I have a screen that interacts with a Bean Data Control I have followed the steps in the following URL to create a Bean Data Control
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html
    My screen successfully interacts with the Bean Data Control. This screen lives in a Bounded Task Flow (BTF). I can add rows using a Create Insert binding and can delete Rows as well. Once the user gets all rows into the Bean Data Control that they want inserted to a DB table, I can iterate through the Bean Data Control and post those records to the DB. It is possible for the users to add rows to the Bean Data Control and then link to a brand new screen which is in a different BTF which leaves rows in the Bean Data Control. Now the user goes back to the original screen. Upon returning, I want to empty (clear all rows) for the Bean Data Control so that they have a fresh start. Could you please provide guidance on what I might need to do to be able to clear a Bean Data Control when entering a BTF

    Hi,
    You can create a method to clear your Bean Data Control and call it with an invokeAction with property refresh="ifNeeded" and refreshCondition="#{pageFlowScope.isTimeToClearAll}", so pageFlowScope.isTimeToClearAll must be true only when you need to clear the BDC.
    Check this article: http://www.gebs.ro/blog/oracle/oracle-adf-invokeaction/
    AP

  • BPM Process Data Object vs Managed Bean

    I need to store an ID which is the primary key of a record in a database in my BPM process so that I can use that to set the bind variable on my view object query. Is it better to store this ID in a process data object or in a managed bean and why is one better than the other?

    I suggest to do the other way.
    Store the BPM Process Instance Id in the Database when you create data in the table.
    Pass this Instance Id to the VO query parameters.
    You can create a page binding of this instance Id from the Data Controls
    I am assuming there is a 1-1 relation between your BPM Process and Database Row.

  • Header value in data table can be fetched from managed bean.

    hi
    My requirement is to display a report in which column headers are also retrieved from data base, it cannot be hardcoded.
    instead of My Column it should come from managed bean
    <f:facet name="header">
    <h:outputText value="My Column"/>
    </f:facet>
    I am not able to fetch the header value from the managed bean.
    I tried
    <f:facet name="header">
    <h:outputText value="#{character.name}"/>
    </f:facet>
    but failed.
    Is there any way i can fetch these values at run time.

    Is that bean the main bean or the row object? It should be the main bean. There is only one column per table, its value is not to be derived from the row object.

  • Should we really go for bean data controls for a new project?

    Hi,
    I am still new data controls and trying to figure out the advantages of using bean data controls for our new project. Our UI is going to have customized UI components and our back end is going to be a tcp/ip server.
    Is it a good idea to develop java beans and then create data controls to bind to UI layer? I think it makes sense to use data controls if we want to use existing java beans. Maybe we would be separating the model layer by using data controls, but only thing it would be doing for us would be the simple object calls to my java beans. Would it be better to use data controls or use I choose to make object calls?
    Thanks,
    Manoj

    Hi,
    the POJO data control will always give you a benefit and develope productivity, unless what you have to build fits on a single page - in which case you may not mind the burdon of manual UI component binding
    Frank

  • How to query data from database and store it into Managed Bean ?

    Hi all,
    In our application we have requirement to store information within Managed Bean to be accessed by ADF pages.
    The information is stored in database tables.
    The question is :
    What is the efficient / recommended way to do that ?
    I do not use apps module to query the data because the information is required in View layer not the model layer
    Thank you for your help,
    xtanto

    Xtanto,
    if the information is stored in the database then the question is if there is a database connect open already. If yes, then why not using this connection to query for the data you want to access and store. Alternatively you can directly open a JDBC connection in a managed bean or access an EJB session bean. However, this comes with the price of an extra database connection.
    Make sure the managed bean is in session scope if you want to share the information without re-fetching it
    Frank

Maybe you are looking for

  • How to reverse the changes made in a report program

    Hi Friends,     I want to change a report program,but this report program is locked under one tp which is not yet released and it is in development only .I want to change the same report program but don't want to keep the changes done in the existing

  • Files to bytes

    i want to store the word document into the data base. how can it be done by converting the word document to bytes and then store the same in the data base.

  • Finding the A frame with G Cadence plug in or any other mean

    hi, I'm working with an editor to successfully reverse telecine some clips. we did telecine for a 24fps film to 30 non-drop NTSC in Singapore. They don't indicate the alphabets for the frames and instead they use numbers. we am trying to figure out t

  • HT201322 To hide or restore purchases on an iOS device is not working

    The hide or restore purchases feature, is not working on iOS devices since the iOS update 6.0

  • Golden Gate: Replicate replicated data

    Hi, We have 3 Oracle 11GR2 database servers, A, B and C. At the moment we have GoldenGate replicating from A to B. We want to set up another GoldenGate process to replicate from B to C. Database server A cannot reach C, so the replication must come f