This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Dynamic TaleColumn Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamic TaleColumn" Watch "Dynamic TaleColumn" New topic
Author

Dynamic TaleColumn

Walter Krawiec
Greenhorn

Joined: Jan 13, 2009
Posts: 20
Hello everyone!

I've problem related with data binding for webuijsf:table, I've array in sessionBean of my custom class objects, but but..., the thing is that I can just bind columns to value like:

currentRow.value['name']

but what if i've array inside of each custom objects and i want to split data from array to different columns,

for example:

Object Person[] (SessionBean) ==> bind to table

in class Person:
{
String notesStr[] = {"note 1","note 2","note 3"};
}

so how i suppose to get value from table using currentRow.value[] syntax? like: currentRow.value[noteStr[0]] ?? (it's not working at all...)

in backing bean I created sample code to support dynamic table, but works with single variables not with String array..:


FacesContext fc = FacesContext.getCurrentInstance();
ValueExpression ve = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(), "#{currentRow.value['testStr']}", String.class);

if (!columnInView) {
TableColumn col1 = new TableColumn();
col1.setVisible(true);
col1.setRendered(true);
col1.setHeaderText("DynCol1");
col1.setId("dynCol1");
// col1.setSort("desc");

StaticText st = new StaticText();
st.setValueExpression("value", ve);
col1.getChildren().add(st);

tprogress.getTableRowGroupChild().getChildren().add(col1);
}


cheers

Walter


Walter Krawiec
Greenhorn

Joined: Jan 13, 2009
Posts: 20
anyone ?
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
You can try currentRow.value.noteStr[0]
Walter Krawiec
Greenhorn

Joined: Jan 13, 2009
Posts: 20
Kavita Tipnis wrote:You can try currentRow.value.noteStr[0]


Thank you mate!

it's working fine, you saved my time ( I was about to build an extra data provider).

You are great!

cheers
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
I just happened to deal with similar EL expressions earlier ;)
JSF EL is good yet a little confusing because it differs slightly for each framework.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamic TaleColumn
 
Similar Threads
double click in textfield into the dynamic table open popup page and also get that rowkey and column
Problem in setting column width..
Arul
building a dataTable from java code
input text inside a datatable not updating