0 Replies Latest reply on Jun 24, 2008 1:19 AM by anjana patel

    Error while creating id dynamically. Help needed.

    anjana patel Newbie

      Hi

      I am trying to create a rich:tree component.
      Find the code snippet below.

      <rich:tree
      nodeSelectListener="#{treeBean.processSelection}"
      ajaxSubmitSelection="true"
      switchType="ajax"
      changeExpandListener="#{treeBean.processExpansion}"
      adviseNodeOpened="#{treeBean.adviseNodeOpened}"
      id="tree"
      ajaxSingle="false"
      adviseNodeSelected="#{treeBean.adviseNodeSelected}"
      value="#{treeBean.rootNode}" var="item" nodeFace="#{item.type}">

      <rich:treeNode id="#{item.id}" type="node" onclick="nodeClick(#{item})" iconLeaf="/treemanager/images/parent_norm.gif" icon="/treemanager/images/parent_norm.gif">
      <h:outputText value="#{item.name}" style="font-size:8pt;"/>
      </rich:treeNode>

      <rich:treeNode id="#{item.id}" type="leaf" iconLeaf="/treemanager/images/orange.gif" icon="/treemanager/images/orange.gif">
      <h:outputText value="#{item.name}" style="font-size: 8pt;"/>
      </rich:treeNode>

      <rich:treeNode id="#{item.id}" type="next" iconLeaf="/treemanager/images/next.gif" icon="/treemanager/images/next.gif">
      <h:outputText value="#{item.name}" style="font-size: 8pt;color:blue"/>
      </rich:treeNode>

      <rich:treeNode id="#{item.id}" type="prev" iconLeaf="/treemanager/images/previous.gif" icon="/treemanager/images/previous.gif">
      <h:outputText value="#{item.name}" style="font-size: 8pt; color:blue"/>
      </rich:treeNode>
      </rich:tree>

      When I try to give the id as EL, am getting exception as mentioned below.
      (It works fine with a static one)

      ************************************************************************
      javax.servlet.ServletException
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)

      root cause

      java.lang.IllegalArgumentException
      javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:536)
      javax.faces.component.UIComponentBase.setId(UIComponentBase.java:344)
      com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:151)
      com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64)
      com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
      com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:312)
      com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:282)
      com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
      com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64)
      com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
      com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:312)
      com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:282)
      com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
      com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)

      *************************************************************************************

      Can't we dynamically create Id for richfaces components or the way I am doing is wrong?

      Can any one clarify it?

      Thanks in advance