Polymorphism , Dynamic Binding, Widening and I'm totally confused

class Fruit
     private String name;
     public String getName()
          return this.name;
class Apple extends Fruit
     private String typeOfApple;
     public void setTypeOfApple(String type)
          this.typeOfApple=type;
     public String getTypeOfApple()
          return this.typeOfApple;
class Banana extends Fruit
     private String typeOfBanana;
     public void setTypeOfBanana(String type)
          this.typeOfBanana=type;
     public String getTypeOfBanana()
          return this.typeOfBanana;
public class ExceptionTesting
     public static void main(String args[])
          Fruit obj=new Apple();
          obj.setTypeOfApple();  // ??? Why can't I do this ???
}how can I achieve something like underneath by modifying above code ???
Fruit whateverFruit=new Apple();
whateverFruit.setTypeOfApple();
whateverFruit=new Banana();
whateverFruit.setTypeOfBanana();
whateverFruit=new Orange();
whateverFruit.setTypeOfOrange();
...

Harry_lynn_17 wrote:
I do apologize if it's become sound like stupid or something . I know somehow it's not very suitable to think in that way but I was just thinking of the object reference variable as a pointer becauseA reference is like a "filtered" pointer to an object: it will only show that part of the object that corresponds with the type of the reference. So after "Fruit whatever = new Banana();", the "whatever" reference only shows the "Fruit" part of the "Banana" object. This means you can only call methods that are defined in Fruit, not those defined in Banana.
Dynamic binding means the JVM will decide at runtime which method implementation to invoke based on the class of the object. So, I thought
Fruit whateverFruit=new Banana(); and then if i tried to invoke whateverFruit.yellowBanana(); then the compiler will try to find the method out and executed automatically.That's not what it means. It means when you have "Fruit whatever = new Banana()" and you call "whatever.getName()", it will call the getName() method from Banana, if Banana overrides the implementation of Fruit. You can still only use methods that are defined in Fruit through a reference of type Fruit. In this case, it doesn't seem that the behaviour of setTypeOfApple() is different from setTypeOfBanana(), so ejp's recommendation to just create a setType() method in Fruit is correct.
Polymorphism means a variable of a superclass type to hold a reference to an object whose class is the superclass or any of its subclasses. So, I thought Fruit whateverFruit is somehow capable to hold the reference of its subclasses and can be used to reference of its subclasses. That's basically correct. However, the variable will only expose the superclass part of the subclass object.
I got confused with all those stuff and kinda lost. There's one more thing. What's the point of doing something like this Fruit apple=new Apple() if I can't reference to an instance of apple object ?? I mean I could just simply write like this Fruit aFruit=new Fruit(). Sorry, if i've become sound like a fool but i'm really confused. Please help me out of this and thanks in advance.The point of having any superclass/subclass combo is that your problem domain demands that you make the distinction: sometimes you need to be able to treat an object as Fruit, sometimes you need to be specific and treat it like an Apple. For example, if you sell fruit and need to calculate the total price of a fruit basket, all you need to know is that each piece of Fruit has a getPrice(), you don't need to know that one piece is an Apple and another piece is a Banana. However, if a customer demands a kilogram of apples, you need to make sure you give him only Apples and not Banana's.List<Fruit> fruitBasket = new ArrayList<Fruit>();
fruitBasket.add(new Apple("Granny Smith"));
fruitBasket.add(new Banana("Chiquita"));
fruitBasket.add(new Apple("Golden Delicious"));
int priceOfBasket = 0;
for(Fruit pieceOfFruit:fruitBasket) {
  priceOfBasket += pieceOfFruit.getPrice();
Set<Apple> appleScale = new HashSet<Apple>();
appleScale.add(new Apple("Granny Smith"));
appleScale.add(new Apple("Golden Delicious"));
appleScale.add(new Banana("Chiquita")); // ERROR

Similar Messages

  • Dynamically binding CachedRowSet and page navigation exception

    I create one page and drop a table, then create one xxxDataProvider and two rowsets from one database table, rowSet1 is set to have a criteria with the key (xxx) and default to bind with the table, rowSet2 doesn't.
    In the prerender(), get the session variable for the criteria (xxx), if the value of xxx == null, xxxDataProvider bind to rowSet2. else xxxDataProvider.setObject(1, value of xxx).
    execute the page, both work well.
    now add a link, if set the link's URL property to another page, both situations work fine, but if I create an action handle method for the link and from there navigate to another gage, if the value of xxx exists, it goes well, or it throws exception like this:
    Exception Handler
    Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
    Exception Details: org.apache.derby.client.am.SqlException
      At least one parameter to the current statement is uninitialized.
    Possible Source of Error:
       Class Name: org.apache.derby.client.am.PreparedStatement
       File Name: null
       Method Name: checkThatAllParametersAreSet
       Line Number: -1
    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    org.apache.derby.client.am.PreparedStatement.checkThatAllParametersAreSet( Unknown Source )
    org.apache.derby.client.am.PreparedStatement.flowExecute( Unknown Source )
    org.apache.derby.client.am.PreparedStatement.executeQueryX( Unknown Source )
    org.apache.derby.client.am.PreparedStatement.executeQuery( Unknown Source )
    com.sun.sql.rowset.internal.CachedRowSetXReader.readData(CachedRowSetXReader.java:193)
    com.sun.sql.rowset.CachedRowSetXImpl.execute(CachedRowSetXImpl.java:950)
    com.sun.sql.rowset.CachedRowSetXImpl.execute(CachedRowSetXImpl.java:1410)
    com.sun.data.provider.impl.CachedRowSetDataProvider.checkExecute(CachedRowSetDataProvider.java:1219)
    com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorRow(CachedRowSetDataProvider.java:329)
    com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorIndex(CachedRowSetDataProvider.java:300)
    com.sun.data.provider.impl.CachedRowSetDataProvider.getRowCount(CachedRowSetDataProvider.java:624)
    com.sun.rave.web.ui.component.TableRowGroup.getRowKeys(TableRowGroup.java:806)
    com.sun.rave.web.ui.component.TableRowGroup.getFilteredRowKeys(TableRowGroup.java:429)
    com.sun.rave.web.ui.component.TableRowGroup.getSortedRowKeys(TableRowGroup.java:1385)
    com.sun.rave.web.ui.component.TableRowGroup.getRenderedRowKeys(TableRowGroup.java:876)
    com.sun.rave.web.ui.component.TableRowGroup.iterate(TableRowGroup.java:1956)
    com.sun.rave.web.ui.component.TableRowGroup.processDecodes(TableRowGroup.java:1679)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    com.sun.rave.web.ui.component.Form.processDecodes(Form.java:78)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:306)
    com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
    com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    Exception Details: java.lang.RuntimeException
      org.apache.derby.client.am.SqlException: At least one parameter to the current statement is uninitialized.
    Possible Source of Error:
       Class Name: com.sun.data.provider.impl.CachedRowSetDataProvider
       File Name: CachedRowSetDataProvider.java
       Method Name: setCursorRow
       Line Number: 343
    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorRow(CachedRowSetDataProvider.java:343)
    com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorIndex(CachedRowSetDataProvider.java:300)
    com.sun.data.provider.impl.CachedRowSetDataProvider.getRowCount(CachedRowSetDataProvider.java:624)
    com.sun.rave.web.ui.component.TableRowGroup.getRowKeys(TableRowGroup.java:806)
    com.sun.rave.web.ui.component.TableRowGroup.getFilteredRowKeys(TableRowGroup.java:429)
    com.sun.rave.web.ui.component.TableRowGroup.getSortedRowKeys(TableRowGroup.java:1385)
    com.sun.rave.web.ui.component.TableRowGroup.getRenderedRowKeys(TableRowGroup.java:876)
    com.sun.rave.web.ui.component.TableRowGroup.iterate(TableRowGroup.java:1956)
    com.sun.rave.web.ui.component.TableRowGroup.processDecodes(TableRowGroup.java:1679)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    com.sun.rave.web.ui.component.Form.processDecodes(Form.java:78)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
    javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:306)
    com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
    com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)Is my way the right one?
    Thank you very much!

    Replacing the link with a button, the problem remains.
    I guess it has something to do deep inside the life cycle.

  • I don't understand the way I set up my iCloud account and I'm totally confused with it. In an attempt to fix this and just start over completely I deleted my screen name but "bonjour" keeps logging me in. Is it safe to delete it? What options do I have?

    Please help!

    Hi,
    In Messages or iChat go to the App Menu > Preferences > Accounts
    On the left is the list of  Accounts that are set up.
    Everyone gets Bonjour (Although by default it is not Active).
    Highlight the Bonjour Account
    On the right there is a Box that says "Enable this Account" which probably has a tick in it.
    Select it to remove the tick.
    This will turn Off the Bonjour Account.
    The List may also contain any @me.com name you have set up.
    This can be used in Messages as the ID for iMessages
    It is also a Valid AIM screen Name.
    It would helps if we knew which version of iChat and the OS you are using as there are some changes that occur
    An iCloud @me.com name will not work in iChat 5 or earlier due to the checks Apple has in iChat 6 (and Messages) which iChat 5 does not do.
    To also work as a Valid Screen Name the password for your @Me.com name has to be 16 characters or less (AIM server limit)
    9:49 PM      Wednesday; October 17, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Trying to create "screencast", and am totally confused...

    Hi.
    So, I used snapZpro and captured a section of my screen, and saved it out as a quicktime with animation codec, 10 frames per second.....
    I then created a project in FCP, and brought in my files... Created a sequence, and put my mov in there.. It immediately set the sequence to DV/DVCPRO - NTSC, the canvas window shows my footage but it looks wrong-- like the fonts are unreadable, blurry, etc.
    So, I went into sequence settings and set it to Animation, and then I have a RED timeline showing that I need to render everything.. and I am totally confused as to why since the footage is the animation codec... The frame rate in the sequence is 29.97, I thought that was perhaps why it's red, but there is no option in the "edit timebase" for 10fps.. Its only options between 23 and 60...
    My goal is to make some basic edits, and then output again with the animation codec.
    Can anyone please let me know how I should proceed? Rendering my footage seems like the wrong thing to do-- especially since it says it will take 2 hours to do it!!!
    Thanks.
    Message was edited by: Patrick Collins

    there is no option in the "edit timebase" for 10fps.. Its only options between 23 and 60...
    Final Cut Pro works with industry standard codecs, pixel dimensions and frame rates. As soon as you try making custom settings, it's no longer standard and you have to render. Snapz Pro was never designed to work in conjunction with a professional video editing system. You should try [iShowU|http://www.shinywhitebox.com/ishowuhd/main.html] instead, which will let you export to any codec on your computer.

  • Totally Confused by Licensing!!

    Hi all
    I am trying to evaluate EM 10G for our organisation and I am totally confused by the Licensing!! I have spoken to our Oracle Account Manager and that has not helped.
    As I understand it you get the license for EM with Database Licenses.
    So assume that we are able to install and use EM to monitor and manage all of our instances (250+).
    The parts I could purchase are
    • Diagnostics Pack
    • Configuration Management Pack
    • Tuning Pack
    • Change Management Pack
    Having a quick look it seem like a lot of the EM functionality (alerts etc) only come with the Diagnostics Pack.
    I suppose the question I am asking is how much functionality will we get without purchasing any of the management packs?
    Regards
    Ben

    Ben,
    When you install EM10g Grid Control you can navigate to the setup page for Management Pack Access.
    This is where you tell EM10g which packs you are licensed for.
    It also explains the packs in the form pasted below.
    As far as I am aware the Change Management Pack is no longer around in 10g?
    I'd hate to have to look after 250 databases without the Diagnostics pack at least...
    Thanks,
    Alan...
    Database Diagnostics Pack
    Performance Monitoring (Database and Host)
    ADDM (Automated Database Diagnostic Monitor)
    Automatic Workload Repository
    Event Notifications: Notification Methods, Rules and Schedules
    Event history/metric history (Database and Host)
    Blackouts
    Database Tuning Pack
    SQL Access Advisor
    SQL Tuning Advisor
    SQL Tuning Sets
    Reorganize Objects
    Database Configuration Pack
    Database and Host Configuration
    Deployments
    Patch Database and View Patch Cache
    Patch staging
    Clone Database
    Clone Oracle Home
    Search configuration
    Compare configuration
    Policies
    Application Server Diagnostics Pack
    Historical/trending data (Application Server and Host)
    Server Tracing
    Page Performance
    Event Notifications: Notification Methods, Rules and Schedules
    Event history/metric history (Application Server and Host)
    Blackouts
    Application Server Configuration Pack
    Application Server and Host Configuration
    Deployments
    Patch Database and View Patch Cache
    Patch staging
    Clone Database
    Clone Oracle Home
    Search configuration
    Compare configuration
    Policies

  • Dynamic Binding and Interactions

    Hi,
    When we invoke a BPEL say "MyBPEL2" from another BPEL say "MYBPEL1" we can see the instance id of "MyBPEL2" in "Interactions" tab of "MyBPEL1" from the BPEL console GUI, seems there is some kind of parent-child relationship maintained in dehydration database. But i dont see the same relation if MyBPEL2 is dynamically binded and invoked?
    any ideas please?
    thanks,
    -Ng.

    Are you saying the classes have package access, or their methods (e.g. toString)?
    If the latter (methods) it won't compile.
    If the former (classes) then polymorphism works as usual--whatever you have an instance of at runtime, that's whose method is called.
    You can't refer to one of those package-protected classes by name, but if you get your hands on one (say from a public factory) with a reference of some public superclass or interface, then you can call any public methods specified by that public superclass/interface, and the appropriate method wil get called on the concrete object.
    If you look at the source code for the Collections classes, you'll find that the Iterator implementations are either package scoped or private, I think.

  • Dynamic binding problem

    I have a problem, i want to use a extend to arraylist to implement different validation to objects. So i added a method add(Person person), dynamic binding, but it has a incorrect behavior, i think
    import java.util.ArrayList;
    import java.util.Collection;
    public class Test {
         class MyList extends ArrayList {
              public boolean add(Object arg0) {
                   System.out.println("add norm");
                   return super.add(arg0);
              public boolean add(Person arg0) {
                   System.out.println("add person");
                   return super.add(arg0);
         class Person{
         public static void main(String[] args) {
              new Test().test();
         private void test() {
              Collection col1 = new MyList();
              col1.add(new Person());
              ArrayList col2 = new MyList();
              col2.add(new Person());
              MyList col3 = new MyList();
              col3.add(new Person());
    }My output=
    add norm
    add norm
    add person
    My wanted output
    add person
    add person
    add person
    Why?

    in case you don't understand why you're getting "addning norm"
    you are using polymorphism. You declared your objects to be of type Collection and ArrayList. This means you can only use methods of those type, eventhough the underlying object is a MyList instance. Now, Collections and ArrayList class only have the add(Object obj) method signature....so, when you say add(new Person()), it will only see add(Object obj)
    When you declared your object as MyList, then it see add(Person p), so it use the add(Person p) method.

  • What is Dynamic Binding ??

    Can anyone help me in telling what is DYNAMIC BINDING with an exmple!!!!
    Thanks
    Pinto

    dynamic binding means binding at run time.it is used in java for achieving runtime polymorphism.
    e.g
    class A
    int i=15;
    void abc()
    System.out.println("in A");
    class B extends A
    int i=20;
    void abc()
    System.out.println("in B");
    class C
    public static void main(String o[])
    A a=new B();
    System.out.println(a.i);
    System.out.println(a.abc);
    this program outputs as
    15
    in B
    this is because the instance methods are bind dynamically at runtime depending upon the object
    not the reference.instance variables and static methods are bind early at compile time so these depends upon the reference not the object.

  • How to create dynamic View Object and Dynamic Table

    Dear ll
    I want to create a dynamic view object and display the output in a dynamic table on the page.
    I am using Jdeveloper 12c "Studio Edition Version 12.1.2.0.0"
    This what I did:
    1- I created a read only view object with this query "Select sysdate from dual"
    2- I added this View object to the application module
    3- I created a new method that change the query of this View object at runtime
        public void changeVoQuery(String dbViewName) {
            String sqlstm = "Select * From " + dbViewName;
            ViewObject dynamicVo = this.findViewObject("DynamicVo");
            if (dynamicVo != null) {
                dynamicVo.remove();
            dynamicVo = this.createViewObjectFromQueryStmt("DynamicVo", sqlstm);
            dynamicVo.executeQuery();
    4- I run the application module for testing the method and I passed "Scott.Emp" as a parameter and the result was Success
    5- Now I want to show the result of the view on the page, so I draged and dropped the method from the data control as a parameter form
    6- I dragged and dropped the view Object "DynamicVo" as a table and I choose "generate Column Dynamically at runtime". This is the page source
    <af:panelHeader text="#{viewcontrollerBundle.SELECT_DOCUMTN_TYPE}" id="ph1">
            <af:panelFormLayout id="pfl1">
                <af:inputText value="#{bindings.dbViewName.inputValue}" label="#{bindings.dbViewName.hints.label}"
                              required="#{bindings.dbViewName.hints.mandatory}"
                              columns="#{bindings.dbViewName.hints.displayWidth}"
                              maximumLength="#{bindings.dbViewName.hints.precision}"
                              shortDesc="#{bindings.dbViewName.hints.tooltip}" id="it1">
                    <f:validator binding="#{bindings.dbViewName.validator}"/>
                </af:inputText>
                <af:button actionListener="#{bindings.changeVoQuery.execute}" text="changeVoQuery"
                           disabled="#{!bindings.changeVoQuery.enabled}" id="b1"/>
            </af:panelFormLayout>
        </af:panelHeader>
        <af:table value="#{bindings.DynamicVo.collectionModel}" var="row" rows="#{bindings.DynamicVo.rangeSize}"
                  emptyText="#{bindings.DynamicVo.viewable ? 'No data to display.' : 'Access Denied.'}"
                  rowBandingInterval="0" selectedRowKeys="#{bindings.DynamicVo.collectionModel.selectedRow}"
                  selectionListener="#{bindings.DynamicVo.collectionModel.makeCurrent}" rowSelection="single"
                  fetchSize="#{bindings.DynamicVo.rangeSize}" filterModel="#{bindings.DynamicVoQuery.queryDescriptor}"
                  queryListener="#{bindings.DynamicVoQuery.processQuery}" filterVisible="true" varStatus="vs" id="t1"
                  partialTriggers="::b1">
            <af:iterator id="i1" value="#{bindings.DynamicVo.attributesModel.attributes}" var="column">
                <af:column headerText="#{column.label}" sortProperty="#{column.name}" sortable="true" filterable="true"
                           id="c1">
                    <af:dynamicComponent id="d1" attributeModel="#{column}"
                                         value="#{row.bindings[column.name].inputValue}"/>
                </af:column>
            </af:iterator>
        </af:table>
    when I run the page this error is occured
    <Nov 13, 2013 2:51:58 PM AST> <Error> <oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter> <BEA-000000> <ADF_FACES-60096:Server Exception during PPR, #1
    javax.el.ELException: java.lang.NullPointerException
    Caused By: java.lang.NullPointerException
    Can any body help me please
    thanks

    Have you seen Shay's video https://blogs.oracle.com/shay/entry/adf_faces_dynamic_tags_-_for_a
    All you have to do is to use the dynamic table to get your result.
    Timo

  • Dynamic binding of items in sap.m.Table using XML views

    Dear SAPUI5 guru's,
    Let's start by saying I'm an ABAP developer who's exploring SAPUI5, so I'm still a rookie at the time of writing. I challenged myself by developing a simple UI5 app that shows information about my colleagues like name, a pic, address data and their skills. The app uses the sap.m library and most of the views are XML based which I prefer.
    The data is stored on an ABAP system and exposed via a gateway service. This service has 2 entities: Employee and Skill. Each employee can have 0..n skills and association/navigation between these 2 entities is set up correctly in the service. The data of this service is fetched from within the app using a sap.ui.model.odata.ODataModel model.
    The app uses the splitApp control which shows the list of employees on the left side (master view). If a user taps an employee, the corresponding details of the employee entity are shown on the right (detail view).
    Up till here everything is fine but I've been struggling with my latest requirement which is: show the skills of the selected employee in a separate XML view when the user performs an action (for the time being, I just created a button on the detail view to perform the action). After some hours I actually got it working but I doubt if my solution is the right way to go. And that's why I'm asking for your opinion here.
    Let's explain how I got things working. First of all I created a new XML view called 'Skills'. The content on this view is currently just a Table with 2 columns:
    <core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
      controllerName="com.pyramid.Skills" xmlns:html="http://www.w3.org/1999/xhtml">
      <Page title="Skills"
           showNavButton="true"
           navButtonPress="handleNavButtonPress">
      <content>
      <Table
       id="skillsTable">
      <columns>
      <Column>
      <Label text="Name"/>
      </Column>
      <Column>
      <Label text="Rating"/>
      </Column>
      </columns>
      </Table>
      </content>
      </Page>
    </core:View>
    The button on the Detail view calls function showSkills:
    showSkills: function(evt) {
      var context = evt.getSource().getBindingContext();
      this.nav.to("Skills", context);
      var skillsController = this.nav.getView().app.getPage("Skills").getController();
      skillsController.updateTableBinding();
    Within 'this.nav.to("Skills", context);' I add the Skills view to the splitApp and set its bindingContext to the current binding context (e.g. "EmployeeSet('000001')"). Then I call function updateTableBinding in the controller of the Skills view which dynamically binds the items in the table based on the selected employee. So, when the ID of the selected employee is '000001', the path of the table's item binding should be "/EmployeeSet('000001')/Skills"
    updateTableBinding: function(){
      var oTemplate = new sap.m.ColumnListItem(
      {cells: [
              new sap.m.Text({text : "{Name}"}),
              new sap.m.Text({text : "{Rating}"})
      var oView = this.getView();
      var oTable = oView.byId("skillsTable");
      var oContext = oView.getBindingContext();
      var path = oContext.sPath + "/Skills";
      oTable.bindItems(path, oTemplate);
    Allthough it works fine, this is where I have my first doubt. Is this the correct way to bind the items? I tried to change the context that is passed to this.nav.to and wanted it to 'drill-down' one level, from Employee to Skills, but I couldn't manage to do that.
    I also tried to bind using the items aggregation of the table within the XML declaration (<Table id="skillsTable" items="{/EmployeeSet('000001')/Skills}">). This works fine if I hard-code the employee ID but off course this ID needs to be dynamic.
    Any better suggestions?
    The second doubt is about the template parameter passed to the bindItems method. This template is declared in the controller via javascript. But I'm using XML views! So why should I declare any content in javascript?? I tried to declare the template in the XML view itself by adding an items tag with a ColumnListItem that has an ID:
                    <items>
                        <ColumnListItem
                        id="defaultItem">
                        <cells>
                            <Text text="{Name}"/>
                            </cells>
                            <cells>
                            <Text text="{Rating}"/>
                            </cells>
                        </ColumnListItem>
                    </items>
    Then, in the updateTableBinding function, I fetched this control (by ID), and passed it as the template parameter to the bindItems method. In this case the table shows a few lines but they don't contain any data and their height is only like 1 mm! Does anyone know where this strange behaviour comes from or what I'm doing wrong?
    I hope I explained my doubts clearly enough. If not, let me know which additional info is required.
    Looking forward to your opinions/suggestions,
    Rudy Clement.

    Hi everybody,
    I found this post by searching for a dynamic binding for well acutally not the same situation but it's similar to it. I'm trying to do the following. I'm having a list where you can create an order. On the bottom of the page you'll find a button with which you're able to create another order. All the fields are set to the same data binding ... so the problem is if you've filled in the values for the first order and you'll press the button you'll get the same values in the second order. Is it possible to generate a dynamic binding?
    I'm going to post you a short code of what I'm meaning:
    <Input type="Text" value="{path: 'MyModel>/Order/0/Field1'}" id="field1">
         <layoutData>
                    <l:GridData span="L11 M7 S3"></l:GridData>
               </layoutData>
    </Input>
    As you can see I need to set the point of "0" to a dynamic number. Is there any possibility to reach this???
    Hope you can help
    Greetings
    Stef

  • Dynamic binding doubt

    i have a a class (say class1) whi uses another class (say class 2) in class i have a public field which class 2 is accessing now i have changed class 2 such that that field is no more public & compiled , now class 1 is actually accessing a private field but it does not show any error , also i found out from some where that java -verify option will inform you that you have to compile class cos class 2 is already changed .so question is why it does not throw any run time exception why -verify option is not doccumented

    This doesn't have anything to do with dynamic binding.
    This allows you to compile one class without
    recompiling every dependent class. At runtime, when
    the other classes try to access those variables you
    should get an error.And if you're not getting the error (like your post seems to indicate), then you're probably not really using that version (with the now-private field) of the compiled class at run-time, but rather the old one because you goofed your classpath.

  • Dynamic binding for table column

    Hi,
    I am using standard application and in a table (not ALV) i want to chnage the name of a column. Already a OTR is placed in it so am planning to do a dynamic bind for the text in the header. Kindly suggest ways.
    Thanks,
    Koushik

    DATA:
            l_caption          TYPE string,
            l_title            TYPE string.
      data lr_caption type ref to cl_wd_caption.
    *---Get OTR Text for Value Description
      CALL METHOD cl_wd_utilities=>get_otr_text_by_alias
        EXPORTING
          alias      = 'ZPERF_MGMT_DEV/RATING'
      language   =
        RECEIVING
          alias_text = l_title.
    lr_caption ?= view->get_element( 'TBL_VAL_HELP_DESCRIPTION_HEADER' ).
    lr_caption->set_text( value = l_title ).

  • Bind by position? I got totally confused

    is it default that the parameters in the .net codes are binded to that in the pl/sql codes by position? i get totally confused.
    very simple codes in the pl/sql are like this:
    ===========================
    FUNCTION create_saint(saint_name IN VARCHAR2,saint_ct IN VARCHAR2)
    RETURN VARCHAR2
    ===========================
    and "oracom" is a OracleCommand calling the function, when i add the parameters like this:
    ===================================
    oracom.Parameters.Add("saint_name",OracleDbType.Varchar2,"aaa");
    oracom.Parameters.Add("saint_ct",OracleDbType.Varchar2,"bbb");
    ===================================
    i woule like the parameter "saint_name" is "aaa" and "saint_ct" is "bbb" if they are binded by position. but error occurs and when i traced the execution of the pl/sql code, i found that the parameter "saint_name" was "bbb" and "saint_ct" was null.
    shouldn't they be binded by position? and when i used the
    "oracom.BindByName = true;"
    the two parameters were just binded correctly.
    so i just wonder when and how the parameters are binded by position.

    Hello,
    Yes, parameters are bound by position by default when using ODP.NET - this is controlled by the BindByName property which defaults to false. If you want to use bind by name, just set this property to true as you've shown.
    Since you are using a FUNCTION I would guess that you did not bind the function return value first, which is required. ODP.NET will generate code similar to this:
    begin
      :1 := function_name(:2, :3, :4);
    end;Hope that helps,
    Mark

  • Dynamically Binding to Dynamically Create View

    I tried to copy the code of “Dynamically Binding to Dynamically Create View object” but something is wrong because when I am debbuging it doesn’t work after the sentence vo.executeQuery();
    I suspect that the reason could be how I created the view..
    Your code is running well but not mine.
    It shows this error
    •     JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
    •     null
    I don’t know why because the code is the same.
    How did you create the objet view ?
    Could you help me?

    I'd recommend checking out this article on Debugging ADF Applications:
    http://www.oracle.com/technology/products/jdev/tips/muench/debugger/index.html
    and then reporting here the full stack trace using the tips described in that article.

  • Dynamic binding of partner links with different payloads

    In dynamic binding of partner links, can we have different payloads for different
    webservices ?

    Hi Marc,
    I have one question regarding the use of <xsd:anyType>, Before that let me clear our requirement. We are trying to create a BPEL flow (Consumer) which has the ability to call other webservices (Producers) dynamically. There can be a number of Producer Webservices performing the same task. The end user should be able to add new Producer Webservices and remove already existing ones. We achieved this using EndPointReference (http://www.oracle.com/technology/pub/articles/bpel_cookbook/carey.html) but the problem with this approach is that all the producer webservices have to work on a common schema. We want to support webservices working on different payloads.
    My understanding is that when we map the XML document to xsd:anyType in the service's WSDL file, the producer web service need to have an implementation of this type in for of a java class. Is this correct ? Or can we provide the java implementation in our code itself? Can you please point me to some detail documentation on xsd:anyType?
    Thanks

Maybe you are looking for

  • Question about Primary Key

    HI I'm going to build a Database to automate center in my university The Database version is Oracle 10g v2 Which data type of primary key should I user? I used number in past but I heard there is more efficient data type for this purpose Thanks

  • Passing Arrays to function

    In my main function, I have created a class array of Players[3]. In the function I pass this array of Players to another class function that may or may not change the size of this array (which I may be doing incorrectly). This is console game of Blac

  • Losing form elements and referer when opening in a javascript window

    I am submitting from a.cfm to b.cfm. b.cfm opens in a Javascript window. In b.cfm, the form elements from a.cfm are lost and cgi.referer returns nothing. When I don't open b.cfm in a Javascript window, everything is ok. What is this happening?

  • Upgrade 10.4.11

    I have a OS X 10.4.11 and have just purchased a new IPhone 4 which I have just discovered is not compatable. How do I upgrade to 10.5 or 10.6 ?? Do I have to buy a new laptop?

  • Cant access "camera roll" album after upgrade to 4.3.3

    iPhone 3GS, recent update to v 4.3.3 now when I go in to Photos the "Camera Roll" album is hidden under the "Albums" heading at the top of the screen and I can't tap it to open it.  Can see and access 3 other albums.  Was fine before this upgrade. An