Hi Rajiv,

JSFSter Smith wrote:
> 
> 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);
> 

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

Why this? Thats the problem!
Here are the valueBinding evaluated at component creation time, but
datatable needs eavluation at rendering time!

just remove this an it should do.


>               }
>               else
>                   ((UIInfactHTMLOutput)component).setValue(value);
>         }
>     }
> 


or better implement your set properties using UIComponentTagUtils like this:

    protected void setProperties(UIComponent component)
    {
      super.setProperties(component);
      UIComponentTagUtils.setValueProperty(getFacesContext(), component,
value);
    }




Regards,
  Volker

> thanks in advance!
> 
> -Rajiv

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Reply via email to