aspose file tools
The moose likes JSF and the fly likes rendering in  a PhaseListener Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "rendering in  a PhaseListener" Watch "rendering in  a PhaseListener" New topic
Author

rendering in a PhaseListener

Albewrt Gore
Greenhorn

Joined: Feb 08, 2005
Posts: 4
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);
writer.endElement("div");
writer.flush();
}


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

} catch (IOException ex) {
ex.printStackTrace();
}
}
}

public void beforePhase(PhaseEvent event) {
}

public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
}

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rendering in a PhaseListener
 
Similar Threads
getting the component when it is a specific TYPE
UiViewRoot - findComponent dont work
Custom control + character encoding issue
Setting a Component readonly Dynamically
Modify components in backing bean