[jboss-user] [JBoss Seam] - FacesMessages with components in dataList

ngeadah do-not-reply at jboss.com
Sun Oct 15 21:42:15 EDT 2006

There is a problem with the FacesMessages implementation for JSF components within in a dataList.  The problem is really caused by the poor implementation of dataList component ID's in MyFaces and how a component in a dataList cannot be instantiated by recursively searching through the JSF tree, as is done in FacesMessages getClientId method:

  |    private static String getClientId(UIComponent component, String id, FacesContext facesContext)
  |    {
  |       String componentId = component.getId();
  |       if (componentId!=null && componentId.equals(id))
  |       {
  |          return component.getClientId(facesContext);
  |       }
  |       else
  |       {
  |          Iterator iter = component.getFacetsAndChildren();
  |          while ( iter.hasNext() )
  |          {
  |             UIComponent child = (UIComponent) iter.next();
  |             String clientId = getClientId(child, id, facesContext);
  |             if (clientId!=null) return clientId;
  |          }
  |          return null;
  |       }
  |    }

This method will return null every time FacesMessages is used to "add" an error message for a component within a dataList as no component will ever match the "id" parameter if that component is in a dataList.

Gavin - I think it would be better for getClientId to at least accomodate this MyFaces flaw by returning the "id" parameter instead of null when no component is found.  That way, messages can be added through FacesMessages using the full component's client ID if that component is within a dataList (e.g. myForm:myList:0:myComponent).  It's not as nice as being able to pass in "myComponent" as the ID directly, but at least it doesn't return null which prevents adding messages altogether.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978425#3978425

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978425

More information about the jboss-user mailing list