Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP-Bean question  RSS feed

 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
There are 3 conditions a bean must adhere to take full advantage of everything beans has to offer:
- Implement java.io.Serializable, or java.io.Externalizable
- provide a no-arguments constructor.
- private properties must have corresponding get/set methods using the appropriate naming pattern.
Now I came across a doubt with this must. I am trying to use a layered design for my some_a_little_complex_app_might_be_good_to_clear_concepts-application, where the bean asks a business logic object for values. There are three properties and 2 of the properties are set when setA is invoked (by asking the business object). setB and setC will never be called by the JSP the bean is created from.
If I implement setC(), setB() it clutters the code.
If I don't implement them there might be problems with I think failover or loadbalancing. Any other problems??? But I think the app will run without them (haven't tried yet).
Think I will implement them.
Is it very bad design praxis to not implement them, when I know that I won't use failover or load-balancing in my app???
What do u think?
Axel
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the properties are for internal use only, it makes it no less a bean for them not to have getters and setters. What the bean 'spec' is saying is that all properties that are exported by the bean should have a standard getter, and if it is a read/write porperty it should also have a standard getter. It does not say that you cannot implement internal-only instance variables.
hth,
bear
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Axel,
what does implementing java.io.serializable or externalizable do?
Adam
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

Adam:
1- Its part of the bean specifications.
2- In my own tired (gmt+1) words:
So the Beans can be saved on disk or transmitted over the network. It can be saved from one server to another as part of the snapshot for the current state (for loadbalancing, failover).
Axel
[ February 04, 2002: Message edited by: Axel Janssen ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!