SelectOneRadio inside datatable?

How do I put a <h:selectOneRadio> inside a datatable> Ie if I wanted to rank names from 1 to 3?

<h:dataTable value="#{bean.myNames}"

var="n"

>

<h:column>

<f:facet name="header">

<h:outputText value="Function Name"/>

</f:facet>

<h:outputText value="#{n.Name}"/>

</h:column>

<h:column>

<f:facet name="header">

<h:outputText value="Rank"/>

</f:facet>

<h:selectOneRadio binding="#{bean.selectOneRank}" >

<f:selectItem itemValue="1" />

<f:selectItem itemValue="2" />

<f:selectItem itemValue="3" />

</h:selectOneRadio>

</h:column>

</h:dataTable>

How do I in the bean say that name y got rank z?

[859 byte] By [ericchilea] at [2007-11-27 6:21:44]
# 1
Attach it to the row object, the DTO, not to the backing bean.<h:dataTable value="#{myBean.rows}" var="row"><h:column><h:selectOneRadio value="#{row.selectedItem}">...
BalusCa at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
The row is iterating on a list of EJB objects from the database. Is there any other way?
ericchilea at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Subclass the EJB and add the selectOneRadio value to it.Another option is to maintain a backing List/Map and make use of HtmlDataTable#getRowData() inside the selectOneRadio valuebinding to retrieve the current row object. But this is more expensive.
BalusCa at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thanks for the help.... I was taught that you should keep the view separate from the model. So I will explore the later....Its too bad there isn't a more eloquent way, as this is easy to do in common jsp.
ericchilea at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Since when should the selectOneRadio value be part of the view?
BalusCa at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Your right... were talking about the value not the componet...But when I add another Variable to my EJB say... String selectOne;It things selectOne is a column in the database table and throws an error?
ericchilea at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
> It things selectOne is a column in the database table and throws an error?I don't understand you. Things? Which error?
BalusCa at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Im sorry, I couldn't edit my post after I read it again...

What is happening is I am adding a value to the EJB in the form of a String. So that the value of the SelectOneRadio can be set to this.

But when I do that the EJB things that it is a Column in the Table in the Database, and none of the queries work.

How do you add a variable to an EJB and not have it be part of the queries?

ericchilea at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Like I said .. subclass the EJB.
BalusCa at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

Worked thanks...

I wish you could iterate though two items at one time in a data table... like this

List temp;

List temp2;

for (int i=0; i<temp.size(); i++){

temp.get(i);

if (temp2.get(i)) temp2.get(i);

}

But in a datatable....

I also found this

http://www.javaworld.com/javaworld/jw-02-2007/jw-02-jsf.html?page=2

That would work better IMHO

Thanks for your help.>

ericchilea at 2007-7-12 17:38:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...