aspose file tools*
The moose likes Struts and the fly likes JSF : Differenc e between attribute and property of a component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF : Differenc e between attribute and property of a component" Watch "JSF : Differenc e between attribute and property of a component" New topic
Author

JSF : Differenc e between attribute and property of a component

Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Hi

I would really appreciate if any one can let me know what is a property of a component and attribute of a component in jsf world.

In faces-config.xml file we can define information about a component

<!ELEMENT component (description*, display-name*, icon*,
component-type, component-class, attribute*, property*,
component-extension*)>

So what is a attribute of a component and what is property of a component
attribute*,
property*,

<!ELEMENT attribute (description*, display-name*, icon*,
attribute-name, attribute-class, default-value?, suggestedvalue?,
attribute-extension*)>


<!ELEMENT property (description*, display-name*, icon*,
property-name, property-class, default-value?, suggested-value?,
property-extension*)>

Both look very similar

Any inputs or pointers is highly appreciated.

Regards,
Vijay V
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by Vijay Venkat:
Hi

I would really appreciate if any one can let me know what is a property of a component and attribute of a component in jsf world.
[...]


The core components in JSF are "rendering independant", meaning that they define behavior that is the same no matter how they are rendered. For example, a UICommand component can be rendered as a link or a button, but the behavior is the same. Another examples is a UIInput, which may be rendered as one input field for text input, or as three fields for year, month and day input, or as four fields for credit card number input; the core component behavior is the same no matter how it's rendered.

The rendering and decoding of input for a component is delegated to a separate Renderer attached to the component. So, for instance, if you want a UICommand rendered as a link, you attach a Link renderer; if you want a button, you attach a Button renderer.

With that background, it's easy to describe the distinction between a component "property" and an "attribute".

All rendering independent configuration items for a component are specified as a set of regular bean properties, i.e., by type-safe get and set methods. For the UICommand component, "action" is one example, used to bind the component to a method invoked when the command is triggered.

All rendering dependent configuration items are specified as generic attributes, represented by entries in an attributes Map that the Renderer attached to the component reads. UICommand/Button examples are "alt", "disabled", "style", and all the other HTML attributes that are supported by an HTML <input type="submit"> element. Using generic attributes for rendering dependent stuff makes it easy to develop new Renderers that need new configuration items, because the component class doesn't have to be modified with new bean get/set methods.
[ June 12, 2004: Message edited by: Hans Bergsten ]

Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Hans thanks for the clear explanation
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF : Differenc e between attribute and property of a component