*
The moose likes JSF and the fly likes My own JSF component renders span after div when only div should be rendered. What's wrong? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "My own JSF component renders span after div when only div should be rendered. What Watch "My own JSF component renders span after div when only div should be rendered. What New topic
Author

My own JSF component renders span after div when only div should be rendered. What's wrong?

Titan Faces
Greenhorn

Joined: Feb 11, 2012
Posts: 1
Hi everyone!
I have created my first JSF component which should simply display a div element with some text inside. This is how I use it.

This is the component's class:

Taglib

When I don't provide the id for the sf:hello compponent everything is rendered as expected:

The problem is when I provide the id for the element e.g.:

Suprisingly a span element is rendered after the div element

Why did this span alement appear there?
Thanks for help!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

It looks like the span was generated solely for the purpose of providing a place to hang the tag's id value. Which is a problem, since you already generated a tag with the same ID, thus violating the uniqueness requirement. The choice of "span" was undoubtedly because it's probably the only HTML wrapper that wouldn't alter the page layout.

I try to avoid doing custom JSF tags as Java code at the moment. I don't trust the mechanisms to remain stable. And it's easier to implement custom controls and the like as XML custom tags, instead. I recommend doing some serious manual reading, though. There's probably a way to switch off the automatic wrapper generation. Although the fact that the span follows your generated code instead of wrapping it probably indicates you haven't followed the protocols properly anyway.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: My own JSF component renders span after div when only div should be rendered. What's wrong?
 
Similar Threads
Facelets custom tag not recognized ?
JSF2.0 custom component development
javax.el.PropertyNotFoundException: Objetivo inalcanzable - JSF - Facelet - method-signature
Facelets and JSF
JSF, Facelets losing context after reload