This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

composite component with inherited attributes

 
Nicola Camuffo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm new in this forum, I have to create a new custom tag "imageLabeable" as a div contains a GraphicImage and an OutputLabel (primefaces).

Since I want to make it reusable as much as possible, I tried to write, in cc:interface section, all GraphicImage attributes (id, value, binding etc) and some new (GraphicImage is the main component among the two). But after that I have must associate GraphicImage attributes with the attributes created in cc:interface:



As you can see, if I have a lot of attributes I have to write a lot of association. Furthermore, if I see html rendered code with Firebug or similar, I see all of these associations.

Can I inherit these attributes automatically? Or associate it in easier way?


Thanks you!

:)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're stuck with the hard way. The XML custom tag mechanism doesn't implement inheritance - there's no base component, but rather all sub-components are peers. So which one would get the "value=" attribute value from its wrapper?
 
Nicola Camuffo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I returned today from holidays...


so.. there isn't a way to do this association! But if I wanted to make a really new component doing a java class further some xhtml code?
If I write a class that encapsulates a GraphicImage and a OutputLabel, doing associations in java..

Would you write me how i can make a class like this? After that, i need to recreate all attributes (value, labelValue, labelStyle, etc).


Do you know if this is possible?

Thanks!

:)

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If at all possible, I recommend creating your custom components using just the xhtml.

You can create custom JSF components in Java code, but there are a number of reasons to avoid this:

1. It's a lot more complicated than setting up xhtml.

2. Good documentation on how to do so is harder to find.

3. Java code is dependent on JSF internals, which can - and have already - changed radically between JSF versions, raising the cost of maintenance.

4. Thanks to #3, #2 is even harder, since Internet searches have a maddening tendency to bring up old, outdated docs ahead of newer stuff. In fact, I think that's the prime reason why so many JSF newbies are coding action listeners and bindings when they should be doing neither.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic