Results 1 to 3 of 3
  1. #1
    jeanjiang is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default are there any other methods to get/set a Java Bean

    Java Bean is a criterion of Java object.

    For example:
    Java Code:
    public class MyBean {
    	
    	private String a;
    	private String b;
    	
    	public MyBean() {
    		
    	}
    	
    	public String getA() {
    		return a;
    	}
    	
    	public void setA(String a) {
    		this.a = a;
    	}
    	
    	public String getB() {
    		return b;
    	}
    	
    	public void setB(String b) {
    		this.b = b;
    	}
    	
    }
    We can say MyBean is a Java Bean.
    We can set/get value of MyBean as below:
    Java Code:
    MyBean myBean = new MyBean();
    
    myBean.setA("a");
    myBean.setB("b");
    
    myBean.getA();
    myBean.getB();
    This is a very right way to get/set value of Java Bean.

    My question is that is there any other methods to implement this function.
    Because I think Java Bean should have some standard methods to implement it, otherwise It means Java Bean is equal to simple Java oject.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    10

    Default

    You must override equals() hashCode and toString().
    JavaBean is used for model in MVC architecture and other frameworks.
    It has not implementation specification logic in site.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    10

    Default

    )) @jackycui Where did you find this info? I have read your article about Beans. It is strange idea.
    Can you explain where it can use?
    Skype: petrarsentev
    http://TrackStudio.com

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2011, 07:55 AM
  2. JSP functions and Java Bean methods
    By lisa.lipsky in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 07-07-2009, 07:29 AM
  3. stateless session bean with methods
    By mihael in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-15-2009, 08:55 PM
  4. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 01:34 PM
  5. Replies: 0
    Last Post: 09-26-2007, 08:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •