Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom component - The child is being rendered outside the parent  RSS feed

 
denis quaid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!