general JSF question (table with checkbox)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-09-2007 10:56 AM
I am trying to modify one of the pages so that the table within it will have a checkbox and a link in every row.
I've built the table, and everything seems to work fine besides one thing - i can't get the checkbox to be selected via the java codeā¦
:arrow: i need to check every row of the table's model and for the desired rows i need to select the checkboxā¦
I've tried using phase listeners - i get the right model, get the row, get the checkbox from the row, set "selected" to "true", but still - the checkbox is rendered as uncheckedā¦.
any ideas????
:roll:
thanks.
Dror
I've built the table, and everything seems to work fine besides one thing - i can't get the checkbox to be selected via the java codeā¦
:arrow: i need to check every row of the table's model and for the desired rows i need to select the checkboxā¦
I've tried using phase listeners - i get the right model, get the row, get the checkbox from the row, set "selected" to "true", but still - the checkbox is rendered as uncheckedā¦.
any ideas????
:roll:
thanks.
Dror
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2007 07:54 AM
anyone???
i am really stuck hereā¦
:?
i am really stuck hereā¦
:?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2007 10:54 AM
Posting some code would be helpfull..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-17-2007 11:36 AM
thanks dhalupa.
this is the relevant code:
[MyBean = the backing bean for the page
childRefs = a collection of references i want to present in the table]
the page shows some data, and every row is a link to the next level of data (the functionlity is similar to navigating through folders - which means - i need to change the model of the table)
when i navigate (as i metioned, i can navigate in and out) i need to show every checkbox that was selected as checked, even when i return to it after i navigated elsewhereā¦
this is what i do when i navigate to the next level (or back to a level i already visited):
[checkedValues = a collection of the recently checked values (i add every value that is checked to this collection)]
but still - after setting the checkbox for all the desired rows, the table is rendered and non of the checkboxes is selectedā¦.
:evil:
thanks,
Dror
this is the relevant code:
[MyBean = the backing bean for the page
childRefs = a collection of references i want to present in the table]
<h:dataTable id="myTable" border="0" binding="#{MyBean.myTable}" value="#{MyBean.childRefs}" var="line"> <h:column> <h:selectBooleanCheckbox id="myCheckbox" immediate="true"/> </h:column> <h:column> <h:commandLink id="cmd-link" action="#{MyBean.getChildrenForNode}" immediate="true"> <h:outputText id="output-text" value="#{line.QName.localName}"/> </h:commandLink> </h:column> </h:dataTable>āāāāāāāāāā
the page shows some data, and every row is a link to the next level of data (the functionlity is similar to navigating through folders - which means - i need to change the model of the table)
when i navigate (as i metioned, i can navigate in and out) i need to show every checkbox that was selected as checked, even when i return to it after i navigated elsewhereā¦
this is what i do when i navigate to the next level (or back to a level i already visited):
[checkedValues = a collection of the recently checked values (i add every value that is checked to this collection)]
if(myTable!= null) { for (int i=0; i < myTable.getRowCount(); i++) { myTable.setRowIndex(i); if(checkedValues.contains(((ChildAssociationRef)myTable.getRowData()).getChildRef())) { UISelectBoolean box = (UISelectBoolean)myTable.findComponent("categoryCheckbox"); box.setSelected(true); box.setValue(true); box.saveState(context); } } }āāāāāāāāāāāāāāā
but still - after setting the checkbox for all the desired rows, the table is rendered and non of the checkboxes is selectedā¦.
:evil:
thanks,
Dror

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-17-2007 01:08 PM
Uf, this is completely wrong, there is only one instance of uiselectboolean component in the component tree and datatable during rendering of children is encoding this component once per each row. Therefore you can not update the value of your component like this. You have to bound the value property of selectbox component to something from your datamodel like ${line.selected}.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-18-2007 04:53 AM
thanks dhalupa!!!
i did exactly that. now it is working :wink:
i did exactly that. now it is working :wink:
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-18-2008 11:38 AM
Yes that is the correct approach as Craig states here
http://forum.java.sun.com/thread.jspa?threadID=486654&messageID=2819434
I too can get it to work fine in a data table. BUT, as soon as I try and do this in an alfresco rich list I get a "base is null" validation error. Any ideas?
http://forum.java.sun.com/thread.jspa?threadID=486654&messageID=2819434
I too can get it to work fine in a data table. BUT, as soon as I try and do this in an alfresco rich list I get a "base is null" validation error. Any ideas?
<a:richList viewMode="details" pageSize="20" ā¦var="promotion"ā¦ <a:column primary="true"> <f:facet name="header"> <a:outputText value="Bulk" styleClass="header" /> </f:facet> <h:selectBooleanCheckbox title="bulkUpdates" value="#{promotion.selected}"></h:selectBooleanCheckbox> </a:column></a:richList>āāāāāāāāāāā
