You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dave <ja...@yahoo.com> on 2006/02/10 23:28:13 UTC

Why ViewRoot.getComponent(clientId) return null?

In a PhaseListener, first get all the clientId(s) with queued messages, then try to find the components. But ViewRoot.findComponent(clientId) return null.
   
  public void beforePhase(PhaseEvent event) {
      FacesContext context = event.getFacesContext();
    UIViewRoot root = context.getViewRoot();
    Iterator<String> itr = context.getClientIdsWithMessages();
    while (itr.hasNext()) {
      String clientId = itr.next();
      UIComponent component = root.findComponent(clientId);
        // ERROR: component is null
        ....
      }
  }
   
  Thanks for ideas.

		
---------------------------------
Relax. Yahoo! Mail virus scanning helps detect nasty viruses!

Re: Why ViewRoot.getComponent(clientId) return null?

Posted by Laurie Harper <la...@holoweb.net>.
Dave wrote:
> In a PhaseListener, first get all the clientId(s) with queued messages, then try to find the components. But ViewRoot.findComponent(clientId) return null.
>    
>   public void beforePhase(PhaseEvent event) {
>       FacesContext context = event.getFacesContext();
>     UIViewRoot root = context.getViewRoot();
>     Iterator<String> itr = context.getClientIdsWithMessages();
>     while (itr.hasNext()) {
>       String clientId = itr.next();
>       UIComponent component = root.findComponent(clientId);
>         // ERROR: component is null
>         ....
>       }
>   }
>    
>   Thanks for ideas.

I would guess you need to check what phase you are in before proceeding. 
It doesn't make much sense to call findComponnet before the Restore View 
phase, for example.

L.