Firstly, kudos to the MyFaces team for the recent releases of myfaces 1.1.3 and tomahawk 1.1.2!

I am just a few weeks old with JSF and am using it for a current project. So far its been great but I am still getting to know the deatils. I attempted to create a simple custom JSP tag and was able to get it together surprisingly quickly. But I do have a problem now. My tag essentially renders the string in an attribute "value". Here is a sample usage:

<my:testTag value="My message"> (or) <my:testTag value="#{datapanel.description}">

But the ValueBinding does not seem to work when I try to access a member of the DataPanel bean that is a collection or another class that has members. Examples of these cases are below:

<t:dataTable value="#{datapanel.sentenceDisplayData}" var="each">
    <t:column>
        <my:testTag value="#{each.part0}" />
        <my:testTag value="#{each.part1}" />
        <my:testTag value="#{each.part2}" />
        <my:testTag value="#{each.part3}" />
    </t:column>
</t:dataTable>

(OR)
<my:testTag value="#{datapanel.summary.length">

I am including my setProperties method of the TagLib class. Would be great if someone can point out what I am missing here.

    protected void setProperties(UIComponent component)
    {
        /* you have to call the super class */

        FacesContext context = FacesContext.getCurrentInstance();
        super.setProperties(component);
       
        if(value != null)
        {
            if (isValueReference(value))
             {
                ValueBinding vb = context.getApplication().createValueBinding(value);
                component.setValueBinding("value", vb);

                // forcing the value from the ValueBinding to the component.
                if(vb != null)
                {
                    if(vb.getValue(context) != null)
                    ((UIInfactHTMLOutput)component).setValue(vb.getValue(context).toString());
                }
              }
              else
                  ((UIInfactHTMLOutput)component).setValue(value);
        }
    }

thanks in advance!

-Rajiv

Reply via email to