• 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

Reference a composite component dynamically

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say I have defined some composite components: "my:componentA", "my:componentB" and "my:componentC".

Now I would like to use these components "dynamically" via some kind of "component selector". For instance somehow like this:



Any idea how to achieve this?
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Heiko, welcome to JavaRanch!

You could add a rendered attribute to your component to turn on and off rendering of it. If it's easier, you could put your component inside JSF container and use its rendered flag. All that assumes that by "dyanmic" you mean that it can change after requests to the server. If you want it to be dynamic completely on the client, you will need JavaScript / jQuery.
 
Heiko Tappe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for not being precise enough.

I know I could do something like creating a new composite and inside the composite I could list several components/composites and only ONE component is rendered based on some incoming attribute.
But this way the composite will grow and grow. The component selector I am thinking about might serve as a selector for maybe more than 100 components.
So I think it's necessary or better to have some kind of "registry" for the component and select it via some "key".

Background: Imagine some generic UI for defining jobs. Each job has its specific parameters and after selecting a job I would like to offer some input component(s) specially designed for that job.
 
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 IceFaces has a dynamic component tag. Either it or PrimeFaces.

As a rule, I prefer static definitions. they're easier to keep track of on the whole and easier to tweak for optimal appearance. But fortunately we have other options, too.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic