myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Winer" <awi...@gmail.com>
Subject Re: [Trinidad] creating tr:table using binding
Date Fri, 10 Aug 2007 15:51:43 GMT
On 8/10/07, Luka Surija <luka@iytim.hr> wrote:
> Hi,
> I'm trying to create a tr:table using binging, and almost everything
> works fine except, getting row values in table.
>
> I've created in index.xhtml this:
>
> <tr:table binding="bean.table" />
>
> and in backing bean crating columns, and outputText inside columns. This
> is working well, but I can't figure out how to set value to the
> outputText as an expression using row value. Example:
>
> table.setValue(getMyData());
> table.setVar("row");
> CoreColumn column = new CoreColumn();
> column.setParetn(table);

Don't do this!  setParent() is called for you.  Don't ever call
it on your own (see the Javadoc).

> column.setTransient(true);
> CoreOutputText text = new CoreOutputText();
> text.setParent(column);
> text.setTransient(true);
> column.getChildren().add(text);
> table.getChildren().add(column);
>
> and now the tricky part. How to set an value to text?
>
> 1. case
> text.setValue("bla");  --- it works, "bla" is showing in each row of the
> table.
> 2. case and 3. case
> ExpressionFactory ef =
> FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
> ELContext elContext = FacesContext.getCurrentInstance().getELContext();
> ValueExpression value =
> ef.createValueExpression(elContext,"#{'xxx'}",String.class);
>
> text.setValue(value) --- "ValueExpression[#{'xxx'}] is showing as output
> in table cell
> text.setValueExpression("value",value) --- table cell is empty

You want text.setValueExpression() - the problem will be that
your ValueExpression is wrong.  It needs to be something like:

ValueExpression value =
ef.createValueExpression(elContext,"#{row.xxx}",String.class);

-- Adam

Mime
View raw message