From my experience using clay I think it would be nice if the
ClayViewHandler accepted listeners that get invoked after the clay
component has been created but before rendering to the outputstream.

This is the case that I have.  I have a render phase listener that
adds javascript, stylesheets, etc before the render phase.  I would
like this listener to know about the faces tree so that I can add
certain javascript only if the tree contains certain components.  The
phase listener doesn't work because it only gives me hooks into before
render and after render.  Before render the tree has not been created
yet, and after render it has already been commited to the stream.  So
in ClayViewHandler I would need something like

UIComponent component = view.findComponent(CLAY_VIEW_ID);
if (component == null) {
  // create clay
}

// start new
Iterator i = getClayListeners().iterator();
while (i.hasNext()) {
   ClayListener next = (ClayListener) i.next();
   next.afterClayCreated(context);
}
// end new

ServletResponse response = ...

This would allow me to inspect the tree and add the appropriate
javascript to the view.

Thanks,
Ryan

Reply via email to