Skip to main content

Pass through attributes and getAttributes( )

2 replies [Last post]
cnoevil
Offline
Joined: 2006-04-11
Points: 0

Hi Guys,

I've been studying JavaServer Faces 2.0 with the ultimate objective of not just being able to use the existing internal components and third party component libraties but to be able to author my own non-composite components as needed. I'm sure that I make things harder on myself than need be and that I assume more complexity than there really is. I'm struggling with getting my mind around component attributes and state saving/restoring mechanisms. The only way I know to approach it is pulling through the code of third party component libraries, Mojarra and using the "JavaServer Faces 2.0: The Complete Reference" book.

In my attempts at getting a good understanding of component attributes I dug around in the implementaion details and found a couple of methods dealing with pass through attributes. Specifically, in the com.sun.faces.renderkit.RenderkitUtils class there is renderPassThruAttributesOptimized and the other is called renderPassThruAttributesUnoptimized. What are pass through attributes?

Also, what attributes are available through a call to getAttributes and how do they end up in the attributes map? Do they have to be explicitly added to the map or does the JavaServer Faces runtime allow access to any and all attributes that may be accessible on a DOM element?

Thanks,
Mark

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cnoevil
Offline
Joined: 2006-04-11
Points: 0

Thanks Roger, That really helps alot. So can I assume that other than these attributes that the getAttributes method and the StateHelper class will not contain any other attributes unless explicitly placed there on a component by the component? The JavaServer Faces runtime is not iterating through the DOM and digging out attributes on whatever css model is being used or such business as that. Other than these attributes, the JSF runtime will not know or care about them unless otherwise explicitly loaded and accessed by whatever code a component may execute?

I'm so glad to get an answer on this. I never thought to look there. This has had me scratching my head for a week.

Thanks,
Mark

rogerk
Offline
Joined: 2004-05-06
Points: 0

The "pass through" attributes are HTML attributes that do not change on page translation and so they end up on the resultant JSF page as is.

The Html attributes are actually loaded from metadata

The Mojarra JSF implementation generates an AttributeManager.java class
(jsf-ri/build/generate/com/sun/faces/renderkit/AttributeManager.java).

This class contains all the valid HTML attributes for each component.