You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by uw...@pharma.novartis.com on 2005/02/23 10:14:02 UTC

checkbox: item values?

Hi,

I'm using the x:dataTable tag in order to display my results.

Now I want to add a checkbox in front of each of those in order to let a 
user select which item to order when submitting the order via a Submit 
button.

Could somebody please give me a hint how I best get any item values of the 
checked ones for further processing?

Thanks very  much for any suggestion,

Uwe

Re: checkbox: item values?

Posted by Slawek <ss...@o2.pl>.
im doing it like this:

1. i have bean which represents one row.
this bean has properites that represents columns from database + one 
boolean property, lets name it checked (default false). if u have nice 
model of your data (ex. hibernate stuff) you can wrap it by bean that 
contains metioned boolean property.

2. i have for ex. ArrayList of my beans that is binded to x:dataTable
3. metioned checked property of my bean is binded to checkbox

after submit you can iterate trough arrayList and check id checked 
property of every element is true and do sth...

piece of "pseudocode":

//============model=================
//MyBean represents one row of datable
class MyBean{
	String data1;//to make code pure;) you can put all data to another class
	String data2;
	boolean checked;
	//getters nad setters
}
//*************
class SommeBean{
	ArrayList<MyBean> rows=//load from datasource
	//getetres, setters, action that check each row of rows if checked is true

}
//==============view=================

<x:dataTable
   var="row"
   value="#{sommeBean.rows}"
>

<h:column >
  <h:selectBooleanCheckbox value="#{row.checked}" />
</h:column>
<h:column>
<h:outputText value="#{row.data1}" />
</h:column>
.
.
.



Sławek Sobótka

> Hi,
>
> I'm using the x:dataTable tag in order to display my results.
>
> Now I want to add a checkbox in front of each of those in order to let a
> user select which item to order when submitting the order via a Submit
> button.
>
> Could somebody please give me a hint how I best get any item values of 
> the
> checked ones for further processing?
>
> Thanks very  much for any suggestion,
>
> Uwe