• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reference a composite component dynamically

 
Heiko Tappe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic