Hi, I don't have any experience with Spring WebFlow, so I can't help you on that part. But when it comes to your other question, as I understand you right, you want to spread your list of books over multiple pages if the number of books exceeds a certain value, right?
This is simple to achieve, but you shouldn't use <trh:tableLayout>. You should use <tr:table> instead. <tr:table> will do all hard work for you, including the pagination of your data. Please read the documentation of <tr:table><http://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_table.html>first. And regarding your <tr:subform>: you are right that you don't use it properly. In this case, it can be left out, you don't need it here. One last remark: as I look at your code, I get the impression that you don't get the idea of JavaServer Faces. The idea is to use components that render a user interface for you. Those components perform all the hard work for you. Generally speaking, you shouldn't be fiddling with repetition in any JSF page definition. In this example, if you use a <tr:table>, the only thing you have to do is tell the table where the collection is that you want to show. The table component will do all the hard work, including the repetition and pagination. I hope this helps. Good luck! Best regards, Bart Kummel On Tue, Nov 17, 2009 at 10:01, Arnold Preg <[email protected]> wrote: > Hi, > > I'm newbie, so sorry for stupid questions. I'm trying to use Facelets > 1.1.14. SWF 2.0.8. Spring 2.5.6. Apache Trinidad 1.2.12. JBoss EL 2.0.1. > and Hibernate JPA imp. but I think it's not relevant now. My English not too > good let the code snippets speak because of this rather. > > borderLayout.xhtml > > <tr:document xmlns:ui="http://java.sun.com/jsf/facelets" > xmlns:h="http://java.sun.com/jsf/html" > xmlns:f="http://java.sun.com/jsf/core" > xmlns:trh="http://myfaces.apache.org/trinidad/html" > xmlns:tr="http://myfaces.apache.org/trinidad" title="#{pageTitle}"> > <tr:form id="mainForm"> > <tr:panelBorderLayout> > <f:facet name="top"> > <ui:include src="searchbar.xhtml" /> > </f:facet> > <ui:insert name="pageContent" /> > </tr:panelBorderLayout> > </tr:form> > <ui:debug /> > </tr:document> > > page.xhtml > > <ui:composition xmlns="http://www.w3.org/1999/xhtml" > xmlns:h="http://java.sun.com/jsf/html" > xmlns:f="http://java.sun.com/jsf/core" > xmlns:ui="http://java.sun.com/jsf/facelets" > xmlns:tr="http://myfaces.apache.org/trinidad" > xmlns:trh="http://myfaces.apache.org/trinidad/html" > xmlns:test="http://www.my.net/some/arbitrary/namespace" > template="/WEB-INF/layouts/borderLayout.xhtml"> > > <ui:param name="pageTitle" value="Home" /> > <ui:define name="pageContent"> > <trh:tableLayout width="75%" borderWidth="0" cellSpacing="10" > halign="center"> > <trh:rowLayout> > <ui:repeat var="book" value="#{bestsellers}" offset="0" size="3"> > <!-- <tr:iterator var="book" first="0" rows="4" value="#{bestsellers}"> --> > <trh:cellFormat valign="bottom"> > <tr:commandLink action="selectBook2SeeDetails" > text="#{book.title}"> > <f:param name="selectedBookId" value="#{book.bookId}" /> > </tr:commandLink> > > <!-- Probably I don't use the subform properly --> > * <tr:subform> > <tr:commandButton text="Add to cart" action="add2Cart"/> > <input type="hidden" name="selectedBookId" value="#{book.bookId}" /> > </tr:subform>* > > </trh:cellFormat> > </ui:repeat> > <!-- </tr:iterator> --> > </trh:rowLayout> > </trh:tableLayout> > </ui:define> > </ui:composition> > > flow.xml > > <?xml version="1.0" encoding="UTF-8"?> > <flow xmlns="http://www.springframework.org/schema/webflow" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.springframework.org/schema/webflow > http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> > > <persistence-context /> > <var name="cart" class="bookstore.domain.Cart" /> > <view-state id="home"> > <on-render> > <evaluate expression="catalogService.getAllBooks()" > result="viewScope.bestsellers"></evaluate> > </on-render> > <transition on="selectBook2SeeDetails" to="reviewBookDetails"> > <set name="flowScope.selectedBook" > > value="catalogService.getBookById(requestParameters.selectedBookId)" /> > </transition> > </view-state> > > <global-transitions> > <transition on="add2Cart"> > <evaluate > <!-- Maybe it would be better to use the bestsellers list of Book entities > but then I guess the place of code that should iterate over the list to find > the Book with the appropriate id would be good in a custom Action "bean" > (correct me if I'm wrong) and I don't want to complicate this sample with > that too. > > > expression="cart.addItem(catalogService.getBookById(requestParameters.selectedBookId))"> > </evaluate> > </transition> > </global-transitions> > </flow> > > When I click on the "Add to cart" button the post request will be something > like this: > > _noJavaScript false > j_id5 > j_id17:rangeStart 0 > javax.faces.ViewState H4sIAAAAAAAAA...... > org.apache.myfaces.trinidad.faces.FORM mainForm > *selectedBookId 1 > selectedBookId 2 > selectedBookId 3 > selectedBookId 4 * > source j_id31:0:j_id37:j_id38 > state > value > > As it seems it's send a "String array" of selectedBookId . I'd like to send > just the appropriate id of course. How could I reach that? On top of this > I'd like to make more rows dynamically. You know 4 books in the first row > than another 4 one etc, but I don't know how to write the repeat code to > make this. Although, the main problem is the first one. > > >

