Jenia's data multipleRowsSelector builds a list of the objects that
you are iterating over. So if your data table's value points to a list
of "MyObject" then the multipleRowsSelector will create list of
MyObject instances for each row that had the checkbox selected.
public class MyItem { ... }
public class MyBean
{
private List<MyItem> selectedItems;
private List<MyItem> allItems;
public List<MyItem> getSelectedItems() { return selectedItems; }
public void setSelectedItems(List<MyItem> selectedItems)
{ this.selectedItems = selectedItems; }
public List<MyItem> getAllItems() { return allItems; }
public String load()
{
// load all items here
}
public String onSubmit()
{
// put your code here
for (MyItem item : selectedItems)
; // do something with it
}
}
<t:dataTable
value="#{myBean.allItems}"
var="_item">
<t:column>
<jdt:multipleRowsSelector
selectionList="#{myBean.selectedItems}" />
</t:column>
<t:column>
<f:facet name="header">
<t:outputText value="Something" />
</f:facet>
<t:outputText value="#{_item.something}" />
</t:column>
</t:dataTable>
<t:commandLink action="#{myBean.onSubmit}"
value="Submit" />
As I mentioned, you don't want to work with IDs of the checkboxes.
-Andrew
On 8/9/06, nimisha sharma <[EMAIL PROTECTED]> wrote:
I also saw your post on
http://mail-archives.apache.org/mod_mbox/myfaces-users/200605.mbox/[EMAIL
PROTECTED]
but i dont get any checkboxes when i use :
<jdt:multipleRowsSelector selectionList="#{mybean.selectedItems}" />
To be more precise, plz find my datatable part:
<html xmlns:jdt="http://www.jenia.org/jsf/dataTools ">
-------
<
t:dataTable
value="#{MaintenanceBean.perfFeeMaintModel.perfFee}"
var="accountList"
id="perfFeeMaint"
rows="4">
<t:column>
<f:facet name="header" >
<h:outputText value="Number" ></h:outputText>
</f:facet>
<t:outputText value="#{accountList.id}" >
<f:param id="selectedRow"
name="id"
value="#{accountList.id}" />
</t:outputText>
</t:column>
<t:column>
<f:facet name="header" >
<h:outputText value="Account" ></h:outputText>
</f:facet>
<t:outputText value="#{accountList.account}" ></t:outputText>
</t:column>
<t:column>
<f:facet name="header" >
<h:outputText value="Performance Fee" ></h:outputText>
</f:facet>
<jdt:multipleRowsSelector selectionList="#{accountList.selectedPerf }" />
</t:column>
</t:dataTable>
I need the id for each checkbox that is selected by the user.. like in
regular HTML, i can do that by request.getParameterValues() and it gives me
an array..
Thanks for the help again...
Regards,
Nimisha.
On 8/9/06, nimisha sharma <[EMAIL PROTECTED]> wrote:
>
>
> Hi Andrew,
>
> Thanks for the quick response. What i want to do exactly is that one of
the columns (it is a property in my list) in my datatable contains
checkboxes.. i have to get them prepopulated (this i can easily do since the
list that i pass to my datatable has it)
> Now, once the user has this infront of him, he can modify the status of
these checkboxes and submit the form. I need to retrieve these values in my
bean.. so that i can update the db with the values selected by the user.
>
> With the first option i could not get exactly what has to be done.
>
> Regards,
>
> Nimisha.
>
>
> On 8/9/06, Andrew Robinson <[EMAIL PROTECTED] > wrote:
> > And FYI, you should avoid using the request parameters yourself -- it
> > is best to let the JSF controls do that. DataTables not only use
> > client IDs, but also add an inded for each row, so it is really not
> > best to attempt to reproduce the ID yourself. Also renderers have the
> > full ability and right according to the specification to change the ID
> > to whatever they want (they don't even have to use the ID attribute
> > from the UIComponent if they don't want to)
> >
> > On 8/9/06, Andrew Robinson < [EMAIL PROTECTED] > wrote:
> > > If the checkbox is for a property on your loop variable (say Item):
> > >
> > > <t:dataTable
> > > value="#{mybean.mylist}"
> > > var="_item">
> > > <t:column>
> > > <t:selectBooleanCheckbox value="#{_item.selected}" />
> > > </t:column>
> > > </t:dataTable>
> > >
> > > If you want to save the checked items in a list on the bean:
> > > <html
> > > ...
> > > xmlns:jdt="http://www.jenia.org/jsf/dataTools">
> > > ...
> > > <t:dataTable
> > > value="#{mybean.mylist}"
> > > var="_item">
> > > <t:column>
> > > <jdt:multipleRowsSelector
> > > selectionList="#{ mybean.selectedItems}" />
> > > </t:column>
> > > </t:dataTable>
> > >
> > > Where "selectedItems" would map to methods:
> > > public List<Item> getSelectedItems()
> > > public void setSelectedItems(List<Item> items)
> > >
> > > -Andrew
> > >
> > > On 8/9/06, nimisha sharma < [EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I think this discussion must have already been there on this but
since i
> > > > could not find it, i m posting it here..
> > > >
> > > > I have a datatable where i have checkboxes in one column that the
user
> > > > checks.. these values have to be saved when the user clicks the save
button.
> > > > Somehow, i cannot get the values in my bean.. The command button for
save
> > > > has an action that calls the save() method in my bean. I have to get
the
> > > > values here so that i can update the db tables with these values.
> > > >
> > > > With each checkbox, i have set the param also.. as given:
> > > >
> > > >
> > > >
> > > > <t:selectBooleanCheckbox value="#{ accountList.perfFee}" >
> > > >
> > > > <f:param id="selectedPerf"
> > > >
> > > > name="perf"
> > > >
> > > > value="#{accountList.perfFee}" />
> > > >
> > > > </t:selectBooleanCheckbox>
> > > >
> > > > now, in my bean if i try getting the value using:
> > > >
> > > > (String)
> > > >
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("selectedPerf");
> > > > it returns null as there would be a List of values..
> > > >
> > > > Could someone give me directions as to how this can be done...
> > > >
> > > > Appreciate,
> > > >
> > > >
> > > > Nimisha.
> > > >
> > >
> >
>
>