1 Reply Latest reply on May 22, 2006 12:09 AM by Gavin King

    Variable resolving problem when using custom facelets tag ha

    Pawel Kaczor Newbie

      Hi,
      This is my table:

      <t:dataTable var="empl" value="#{employeeList}">
      
      <n:column entity="${empl}" fieldName="name" label="#{msg.Employee}"/>


      this is a code from my column.xhtml component:

      <ui:composition>
       ...
       <h:column>
       ...//EXCEPTION IS THROWN when resolving valueBinding
       <n:setValueBinding var="vb" valueBinding="#{entity[fieldName]}" />
      
       <n:isText id="vb">
       <h:outputText value="#{entity[fieldName]}" style="tableInputField"/>
       </n:isText>
       </h:column>
      </ui:composition>


      And this is the apply() method from my tag handler for <n:setValueBinding> :

      public final class SetValueBindingHandler extends TagHandler {
       private final TagAttribute var;
       private final TagAttribute valueBinding;
      
       ...
       public void apply(final FaceletContext faceletsContext, final UIComponent parent) {
       /* Create the ValueExpression from the valueBinding attribute. */
       ValueExpression valueExpression = valueBinding.getValueExpression(faceletsContext, Object.class);
      
       /* Get the name of the new value. */
       String tvar = this.var.getValue(faceletsContext);
      
       // EXCEPTION IS THROWN HERE
       Class type = valueExpression.getType(faceletsContext);
      
       faceletsContext.setAttribute(tvar, valueExpression);
       faceletsContext.setAttribute(tvar + "Type", type);
       }
      }


      The log for the exception is:
      valueBinding="#{entity[fieldName]}": Target Unreachable, identifier 'entity' resolved to null

      The problem is that variable empl is not resolved by SeamVariableResolver while running apply method of my custom tag handler.

      Everything works well when not using custom tag handler:
      <ui:composition>
       ...
       <h:column>
       //EXCEPTION IS NOT THROWN when resolving value
       <h:outputText value="#{entity[fieldName]}" style="tableInputField"/>
       </h:column>
      </ui:composition>


      What is the reason for this? How to solve this problem??
      The code comes from the article: http://www-128.ibm.com/developerworks/java/library/j-facelets2.html?ca=drs-

      Thanks,
      Pawel Kaczor