This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Bean properties vs other Bean methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Bean properties vs other Bean methods" Watch "Bean properties vs other Bean methods" New topic

Bean properties vs other Bean methods

leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Normally, when you bind a value to a component, you create a property in the bean and provide get/set methods for that property.


What is it called when you create a random method with a "get" naming convention and use that as the value binding to a component? Is there a word for that?


Thanks, leo
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950

Yes. It's called a "property 'get' method."

Properties aren't the internal objects, they're what external accessors see. And if an external accessor sees a "get" method, as far as it's concerned, that's a property fetch.

You can provide synthetic properties via internal computations, string operations, database fetches, or whatever and there will be no way for the external accessor code to know that the property value isn't actually a physical field within the target object.

Of course, in JSF, there are a few limitations on this. Property methods have to return the same value every time they're read within the request phases of the JSF lifecycle (I believe the term is "idempotent"). They shouldn't have "side effects", and for performance reasons, they shouldn't take long to execute.

Anything beyond that is fair game.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Bean properties vs other Bean methods
Similar Threads
Using Hibernate to insert into Oracle Blob, then read back out
Why am I getting NoSuchBeanDefinition Exception? I am new to Spring!
Passing Params
code compiles with no errors but doesn't not create a class with pdf fields
Printing two substrings