Hi what can you say about Java Beans...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeffbroodwar
    New Member
    • Oct 2006
    • 118

    #1

    Hi what can you say about Java Beans...

    Hi Guys,

    I just want to hear your understanding of Java Beans. I mean it doesn't just expose properties (for parameters) right? Java beans must be able to do what variables can't. i need feedbacks please. Thanks

    Regards,
    Jeff
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by jeffbroodwar
    Hi Guys,

    I just want to hear your understanding of Java Beans. I mean it doesn't just expose properties (for parameters) right? Java beans must be able to do what variables can't. i need feedbacks please. Thanks

    Regards,
    Jeff
    There's not much to say about beans; any POJO (Plain Old Java Object) can
    be a bean; according to Sun:

    Originally posted by Sun
    Definition:

    A Java Bean is a reusable software component that can be visually manipulated in builder tools.

    To understand the precise meaning of this definition of a Bean, clarification is required for the following terms:

    Software component
    Builder tool
    Visual manipulation
    Note that it isn't required to be visually manipulatable, nor does one need a
    builder tool. There's one badly understood aspect about beans: for a property
    'T x' in order to be manipulatable there need to be methods available named:

    [code=java]
    private T x;
    public T getX() { return x; }
    public void setX(T x) { this.x= x; }
    [/code]

    People think that those get and set methods must operate on private member
    variables which isn't true; a property is just a property, i.e. it doesn't have to be
    a member variable. The above example is bad practice: simply making 'x' a
    public member variable has the same effect.

    kind regards,

    Jos

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Originally posted by jeffbroodwar
      Hi Guys,

      I just want to hear your understanding of Java Beans. I mean it doesn't just expose properties (for parameters) right? Java beans must be able to do what variables can't. i need feedbacks please. Thanks

      Regards,
      Jeff

      Hi
      I uses and Understands java Beans as follows.

      1. Whenever I need the a java class in the JSP page. I can store that class in the WEB-INF folder and I can call this class by a bean name

      Syntex: <jsp:useBean id="LearnJava" class="class name " scope = "page" />


      2. I finds that some java method of the class is required in the JSP page I can call that method by the bean name followed by the method name.

      Example:
      BeanId.MethodNa me
      LearnJava.metho dName


      3. When ever I need the parameters to be passed to the methods of the class file We can use get and set properties.

      Comment

      • jeffbroodwar
        New Member
        • Oct 2006
        • 118

        #4
        Hi,

        Thanks for sharing your thoughts.... i was just thinking about variables vs. beans. Hmm... basically, beans can be used as a library. You can keep different beans having different properties for later use.(depending on the task to be handled). Can you guys give me a sample of how can i use java beans as an object that will be used to bind a jComboBox to the database? just get the values in one of the fields in the database will be fine. Cause i saw other IDEs in Java that supports database binding. (I'm using netbeans) Netbeans will have this feature in the last quarter of 2007 (in their release of Netbeans 6.0). Thanks.

        Best Regards,
        Jeff

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by jeffbroodwar
          Hi,

          Thanks for sharing your thoughts.... i was just thinking about variables vs. beans. Hmm... basically, beans can be used as a library. You can keep different beans having different properties for later use.(depending on the task to be handled). Can you guys give me a sample of how can i use java beans as an object that will be used to bind a jComboBox to the database? just get the values in one of the fields in the database will be fine. Cause i saw other IDEs in Java that supports database binding. (I'm using netbeans) Netbeans will have this feature in the last quarter of 2007 (in their release of Netbeans 6.0). Thanks.

          Best Regards,
          Jeff
          It's not the IDE that supports what you want: there are vendor specific beans that
          do that for you. Notably Borland likes those 'data aware' widgets/components,
          or whatchamacallit . I personally keep visual beans/components and data
          handling beans/components as far apart from each other as possible.

          Use beans for the Model, i.e. beans that can manipulate data, use beans for
          the View, i.e. beans that are as stupid as they come but are very good at
          displaying stuff and think of Controller beans: the beans that implement your
          business logic (read: what you actually want to do).

          kind regards,

          Jos

          Comment

          Working...