• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

composite component with inherited attributes

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

:)
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic