UIXTable is not a concrete class, you should be using CoreTable. You
should never use "new ComponentClass" to create a component, but
instead should be using the Application to create the component using
the component type. This ensures that you get the correct
implementation class for the current render kit.

-Andrew

On Fri, Mar 12, 2010 at 6:14 AM, Belkom,Gijs G.H.C. van
<[email protected]> wrote:
> 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
>

Reply via email to