Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rendering in a PhaseListener

Albewrt Gore
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to output something in the HTML document, from a render PhaseListener.
This is part of my code:

public class AjaxRendererPhaseListener implements PhaseListener {

private void addBookmark(UIComponent component) throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter writer = context.getResponseWriter();
writer.startElement("div", component);
writer.writeAttribute("id", component.getClientId(context), null);

public void afterPhase(PhaseEvent event) {
UIViewRoot root = event.getFacesContext().getViewRoot();
for(Iterator it = root.getChildren().iterator(); it.hasNext() {
UIComponent component = (UIComponent);
try {
addBookmark(UIComponent component);

} catch (IOException ex) {

public void beforePhase(PhaseEvent event) {

public PhaseId getPhaseId() {

I registered it and I am sure the listener execute the code (I tried with logging).
So why the writer doesn't output anything in the HTML document?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic