myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Belkom,Gijs G.H.C. van" <g.vanbel...@student.fontys.nl>
Subject Trinidad 2.0 TableRenderingContext nullpointer
Date Fri, 12 Mar 2010 13:14:02 GMT
Hello,

At this moment I am trying to build a Proof of Concept for my graduate project using Trinidad
2.0 nested grid component. The 'normal' approach for a grid is declaring the columns in the
xhtml page but I want to do this dynamically in the backing bean. When I create a new UIXTable
and add it to the CorePanelPage, even without any column data, the internet browser inmediately
returns at startup:

java.lang.NullPointerException
        at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableRenderingContext.<init>(TableRenderingContext.java:102)
        at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer.createRenderingContext(TableRenderer.java:518)
        at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer.encodeAll(TableRenderer.java:352)
        at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:364)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:782)
        at org.apache.myfaces.trinidad.component.UIXCollection.encodeEnd(UIXCollection.java:584)
etc...

/* -----------------------------------------------------*/

My JAVA class:

package data;
import java.io.Serializable;
import javax.el.ValueExpression;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.component.core.layout.CorePanelPage;
import org.apache.myfaces.trinidad.component.core.output.CoreOutputText;
import org.apache.myfaces.trinidad.component.core.nav.CoreCommandButton;
import org.apache.myfaces.trinidad.component.UIXColumn;
import org.apache.myfaces.trinidad.component.UIXTable;
/**
 *
 * @author gvanbelkom
 */
@ManagedBean(name = "Table")
@SessionScoped
public class Table implements Serializable
{
    CoreCommandButton button;
    CoreOutputText output;
    CorePanelPage panel;
    UIXColumn column;
    UIXTable table;
    /** Creates a new instance of Table */
    public Table()
    {
    }
    private void createDynamicObjects()
    {
        output = new CoreOutputText();
        output.setValueExpression("value", createValueExpression("I am a Trinidad OutputField",
String.class));
        button = new CoreCommandButton();
        button.setValueExpression("I am a Trinidad CommandButton", createValueExpression("test",
String.class));
        table = new UIXTable();
        table.setValueExpression("value", createValueExpression("I am a Trinidad Table", String.class));
        panel = new CorePanelPage();
        panel.getChildren().add(output);
        panel.getChildren().add(button);
        panel.getChildren().add(table);
    }
    public CorePanelPage getPanel()
    {
        if (panel == null)
        {
            createDynamicObjects();
        }
        return panel;
    }
    public void setPanel(CorePanelPage panel)
    {
        this.panel = panel;
    }
    private ValueExpression createValueExpression(String valueExpression, Class<?> valueType)
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        return facesContext.getApplication().getExpressionFactory().createValueExpression(
                facesContext.getELContext(), valueExpression, valueType);
    }
}

Do you have any sugestion to solve this problem?

Thanks in advance,

Gijs van Belkom

Mime
View raw message