tags:

views:

256

answers:

2

Hi all,

I am trying to write a custom tag. I can write attributes; however, I'm having difficulty writing the innerHTML part:

<span class="required">*</span>

I can write:

writer.startElement("span", component);
writer.writeAttribute("class", "required", "class");
writer.endElement("span");

How do I write the *?

http://developers.sun.com/docs/jscreator/apis/jsf/javax/faces/context/ResponseWriter.html

This is a simple example, essentially, I would like to wrap some other JSF components to simplify what goes into my xhtml file.

Thanks, Walter

+1  A: 

Isn't that what ResponseWriter.writeText does?

DigitalRoss
+2  A: 

As explained by digitalross, you can simply write text:

writer.startElement("span", component);
writer.writeAttribute("class", "required", "class");
writer.writeText("*");
writer.endElement("span");

If you need to include another HTML tags (instead of text):

writer.startElement("span", component);
writer.writeAttribute("class", "required", "class");
writer.startElement("xxx", component);
...
writer.endElement("xxx");
writer.endElement("span");
romaintaz
This works very good for me
ChrisAD