Bind data from array
I have a table created dynamically where I don't know what columns I have. I've created the table but I don't know how to make the binding. I have a class that has a boolean array. I want to show a check box in every column. I've crated the columns:
Checkbox checkbox2 = new Checkbox();
tableColumn2.getChildren().add(checkbox2);
The thing is:
checkbox2.setValueBinding("selected", getApplication().createValueBinding("#{((currentRow.value['tipos'])[0])}"));
Is not working. I want to know if its possible to bind data to the check box from an array or something that is not a property.
[629 byte] By [
Azerotha] at [2007-11-27 7:36:39]

# 2
Actually I've see that example before but it's not quite what I need to do.
In that example, what I get, is how to get data from the table that is not in the bound data provider.
I need to bind a boolean that comes from myClass to a table. So I've created a Column in the TableRowGroup and bound a checkbox to this new column.
Now what I want to know is how to bind the boolean that is stored in an array to the checkbox.
My problem is that this boolean has to be in the array and can't be set as a property.
# 3
I am not understanding what you are doing. I am sorry.
Do you have an array of a class and one of the properties in the class is a boolean? Or do you have a class AND an array of booleans? If yo have a class AND an array of booleans, how do you associate the individual elements of the boolean array with the data in that particular row in the table.
What does the array look like. What does the class look like.
Some resources:
http://developers.sun.com/jscreator/learning/tutorials/2/dataproviders.html#06A
http://developers.sun.com/jscreator/learning/tutorials/2/about_components.html# input
http://blogs.sun.com/sakthi/entry/how_i_bind_checkbox_to
http://blogs.sun.com/winston/entry/non_boolean_checkbox
http://blogs.sun.com/winston/entry/non_boolean_checkbox
http://blogs.sun.com/winston/entry/multiple_selection_table1
# 5
With the JSF expression language, the following are equivalent
checkbox2.setValueBinding("selected", getApplication().createValueBinding("#{(currentRow.value['myArray'])}"));
checkbox2.setValueBinding("selected", getApplication().createValueBinding("#{(currentRow.value.myArray)}"));
So, to access an element of the array, try
checkbox2.setValueBinding("selected", getApplication().createValueBinding("#{(currentRow.value.myArray[0])}"));
Note for those who want to do this to static components via the Visual Designer: You have to make the change in the JSP to add [0]. Once you add the [0] the Table Layout dialog box will not open, so do this as the last step.