aha the problem is quite simple. Valuebindings resolved in the tag
class can not be used for dynamic beans like the var in UIData
components. Because they are created dynamically in the process
methods of the components and the tag class is just the entry point
for jsf.

Either subclass from org.apache.myfaces.taglib.UIComponentTagBase and
use set*Property(...) to pass the attribute values to the component or
test every attribute value if it is a valuebinding and call
component.setValueBinding(...) but don´t call
ValueBinding.getValue(...) in your tag classes.

These value bindings are evaluated in the component classes. Every
getter method in the component which may have a valuebinding should be
implemented like this one:

public String getSomething()
{
  if(_something != null) return _something;
  ValueBinding vb = getValueBinding("something");
  return vb != null ? (String)vb.getValue(getFacesContext()) : null;
}

// the setter is simple.
public void setSomething(String something)
{
  _something = something;
}

just a hint: take care for your _something value in saveState/restoreState


2005/10/19, Stefan Gesigora <[EMAIL PROTECTED]>:
> Hi!
>
> If I use my custom component in the datatable the expressions "#{list.id}" 
> and "#{list.isIntern}" are resolved as null values.
>
> Here are the snippets of my TagClasses:
>
> ---SNIP--
>
> public abstract class BaseTag extends UIComponentTag{
>
>   /**
>    * @param attributeValue String
>    * @return String
>    */
>   public String solveValueBinding(String attributeValue) {
>     if (attributeValue != null && isValueReference(attributeValue))
>       return getValueBindingVal(attributeValue);
>     return attributeValue;
>   }
>
>   /**
>    * @param attributeValue String
>    * @return String
>    */
>   private String getValueBindingVal(String attributeValue) {
>     FacesContext context = FacesContext.getCurrentInstance();
>     ValueBinding vb = 
> context.getApplication().createValueBinding(attributeValue);
>     return (String) vb.getValue(context);
>   }
>
> }
>
>
> package com.dsa.qms.web.components;
>
> import javax.faces.component.UIComponent;
>
> public class EmployeeTag extends BaseTag{
>
>   private String readOnly;
>   private String partIntern;
>   private String roleAbbrev;
>   private String partId;
>   private String totalStyleClass;
>   private String descLeftStyleClass;
>   private String descRightStyleClass;
>   private String selectBoxStyleClass;
>   private String contentStyleClass;
>
>
>   public EmployeeTag () {
>   }
>
>   /**
>    * @return String
>    */
>   public String getComponentType() {
>     return "Employee";
>   }
>
>   /**
>    * @return String
>    */
>   public String getRendererType() {
>     return null;
>   }
>
>   protected void setProperties(UIComponent component) {
>
>     super.setProperties(component);
>     EmployeeComponent employeeComponent = (EmployeeComponent) component;
>
>     employeeComponent.setReadOnly( new  
> Boolean(solveValueBinding(readOnly)).booleanValue() );
>     employeeComponent.setPartIntern( new        
> Boolean(solveValueBinding(partIntern)).booleanValue() );
>     employeeComponent.setRoleAbbrev(solveValueBinding(roleAbbrev));
>     employeeComponent.setPartId(solveValueBinding(partId));
>    employeeComponent.setTotalStyleClass(solveValueBinding(totalStyleClass));
>     
> employeeComponent.setDescLeftStyleClass(solveValueBinding(descLeftStyleClass));
>     
> employeeComponent.setDescRightStyleClass(solveValueBinding(descRightStyleClass));
>     
> employeeComponent.setSelectBoxStyleClass(solveValueBinding(selectBoxStyleClass));
>     
> employeeComponent.setContentStyleClass(solveValueBinding(contentStyleClass));
>
>   }
>
>   public void release() {
>     super.release();
>     readOnly = null;
>     partIntern = null;
>     roleAbbrev = null;
>     partId = null;
>     totalStyleClass = null;
>     descLeftStyleClass = null;
>     descRightStyleClass = null;
>     selectBoxStyleClass = null;
>     contentStyleClass = null;
>
>   }
>
>   public void setRoleAbbrev(String roleAbbrev) {
>     this.roleAbbrev = roleAbbrev;
>   }
>
>   public void setReadOnly(String readOnly) {
>     this.readOnly = readOnly;
>   }
>
>   public void setContentStyleClass(String contentStyleClass) {
>     this.contentStyleClass = contentStyleClass;
>   }
>
>   public void setDescLeftStyleClass(String descLeftStyleClass) {
>     this.descLeftStyleClass = descLeftStyleClass;
>   }
>
>   public void setTotalStyleClass(String totalStyleClass) {
>     this.totalStyleClass = totalStyleClass;
>   }
>
>   public void setDescRightStyleClass(String descRightStyleClass) {
>     this.descRightStyleClass = descRightStyleClass;
>   }
>
>   public void setSelectBoxStyleClass(String selectBoxStyleClass) {
>     this.selectBoxStyleClass = selectBoxStyleClass;
>   }
>
>   public void setPartId(String partId) {
>     this.partId = partId;
>   }
>
>   public void setPartIntern(String partIntern) {
>     this.partIntern = partIntern;
>   }
>
>   public String getRoleAbbrev() {
>     return roleAbbrev;
>   }
>
>   public String getReadOnly() {
>     return readOnly;
>   }
>
>   public String getContentStyleClass() {
>     return contentStyleClass;
>   }
>
>   public String getDescLeftStyleClass() {
>     return descLeftStyleClass;
>   }
>
>   public String getTotalStyleClass() {
>     return totalStyleClass;
>   }
>
>   public String getDescRightStyleClass() {
>     return descRightStyleClass;
>   }
>
>   public String getSelectBoxStyleClass() {
>     return selectBoxStyleClass;
>   }
>
>   public String getPartId() {
>     return partId;
>   }
>
>   public String getPartIntern() {
>     return partIntern;
>   }
>
> }
>
>
> ---SNIP--
>
> Regards,
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 19. Oktober 2005 11:08
> An: MyFaces Discussion
> Betreff: Re: custom output component in datatable
>
> IMO there is nothing wrong with the two methods you have posted.
>
> Can you post the getter methods for partId and partIntern?
> What happens if you use it in the datatable?
>
> 2005/10/19, Stefan Gesigora <[EMAIL PROTECTED]>:
> > Hi!
> >
> > I'm trying to use my custom output component "employee" in a standard
> > h:datatable.
> >
> > ---Snip---
> >
> > <h:dataTable width="100%" value="#{facListBean.facList}" var="list">
> >        <h:column>
> >         <ds:employee partId="#{list.id}" partIntern="#{list.isIntern}"/>
> >        </h:column>
> > </h:dataTable>
> >
> > ---Snip---
> >
> > To get the value of "#{list.id}" and "#{list.isIntern}" I've used the
> > method solveValueBinding:
> >
> >   public String solveValueBinding(String attributeValue) {
> >     if (attributeValue != null && isValueReference(attributeValue))
> >       return getValueBindingVal(attributeValue);
> >     return attributeValue;
> >   }
> >
> >   private String getValueBindingVal(String attributeValue) {
> >     FacesContext context = FacesContext.getCurrentInstance();
> >     ValueBinding vb =
> > context.getApplication().createValueBinding(attributeValue);
> >     return (String) vb.getValue(context);
> >   }
> >
> > It works fine with other values BUT not in the datatable!!
> > How can I resolve the values??
> >
> > regards,
> >
> > Stefan
> >
>
>
> --
> Mathias
>
>


--
Mathias

Reply via email to