• 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

Custom component - The child is being rendered outside the parent

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to create some custom components but I'm having some trouble with the children.

So, given this xhtml page:



This is what I want the resulting page to look like on the browser:



But this is what I'm getting:



And this is the code for the components



What am I doing wrong?
 
Saloon Keeper
Posts: 27752
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
The first thing you did wrong was you wrote a custom control as Java code.

If at all possible, do your custom controls using XML, instead:

1) It's usually simpler
2) You're less likely to have to tear it up and rewrite it when a new JSF version comes out. JSF1 and JSF2 had some significant differences internally and it required overhauling binary tags.

Sometimes you need something that absolutely cannot be done in XML and you have no choice, though.

Truthfully, I haven't done one of these recently. But I believe that the parent tag is responsible to invoking the rendering processors of its children. I'm also not sure that you are using the correct mechanism to write your generated output, but I'd have to go back and look.

Also, one of the things that JSF2 did that JSF1 did not was provide a standard way for custom tags to throw renderings to the top or bottom of the generated HTML. For example, you could tag generated JavaScript to be bound to the h:head tag's renderer so that SCRIPT elements would render within the HTML HEAD element. This is especially useful when rendering custom CSS styles or link-including style and script libraries.
 
denis quaid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim, thank you for your response.

I just realized it was my own stupidity, I actually had the child tag outside the parent tag.
 
Tim Holloway
Saloon Keeper
Posts: 27752
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 the child tag is useless unless embedded in the parent tag, you might want to look "uphill" in the UIComponent tree to make sure that it has the proper parent and report if not.
reply
    Bookmark Topic Watch Topic
  • New Topic