This content has been marked as final.
Show 6 replies
-
1. Re: rich:datatable - how to get rows
ilya_shaikovsky Aug 3, 2009 10:07 AM (in response to zelenka)you should implement data model properly. see modifiable model sample at richfaces-demo.
-
2. Re: rich:datatable - how to get rows
zelenka Aug 4, 2009 1:47 AM (in response to zelenka)"ilya_shaikovsky" wrote:
you should implement data model properly. see modifiable model sample at richfaces-demo.
Thanks, but I think don't understand it. Maybe it's too complicated for me. I have very simple data table:
<rich:dataTable id="table" value="#{MyBean.carList}" var="item" rows="25"> The only thing I need is when user clicks a button in the page to iterate actually viewed data from data table. -
3. Re: rich:datatable - how to get rows
ilya_shaikovsky Aug 4, 2009 4:55 AM (in response to zelenka)check richfaces-demo all samples placed at dataTable menu item.
-
4. Re: rich:datatable - how to get rows
johndoe123 Aug 4, 2009 5:07 AM (in response to zelenka)You don't need to write a whole custom DataModel.
Construct your Bean like this:int currentCarListIndex = 0; Car currentCar; public Car getCurrentCar() { return currentCar; } public void setCurrentCar(Car c) { this.currentCar = car; } public void nextCar() { //TODO: bounds check currentCar = carList.get(currentCarListIndex++); }
Then construct your datatable like this:<rich:dataTable id="datatable" rows="20" var="item" value="#{MyBean.carList}" > <rich:column> <f:facet name="header">Actions</f:facet> <a4j:commandLink id="editlink" > <h:graphicImage value="/img/edit.gif" style="border:0"/> <f:setPropertyActionListener value="#{item}" target="#{MyBean.currentCar}" /> </a4j:commandLink> </rich:column> <rich:column> <!-- just some column for output --> <h:outputText value="#{item.engineDescription} </rich:column> </rich:datatable> <a4j:commandLink id="NEXT" value="NEXT CAR" action="#{MyBean.nextCar()}" /> <h:outputText value="#{MyBean.currentCar.engineDescription}" />
HTH -
5. Re: rich:datatable - how to get rows
zelenka Aug 4, 2009 5:15 AM (in response to zelenka)"JohnDoe123" wrote:
You don't need to write a whole custom DataModel.
Construct your Bean like this:
Thanks, but I don't need one particular row. I need all rows viewed which may be filtered via filterBy feature. -
6. Re: rich:datatable - how to get rows
zelenka Aug 11, 2009 4:56 AM (in response to zelenka)The solution is very simple. Just to use HtmlDataTable and iterate through rows.
for (int i = 0; i < htmlDataTable.getRowCount(); i++) {
htmlDataTable.setRowIndex(i);
Car c = (Car) htmlDataTable.getRowData();
....
}