You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Arnold Preg <ap...@mailbox.hu> on 2009/11/17 10:01:51 UTC

[Trinidad] Trinidad, Facelets, multiple forms

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.



Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
Hi Arnold,

I don't see why a solution with request parameters is more elegant than
using a JSF/Spring managed bean?

Best regards,
Bart

On Fri, Nov 20, 2009 at 08:21, Arnold Preg <ap...@mailbox.hu> wrote:

> Hi Bart,
>
> I asked it already in the spring forum but nobody answered. I read the
> spring reference already but I think it's not particular and I did not see
> example for this problem in the example program neither. There is a
> requestParameters EL variable to reach the request parameters as I know, but
> the problem is I can't send an appropriate parameter.
> I will looking for solution in this <
> http://www.apress.com/book/view/9781430216247> book too.
> The scoped bean thing (Spring call it Spring Managed Bean) could works like
> a charm just like in plain JSF solutions, but I hoped there is an elegant
> way to handle this like the f:param in commandLink.
> Thank you for your help.
>
>
>
> On 2009.11.19. 10:32, Bart Kummel wrote:
>
>> Hi Arnold,
>>
>> I'm afraid I can't help you with the parameter sending problem. I think
>> you
>> should read the Spring WebFlow documentation. They must have implemented
>> an
>> elegant way to handle parameters. I think you should focus on setting a
>> value on a scope or in a bean that is on a scope. That way JSF and/or SWF
>> will do the hard parameter encoding/decoding for you. Generally speaking,
>> with JSF, you should be messing around with GET or POST parameters. I
>> can't
>> imaging SWF changes this. But as said, I don't know anything about SWF.
>> Perhaps you should ask this question on an SWF related mailing list or
>> forum.
>>
>> Composite Component: I think that is an elegant way to implement it, as I
>> said. Remember to not use any trh tag in your composite component. What
>> you
>> want can be achieved by using standard components, like outputText,
>> various
>> panelXyz variants, etc. In your main page you can do the iteration. You
>> could use<tr:iterator>, but with Facelets, it is also possible to use JSTL
>> iteration.
>>
>> Best regards,
>> Bart
>>
>> On Wed, Nov 18, 2009 at 20:06, Arnold Preg<ap...@mailbox.hu>  wrote:
>>
>>
>>
>>> I accept that making a composite component cleans the code etc. But I
>>> still
>>> have to iterate over the collection of books somehow, e.g. with
>>> tr:iterator,
>>> right?
>>> And I don't know how does it solve the parameter sending problem.
>>> With tr:inputHidden the POST parameters looks like this:
>>>
>>>  _noJavaScript    false
>>> *j_id33:0:j_id36:selectedBookId    1
>>> j_id33:1:j_id36:selectedBookId    2
>>> j_id33:2:j_id36:selectedBookId    3
>>> j_id33:3:j_id36:selectedBookId    4 *
>>> javax.faces.ViewState    H4sIAAAAAAAA...
>>> org.apache.myfaces.trinidad.faces.FORM    j_id30
>>> source    j_id33:0:j_id36:j_id41
>>>
>>> The point is the parameter's name is *"j_id33:0:j_id36:selectedBookId"
>>> *and
>>> so on. So, I could reference it on this name only in the flow definition,
>>> but of course it's not good. I need one form for one hidden field.
>>>
>>>
>>> On 2009.11.18. 11:51, Bart Kummel wrote:
>>>
>>>
>>>
>>>> Okay, now I get what you want. Good idea to post an image!
>>>>
>>>> If I were you, I would craete a Facelets Composition Component to render
>>>> a
>>>> single book's details (image, title, etc.) Inside that Composition
>>>> Component
>>>> you could use various Trinidad components to render the image, the
>>>> price,
>>>> the link, etc. (Use Google to find more info on Facelets Composition
>>>> Components.)
>>>>
>>>> Then you could use e.g. a<tr:panelGroupLayout>   or a<h:panelGrid>   or
>>>> something like that to distribute the items over a page as desired.
>>>>
>>>> As for passing on the selected book ID, have you tried using
>>>> <tr:inputHidden>?
>>>>
>>>> Best regards,
>>>> Bart
>>>>
>>>> On Wed, Nov 18, 2009 at 11:20, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> If I can reach this<http://i48.tinypic.com/2q207ib.png>(
>>>>> http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes.
>>>>> (In
>>>>> essence I don't need column headers, pagination bar, radiobuttons etc.
>>>>> Just
>>>>> the layout and collection handling function I need from tr:table in
>>>>> this
>>>>> case.)
>>>>> I think SWF can handle POST and GET parameters equally.
>>>>>
>>>>>
>>>>>
>>>>> On 2009.11.18. 10:33, Bart Kummel wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> If you only want to change the appearance, you should definitely take
>>>>>> a
>>>>>> look
>>>>>> at Trinidad's skinning
>>>>>> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
>>>>>>
>>>>>> You can change the appearance of every Trinidad component this way,
>>>>>> while
>>>>>> keeping the functionality. Is that what you're looking for?
>>>>>>
>>>>>> As for you other question: what type of parameters does SWF expect?
>>>>>> POST
>>>>>> or
>>>>>> GET?
>>>>>>
>>>>>> Best regards,
>>>>>> Bart
>>>>>>
>>>>>> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>
>>>>>>  wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have to use Trinidad components, and minimalize the use of manual
>>>>>>>  HTML
>>>>>>> or js codes. I do not like to use trh: components, but the tr:table
>>>>>>> appearance has not been being suitable and  I did not want to write
>>>>>>> own
>>>>>>> component because I thought the tr:table and iterate will do the work
>>>>>>>  and
>>>>>>> I never wrote an own component before yet, so this was left.
>>>>>>> Although,
>>>>>>> as
>>>>>>> I
>>>>>>> see the own component could be the best solution to reach the proper
>>>>>>> appearance. But one question is still here: How to send parameters
>>>>>>> with
>>>>>>> tr:commandButton to SWF correctly and easy? Thank you for your
>>>>>>> patience.
>>>>>>>
>>>>>>>
>>>>>>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I'm afraid I still don't understand exactly what you need. However,
>>>>>>>> I
>>>>>>>> still
>>>>>>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>>>>>>> (Should you need *some* HTML for layout of your page, with Facelets
>>>>>>>> you
>>>>>>>> can
>>>>>>>> use HTML in your Facelet, so you don't need any<trh:...>     tag for
>>>>>>>> that
>>>>>>>> anymore.)
>>>>>>>>
>>>>>>>> If you want to use JSF, you should use JSF components that do the
>>>>>>>> hard
>>>>>>>> work
>>>>>>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries
>>>>>>>> or
>>>>>>>> other
>>>>>>>> component libraries for a component that suits your needs. If
>>>>>>>> nothing
>>>>>>>> can
>>>>>>>> be
>>>>>>>> found, you can create your own JSF component. If you prefer to be
>>>>>>>> super
>>>>>>>> flexible in the HTML output, you should perhaps consider a framework
>>>>>>>> that
>>>>>>>> isn't component based, like JSF.
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Bart
>>>>>>>>
>>>>>>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>
>>>>>>>>  wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> 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<ap...@mailbox.hu>
>>>>>>>>>>  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.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd
>>>>>>>>> like
>>>>>>>>> to
>>>>>>>>> create something you can see on amazon. There are book's pictures 3
>>>>>>>>> in
>>>>>>>>> a
>>>>>>>>> row, you can click on them to see details. I'd like to make a
>>>>>>>>> category
>>>>>>>>> panel
>>>>>>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>>>>>>> topic.
>>>>>>>>> If I can reach that look easily with tr:table I'll use that for
>>>>>>>>> this,
>>>>>>>>> but
>>>>>>>>> I
>>>>>>>>> think the problem will come out again in an other scenario. Namely
>>>>>>>>> how
>>>>>>>>> to
>>>>>>>>> send parameters with tr:commandButton. I think a hidden input filed
>>>>>>>>> would
>>>>>>>>> be
>>>>>>>>> great for this, but in a separate form or something. Of course with
>>>>>>>>> an
>>>>>>>>> action listener in a backing bean all of my problems would fly
>>>>>>>>> away,
>>>>>>>>> but
>>>>>>>>> what is the purpose of SWF than?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Arnold Preg <ap...@mailbox.hu>.
Hi Bart,

I asked it already in the spring forum but nobody answered. I read the 
spring reference already but I think it's not particular and I did not 
see example for this problem in the example program neither. There is a 
requestParameters EL variable to reach the request parameters as I know, 
but the problem is I can't send an appropriate parameter.
I will looking for solution in this 
<http://www.apress.com/book/view/9781430216247> book too.
The scoped bean thing (Spring call it Spring Managed Bean) could works 
like a charm just like in plain JSF solutions, but I hoped there is an 
elegant way to handle this like the f:param in commandLink.
Thank you for your help.


On 2009.11.19. 10:32, Bart Kummel wrote:
> Hi Arnold,
>
> I'm afraid I can't help you with the parameter sending problem. I think you
> should read the Spring WebFlow documentation. They must have implemented an
> elegant way to handle parameters. I think you should focus on setting a
> value on a scope or in a bean that is on a scope. That way JSF and/or SWF
> will do the hard parameter encoding/decoding for you. Generally speaking,
> with JSF, you should be messing around with GET or POST parameters. I can't
> imaging SWF changes this. But as said, I don't know anything about SWF.
> Perhaps you should ask this question on an SWF related mailing list or
> forum.
>
> Composite Component: I think that is an elegant way to implement it, as I
> said. Remember to not use any trh tag in your composite component. What you
> want can be achieved by using standard components, like outputText, various
> panelXyz variants, etc. In your main page you can do the iteration. You
> could use<tr:iterator>, but with Facelets, it is also possible to use JSTL
> iteration.
>
> Best regards,
> Bart
>
> On Wed, Nov 18, 2009 at 20:06, Arnold Preg<ap...@mailbox.hu>  wrote:
>
>    
>> I accept that making a composite component cleans the code etc. But I still
>> have to iterate over the collection of books somehow, e.g. with tr:iterator,
>> right?
>> And I don't know how does it solve the parameter sending problem.
>> With tr:inputHidden the POST parameters looks like this:
>>
>>   _noJavaScript    false
>> *j_id33:0:j_id36:selectedBookId    1
>> j_id33:1:j_id36:selectedBookId    2
>> j_id33:2:j_id36:selectedBookId    3
>> j_id33:3:j_id36:selectedBookId    4 *
>> javax.faces.ViewState    H4sIAAAAAAAA...
>> org.apache.myfaces.trinidad.faces.FORM    j_id30
>> source    j_id33:0:j_id36:j_id41
>>
>> The point is the parameter's name is *"j_id33:0:j_id36:selectedBookId" *and
>> so on. So, I could reference it on this name only in the flow definition,
>> but of course it's not good. I need one form for one hidden field.
>>
>>
>> On 2009.11.18. 11:51, Bart Kummel wrote:
>>
>>      
>>> Okay, now I get what you want. Good idea to post an image!
>>>
>>> If I were you, I would craete a Facelets Composition Component to render a
>>> single book's details (image, title, etc.) Inside that Composition
>>> Component
>>> you could use various Trinidad components to render the image, the price,
>>> the link, etc. (Use Google to find more info on Facelets Composition
>>> Components.)
>>>
>>> Then you could use e.g. a<tr:panelGroupLayout>   or a<h:panelGrid>   or
>>> something like that to distribute the items over a page as desired.
>>>
>>> As for passing on the selected book ID, have you tried using
>>> <tr:inputHidden>?
>>>
>>> Best regards,
>>> Bart
>>>
>>> On Wed, Nov 18, 2009 at 11:20, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>
>>>
>>>
>>>        
>>>> Hi,
>>>>
>>>> If I can reach this<http://i48.tinypic.com/2q207ib.png>(
>>>> http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes. (In
>>>> essence I don't need column headers, pagination bar, radiobuttons etc.
>>>> Just
>>>> the layout and collection handling function I need from tr:table in this
>>>> case.)
>>>> I think SWF can handle POST and GET parameters equally.
>>>>
>>>>
>>>>
>>>> On 2009.11.18. 10:33, Bart Kummel wrote:
>>>>
>>>>
>>>>
>>>>          
>>>>> Hi,
>>>>>
>>>>> If you only want to change the appearance, you should definitely take a
>>>>> look
>>>>> at Trinidad's skinning
>>>>> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
>>>>>
>>>>> You can change the appearance of every Trinidad component this way,
>>>>> while
>>>>> keeping the functionality. Is that what you're looking for?
>>>>>
>>>>> As for you other question: what type of parameters does SWF expect? POST
>>>>> or
>>>>> GET?
>>>>>
>>>>> Best regards,
>>>>> Bart
>>>>>
>>>>> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>    wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>>>> Hi,
>>>>>>
>>>>>> I have to use Trinidad components, and minimalize the use of manual
>>>>>>   HTML
>>>>>> or js codes. I do not like to use trh: components, but the tr:table
>>>>>> appearance has not been being suitable and  I did not want to write own
>>>>>> component because I thought the tr:table and iterate will do the work
>>>>>>   and
>>>>>> I never wrote an own component before yet, so this was left. Although,
>>>>>> as
>>>>>> I
>>>>>> see the own component could be the best solution to reach the proper
>>>>>> appearance. But one question is still here: How to send parameters with
>>>>>> tr:commandButton to SWF correctly and easy? Thank you for your
>>>>>> patience.
>>>>>>
>>>>>>
>>>>>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm afraid I still don't understand exactly what you need. However, I
>>>>>>> still
>>>>>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>>>>>> (Should you need *some* HTML for layout of your page, with Facelets
>>>>>>> you
>>>>>>> can
>>>>>>> use HTML in your Facelet, so you don't need any<trh:...>     tag for
>>>>>>> that
>>>>>>> anymore.)
>>>>>>>
>>>>>>> If you want to use JSF, you should use JSF components that do the hard
>>>>>>> work
>>>>>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>>>>>>> other
>>>>>>> component libraries for a component that suits your needs. If nothing
>>>>>>> can
>>>>>>> be
>>>>>>> found, you can create your own JSF component. If you prefer to be
>>>>>>> super
>>>>>>> flexible in the HTML output, you should perhaps consider a framework
>>>>>>> that
>>>>>>> isn't component based, like JSF.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Bart
>>>>>>>
>>>>>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>
>>>>>>>   wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>>>> 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<ap...@mailbox.hu>
>>>>>>>>>   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.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd
>>>>>>>> like
>>>>>>>> to
>>>>>>>> create something you can see on amazon. There are book's pictures 3
>>>>>>>> in
>>>>>>>> a
>>>>>>>> row, you can click on them to see details. I'd like to make a
>>>>>>>> category
>>>>>>>> panel
>>>>>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>>>>>> topic.
>>>>>>>> If I can reach that look easily with tr:table I'll use that for this,
>>>>>>>> but
>>>>>>>> I
>>>>>>>> think the problem will come out again in an other scenario. Namely
>>>>>>>> how
>>>>>>>> to
>>>>>>>> send parameters with tr:commandButton. I think a hidden input filed
>>>>>>>> would
>>>>>>>> be
>>>>>>>> great for this, but in a separate form or something. Of course with
>>>>>>>> an
>>>>>>>> action listener in a backing bean all of my problems would fly away,
>>>>>>>> but
>>>>>>>> what is the purpose of SWF than?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>>
>>>>>>
>>>>>>              
>>>>>
>>>>>
>>>>>            
>>>>
>>>>
>>>>          
>>>
>>>        
>>
>>      
>    


Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
Hi Arnold,

I'm afraid I can't help you with the parameter sending problem. I think you
should read the Spring WebFlow documentation. They must have implemented an
elegant way to handle parameters. I think you should focus on setting a
value on a scope or in a bean that is on a scope. That way JSF and/or SWF
will do the hard parameter encoding/decoding for you. Generally speaking,
with JSF, you should be messing around with GET or POST parameters. I can't
imaging SWF changes this. But as said, I don't know anything about SWF.
Perhaps you should ask this question on an SWF related mailing list or
forum.

Composite Component: I think that is an elegant way to implement it, as I
said. Remember to not use any trh tag in your composite component. What you
want can be achieved by using standard components, like outputText, various
panelXyz variants, etc. In your main page you can do the iteration. You
could use <tr:iterator>, but with Facelets, it is also possible to use JSTL
iteration.

Best regards,
Bart

On Wed, Nov 18, 2009 at 20:06, Arnold Preg <ap...@mailbox.hu> wrote:

>
> I accept that making a composite component cleans the code etc. But I still
> have to iterate over the collection of books somehow, e.g. with tr:iterator,
> right?
> And I don't know how does it solve the parameter sending problem.
> With tr:inputHidden the POST parameters looks like this:
>
>  _noJavaScript    false
> *j_id33:0:j_id36:selectedBookId    1
> j_id33:1:j_id36:selectedBookId    2
> j_id33:2:j_id36:selectedBookId    3
> j_id33:3:j_id36:selectedBookId    4 *
> javax.faces.ViewState    H4sIAAAAAAAA...
> org.apache.myfaces.trinidad.faces.FORM    j_id30
> source    j_id33:0:j_id36:j_id41
>
> The point is the parameter's name is *"j_id33:0:j_id36:selectedBookId" *and
> so on. So, I could reference it on this name only in the flow definition,
> but of course it's not good. I need one form for one hidden field.
>
>
> On 2009.11.18. 11:51, Bart Kummel wrote:
>
>> Okay, now I get what you want. Good idea to post an image!
>>
>> If I were you, I would craete a Facelets Composition Component to render a
>> single book's details (image, title, etc.) Inside that Composition
>> Component
>> you could use various Trinidad components to render the image, the price,
>> the link, etc. (Use Google to find more info on Facelets Composition
>> Components.)
>>
>> Then you could use e.g. a<tr:panelGroupLayout>  or a<h:panelGrid>  or
>> something like that to distribute the items over a page as desired.
>>
>> As for passing on the selected book ID, have you tried using
>> <tr:inputHidden>?
>>
>> Best regards,
>> Bart
>>
>> On Wed, Nov 18, 2009 at 11:20, Arnold Preg<ap...@mailbox.hu>  wrote:
>>
>>
>>
>>> Hi,
>>>
>>> If I can reach this<http://i48.tinypic.com/2q207ib.png>(
>>> http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes. (In
>>> essence I don't need column headers, pagination bar, radiobuttons etc.
>>> Just
>>> the layout and collection handling function I need from tr:table in this
>>> case.)
>>> I think SWF can handle POST and GET parameters equally.
>>>
>>>
>>>
>>> On 2009.11.18. 10:33, Bart Kummel wrote:
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> If you only want to change the appearance, you should definitely take a
>>>> look
>>>> at Trinidad's skinning
>>>> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
>>>>
>>>> You can change the appearance of every Trinidad component this way,
>>>> while
>>>> keeping the functionality. Is that what you're looking for?
>>>>
>>>> As for you other question: what type of parameters does SWF expect? POST
>>>> or
>>>> GET?
>>>>
>>>> Best regards,
>>>> Bart
>>>>
>>>> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I have to use Trinidad components, and minimalize the use of manual
>>>>>  HTML
>>>>> or js codes. I do not like to use trh: components, but the tr:table
>>>>> appearance has not been being suitable and  I did not want to write own
>>>>> component because I thought the tr:table and iterate will do the work
>>>>>  and
>>>>> I never wrote an own component before yet, so this was left. Although,
>>>>> as
>>>>> I
>>>>> see the own component could be the best solution to reach the proper
>>>>> appearance. But one question is still here: How to send parameters with
>>>>> tr:commandButton to SWF correctly and easy? Thank you for your
>>>>> patience.
>>>>>
>>>>>
>>>>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I'm afraid I still don't understand exactly what you need. However, I
>>>>>> still
>>>>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>>>>> (Should you need *some* HTML for layout of your page, with Facelets
>>>>>> you
>>>>>> can
>>>>>> use HTML in your Facelet, so you don't need any<trh:...>    tag for
>>>>>> that
>>>>>> anymore.)
>>>>>>
>>>>>> If you want to use JSF, you should use JSF components that do the hard
>>>>>> work
>>>>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>>>>>> other
>>>>>> component libraries for a component that suits your needs. If nothing
>>>>>> can
>>>>>> be
>>>>>> found, you can create your own JSF component. If you prefer to be
>>>>>> super
>>>>>> flexible in the HTML output, you should perhaps consider a framework
>>>>>> that
>>>>>> isn't component based, like JSF.
>>>>>>
>>>>>> Best regards,
>>>>>> Bart
>>>>>>
>>>>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>
>>>>>>  wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> 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<ap...@mailbox.hu>
>>>>>>>>  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.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd
>>>>>>> like
>>>>>>> to
>>>>>>> create something you can see on amazon. There are book's pictures 3
>>>>>>> in
>>>>>>> a
>>>>>>> row, you can click on them to see details. I'd like to make a
>>>>>>> category
>>>>>>> panel
>>>>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>>>>> topic.
>>>>>>> If I can reach that look easily with tr:table I'll use that for this,
>>>>>>> but
>>>>>>> I
>>>>>>> think the problem will come out again in an other scenario. Namely
>>>>>>> how
>>>>>>> to
>>>>>>> send parameters with tr:commandButton. I think a hidden input filed
>>>>>>> would
>>>>>>> be
>>>>>>> great for this, but in a separate form or something. Of course with
>>>>>>> an
>>>>>>> action listener in a backing bean all of my problems would fly away,
>>>>>>> but
>>>>>>> what is the purpose of SWF than?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Arnold Preg <ap...@mailbox.hu>.
I accept that making a composite component cleans the code etc. But I 
still have to iterate over the collection of books somehow, e.g. with 
tr:iterator, right?
And I don't know how does it solve the parameter sending problem.
With tr:inputHidden the POST parameters looks like this:

  _noJavaScript    false
*j_id33:0:j_id36:selectedBookId    1
j_id33:1:j_id36:selectedBookId    2
j_id33:2:j_id36:selectedBookId    3
j_id33:3:j_id36:selectedBookId    4 *
javax.faces.ViewState    H4sIAAAAAAAA...
org.apache.myfaces.trinidad.faces.FORM    j_id30
source    j_id33:0:j_id36:j_id41

The point is the parameter's name is *"j_id33:0:j_id36:selectedBookId" 
*and so on. So, I could reference it on this name only in the flow 
definition, but of course it's not good. I need one form for one hidden 
field.

On 2009.11.18. 11:51, Bart Kummel wrote:
> Okay, now I get what you want. Good idea to post an image!
>
> If I were you, I would craete a Facelets Composition Component to render a
> single book's details (image, title, etc.) Inside that Composition Component
> you could use various Trinidad components to render the image, the price,
> the link, etc. (Use Google to find more info on Facelets Composition
> Components.)
>
> Then you could use e.g. a<tr:panelGroupLayout>  or a<h:panelGrid>  or
> something like that to distribute the items over a page as desired.
>
> As for passing on the selected book ID, have you tried using
> <tr:inputHidden>?
>
> Best regards,
> Bart
>
> On Wed, Nov 18, 2009 at 11:20, Arnold Preg<ap...@mailbox.hu>  wrote:
>
>    
>> Hi,
>>
>> If I can reach this<http://i48.tinypic.com/2q207ib.png>(
>> http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes. (In
>> essence I don't need column headers, pagination bar, radiobuttons etc. Just
>> the layout and collection handling function I need from tr:table in this
>> case.)
>> I think SWF can handle POST and GET parameters equally.
>>
>>
>>
>> On 2009.11.18. 10:33, Bart Kummel wrote:
>>
>>      
>>> Hi,
>>>
>>> If you only want to change the appearance, you should definitely take a
>>> look
>>> at Trinidad's skinning
>>> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
>>>
>>> You can change the appearance of every Trinidad component this way, while
>>> keeping the functionality. Is that what you're looking for?
>>>
>>> As for you other question: what type of parameters does SWF expect? POST
>>> or
>>> GET?
>>>
>>> Best regards,
>>> Bart
>>>
>>> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>
>>>
>>>
>>>        
>>>> Hi,
>>>>
>>>> I have to use Trinidad components, and minimalize the use of manual  HTML
>>>> or js codes. I do not like to use trh: components, but the tr:table
>>>> appearance has not been being suitable and  I did not want to write own
>>>> component because I thought the tr:table and iterate will do the work
>>>>   and
>>>> I never wrote an own component before yet, so this was left. Although, as
>>>> I
>>>> see the own component could be the best solution to reach the proper
>>>> appearance. But one question is still here: How to send parameters with
>>>> tr:commandButton to SWF correctly and easy? Thank you for your patience.
>>>>
>>>>
>>>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>>>
>>>>
>>>>
>>>>          
>>>>> Hi,
>>>>>
>>>>> I'm afraid I still don't understand exactly what you need. However, I
>>>>> still
>>>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>>>> (Should you need *some* HTML for layout of your page, with Facelets you
>>>>> can
>>>>> use HTML in your Facelet, so you don't need any<trh:...>    tag for that
>>>>> anymore.)
>>>>>
>>>>> If you want to use JSF, you should use JSF components that do the hard
>>>>> work
>>>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>>>>> other
>>>>> component libraries for a component that suits your needs. If nothing
>>>>> can
>>>>> be
>>>>> found, you can create your own JSF component. If you prefer to be super
>>>>> flexible in the HTML output, you should perhaps consider a framework
>>>>> that
>>>>> isn't component based, like JSF.
>>>>>
>>>>> Best regards,
>>>>> Bart
>>>>>
>>>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>    wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> 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<ap...@mailbox.hu>
>>>>>>>   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.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd
>>>>>> like
>>>>>> to
>>>>>> create something you can see on amazon. There are book's pictures 3 in
>>>>>> a
>>>>>> row, you can click on them to see details. I'd like to make a category
>>>>>> panel
>>>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>>>> topic.
>>>>>> If I can reach that look easily with tr:table I'll use that for this,
>>>>>> but
>>>>>> I
>>>>>> think the problem will come out again in an other scenario. Namely how
>>>>>> to
>>>>>> send parameters with tr:commandButton. I think a hidden input filed
>>>>>> would
>>>>>> be
>>>>>> great for this, but in a separate form or something. Of course with an
>>>>>> action listener in a backing bean all of my problems would fly away,
>>>>>> but
>>>>>> what is the purpose of SWF than?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>
>>>>>
>>>>>            
>>>>
>>>>          
>>>
>>>        
>>
>>      
>    


Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
Okay, now I get what you want. Good idea to post an image!

If I were you, I would craete a Facelets Composition Component to render a
single book's details (image, title, etc.) Inside that Composition Component
you could use various Trinidad components to render the image, the price,
the link, etc. (Use Google to find more info on Facelets Composition
Components.)

Then you could use e.g. a <tr:panelGroupLayout> or a <h:panelGrid> or
something like that to distribute the items over a page as desired.

As for passing on the selected book ID, have you tried using
<tr:inputHidden>?

Best regards,
Bart

On Wed, Nov 18, 2009 at 11:20, Arnold Preg <ap...@mailbox.hu> wrote:

> Hi,
>
> If I can reach this <http://i48.tinypic.com/2q207ib.png>(
> http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes. (In
> essence I don't need column headers, pagination bar, radiobuttons etc. Just
> the layout and collection handling function I need from tr:table in this
> case.)
> I think SWF can handle POST and GET parameters equally.
>
>
>
> On 2009.11.18. 10:33, Bart Kummel wrote:
>
>> Hi,
>>
>> If you only want to change the appearance, you should definitely take a
>> look
>> at Trinidad's skinning
>> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
>>
>> You can change the appearance of every Trinidad component this way, while
>> keeping the functionality. Is that what you're looking for?
>>
>> As for you other question: what type of parameters does SWF expect? POST
>> or
>> GET?
>>
>> Best regards,
>> Bart
>>
>> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>  wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I have to use Trinidad components, and minimalize the use of manual  HTML
>>> or js codes. I do not like to use trh: components, but the tr:table
>>> appearance has not been being suitable and  I did not want to write own
>>> component because I thought the tr:table and iterate will do the work
>>>  and
>>> I never wrote an own component before yet, so this was left. Although, as
>>> I
>>> see the own component could be the best solution to reach the proper
>>> appearance. But one question is still here: How to send parameters with
>>> tr:commandButton to SWF correctly and easy? Thank you for your patience.
>>>
>>>
>>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I'm afraid I still don't understand exactly what you need. However, I
>>>> still
>>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>>> (Should you need *some* HTML for layout of your page, with Facelets you
>>>> can
>>>> use HTML in your Facelet, so you don't need any<trh:...>   tag for that
>>>> anymore.)
>>>>
>>>> If you want to use JSF, you should use JSF components that do the hard
>>>> work
>>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>>>> other
>>>> component libraries for a component that suits your needs. If nothing
>>>> can
>>>> be
>>>> found, you can create your own JSF component. If you prefer to be super
>>>> flexible in the HTML output, you should perhaps consider a framework
>>>> that
>>>> isn't component based, like JSF.
>>>>
>>>> Best regards,
>>>> Bart
>>>>
>>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> 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<ap...@mailbox.hu>
>>>>>>  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.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd
>>>>> like
>>>>> to
>>>>> create something you can see on amazon. There are book's pictures 3 in
>>>>> a
>>>>> row, you can click on them to see details. I'd like to make a category
>>>>> panel
>>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>>> topic.
>>>>> If I can reach that look easily with tr:table I'll use that for this,
>>>>> but
>>>>> I
>>>>> think the problem will come out again in an other scenario. Namely how
>>>>> to
>>>>> send parameters with tr:commandButton. I think a hidden input filed
>>>>> would
>>>>> be
>>>>> great for this, but in a separate form or something. Of course with an
>>>>> action listener in a backing bean all of my problems would fly away,
>>>>> but
>>>>> what is the purpose of SWF than?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Arnold Preg <ap...@mailbox.hu>.
Hi,

If I can reach this <http://i48.tinypic.com/2q207ib.png>( 
http://i48.tinypic.com/2q207ib.png ) look with skinning,  then yes. (In 
essence I don't need column headers, pagination bar, radiobuttons etc. 
Just the layout and collection handling function I need from tr:table in 
this case.)
I think SWF can handle POST and GET parameters equally.


On 2009.11.18. 10:33, Bart Kummel wrote:
> Hi,
>
> If you only want to change the appearance, you should definitely take a look
> at Trinidad's skinning
> features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
> You can change the appearance of every Trinidad component this way, while
> keeping the functionality. Is that what you're looking for?
>
> As for you other question: what type of parameters does SWF expect? POST or
> GET?
>
> Best regards,
> Bart
>
> On Wed, Nov 18, 2009 at 09:35, Arnold Preg<ap...@mailbox.hu>  wrote:
>
>    
>> Hi,
>>
>> I have to use Trinidad components, and minimalize the use of manual  HTML
>> or js codes. I do not like to use trh: components, but the tr:table
>> appearance has not been being suitable and  I did not want to write own
>> component because I thought the tr:table and iterate will do the work  and
>> I never wrote an own component before yet, so this was left. Although, as I
>> see the own component could be the best solution to reach the proper
>> appearance. But one question is still here: How to send parameters with
>> tr:commandButton to SWF correctly and easy? Thank you for your patience.
>>
>>
>> On 2009.11.18. 8:54, Bart Kummel wrote:
>>
>>      
>>> Hi,
>>>
>>> I'm afraid I still don't understand exactly what you need. However, I
>>> still
>>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>>> (Should you need *some* HTML for layout of your page, with Facelets you
>>> can
>>> use HTML in your Facelet, so you don't need any<trh:...>   tag for that
>>> anymore.)
>>>
>>> If you want to use JSF, you should use JSF components that do the hard
>>> work
>>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>>> other
>>> component libraries for a component that suits your needs. If nothing can
>>> be
>>> found, you can create your own JSF component. If you prefer to be super
>>> flexible in the HTML output, you should perhaps consider a framework that
>>> isn't component based, like JSF.
>>>
>>> Best regards,
>>> Bart
>>>
>>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>   wrote:
>>>
>>>
>>>
>>>        
>>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>>
>>>>
>>>>
>>>>          
>>>>> 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<ap...@mailbox.hu>    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.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>
>>>>>
>>>>>            
>>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd like
>>>> to
>>>> create something you can see on amazon. There are book's pictures 3 in a
>>>> row, you can click on them to see details. I'd like to make a category
>>>> panel
>>>> and cart  panel you can see on that portal, but it's maybe an other
>>>> topic.
>>>> If I can reach that look easily with tr:table I'll use that for this, but
>>>> I
>>>> think the problem will come out again in an other scenario. Namely how to
>>>> send parameters with tr:commandButton. I think a hidden input filed would
>>>> be
>>>> great for this, but in a separate form or something. Of course with an
>>>> action listener in a backing bean all of my problems would fly away, but
>>>> what is the purpose of SWF than?
>>>>
>>>>
>>>>
>>>>          
>>>
>>>        
>>      
>    


Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
Hi,

If you only want to change the appearance, you should definitely take a look
at Trinidad's skinning
features<http://myfaces.apache.org/trinidad/devguide/skinning.html>.
You can change the appearance of every Trinidad component this way, while
keeping the functionality. Is that what you're looking for?

As for you other question: what type of parameters does SWF expect? POST or
GET?

Best regards,
Bart

On Wed, Nov 18, 2009 at 09:35, Arnold Preg <ap...@mailbox.hu> wrote:

> Hi,
>
> I have to use Trinidad components, and minimalize the use of manual  HTML
> or js codes. I do not like to use trh: components, but the tr:table
> appearance has not been being suitable and  I did not want to write own
> component because I thought the tr:table and iterate will do the work  and
> I never wrote an own component before yet, so this was left. Although, as I
> see the own component could be the best solution to reach the proper
> appearance. But one question is still here: How to send parameters with
> tr:commandButton to SWF correctly and easy? Thank you for your patience.
>
>
> On 2009.11.18. 8:54, Bart Kummel wrote:
>
>> Hi,
>>
>> I'm afraid I still don't understand exactly what you need. However, I
>> still
>> think you shouldn't use the approach with the<trh:tableLayout>, etc.
>> (Should you need *some* HTML for layout of your page, with Facelets you
>> can
>> use HTML in your Facelet, so you don't need any<trh:...>  tag for that
>> anymore.)
>>
>> If you want to use JSF, you should use JSF components that do the hard
>> work
>> for you. You can search the Trinidad, Tomahawk and Tobago libraries or
>> other
>> component libraries for a component that suits your needs. If nothing can
>> be
>> found, you can create your own JSF component. If you prefer to be super
>> flexible in the HTML output, you should perhaps consider a framework that
>> isn't component based, like JSF.
>>
>> Best regards,
>> Bart
>>
>> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>  wrote:
>>
>>
>>
>>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>>
>>>
>>>
>>>> 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<ap...@mailbox.hu>   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.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> Thank you for your reply. I'm afraid you have misunderstood me. I'd like
>>> to
>>> create something you can see on amazon. There are book's pictures 3 in a
>>> row, you can click on them to see details. I'd like to make a category
>>> panel
>>> and cart  panel you can see on that portal, but it's maybe an other
>>> topic.
>>> If I can reach that look easily with tr:table I'll use that for this, but
>>> I
>>> think the problem will come out again in an other scenario. Namely how to
>>> send parameters with tr:commandButton. I think a hidden input filed would
>>> be
>>> great for this, but in a separate form or something. Of course with an
>>> action listener in a backing bean all of my problems would fly away, but
>>> what is the purpose of SWF than?
>>>
>>>
>>>
>>
>>
>

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Arnold Preg <ap...@mailbox.hu>.
Hi,

I have to use Trinidad components, and minimalize the use of manual  
HTML or js codes. I do not like to use trh: components, but the tr:table 
appearance has not been being suitable and  I did not want to write own 
component because I thought the tr:table and iterate will do the work  and
I never wrote an own component before yet, so this was left. Although, 
as I see the own component could be the best solution to reach the 
proper appearance. But one question is still here: How to send 
parameters with tr:commandButton to SWF correctly and easy? Thank you 
for your patience.

On 2009.11.18. 8:54, Bart Kummel wrote:
> Hi,
>
> I'm afraid I still don't understand exactly what you need. However, I still
> think you shouldn't use the approach with the<trh:tableLayout>, etc.
> (Should you need *some* HTML for layout of your page, with Facelets you can
> use HTML in your Facelet, so you don't need any<trh:...>  tag for that
> anymore.)
>
> If you want to use JSF, you should use JSF components that do the hard work
> for you. You can search the Trinidad, Tomahawk and Tobago libraries or other
> component libraries for a component that suits your needs. If nothing can be
> found, you can create your own JSF component. If you prefer to be super
> flexible in the HTML output, you should perhaps consider a framework that
> isn't component based, like JSF.
>
> Best regards,
> Bart
>
> On Tue, Nov 17, 2009 at 20:28, Arnold Preg<ap...@mailbox.hu>  wrote:
>
>    
>> On 2009.11.17. 13:50, Bart Kummel wrote:
>>
>>      
>>> 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<ap...@mailbox.hu>   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.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>          
>>>
>>>        
>> Thank you for your reply. I'm afraid you have misunderstood me. I'd like to
>> create something you can see on amazon. There are book's pictures 3 in a
>> row, you can click on them to see details. I'd like to make a category panel
>> and cart  panel you can see on that portal, but it's maybe an other topic.
>> If I can reach that look easily with tr:table I'll use that for this, but I
>> think the problem will come out again in an other scenario. Namely how to
>> send parameters with tr:commandButton. I think a hidden input filed would be
>> great for this, but in a separate form or something. Of course with an
>> action listener in a backing bean all of my problems would fly away, but
>> what is the purpose of SWF than?
>>
>>      
>    

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
Hi,

I'm afraid I still don't understand exactly what you need. However, I still
think you shouldn't use the approach with the <trh:tableLayout>, etc.
(Should you need *some* HTML for layout of your page, with Facelets you can
use HTML in your Facelet, so you don't need any <trh:...> tag for that
anymore.)

If you want to use JSF, you should use JSF components that do the hard work
for you. You can search the Trinidad, Tomahawk and Tobago libraries or other
component libraries for a component that suits your needs. If nothing can be
found, you can create your own JSF component. If you prefer to be super
flexible in the HTML output, you should perhaps consider a framework that
isn't component based, like JSF.

Best regards,
Bart

On Tue, Nov 17, 2009 at 20:28, Arnold Preg <ap...@mailbox.hu> wrote:

> On 2009.11.17. 13:50, Bart Kummel wrote:
>
>> 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<ap...@mailbox.hu>  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.
>>>
>>>
>>>
>>>
>>>
>>
>>
> Thank you for your reply. I'm afraid you have misunderstood me. I'd like to
> create something you can see on amazon. There are book's pictures 3 in a
> row, you can click on them to see details. I'd like to make a category panel
> and cart  panel you can see on that portal, but it's maybe an other topic.
> If I can reach that look easily with tr:table I'll use that for this, but I
> think the problem will come out again in an other scenario. Namely how to
> send parameters with tr:commandButton. I think a hidden input filed would be
> great for this, but in a separate form or something. Of course with an
> action listener in a backing bean all of my problems would fly away, but
> what is the purpose of SWF than?
>

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Arnold Preg <ap...@mailbox.hu>.
On 2009.11.17. 13:50, Bart Kummel wrote:
> 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<ap...@mailbox.hu>  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.
>>
>>
>>
>>      
>    
Thank you for your reply. I'm afraid you have misunderstood me. I'd like 
to create something you can see on amazon. There are book's pictures 3 
in a row, you can click on them to see details. I'd like to make a 
category panel and cart  panel you can see on that portal, but it's 
maybe an other topic.
If I can reach that look easily with tr:table I'll use that for this, 
but I think the problem will come out again in an other scenario. Namely 
how to send parameters with tr:commandButton. I think a hidden input 
filed would be great for this, but in a separate form or something. Of 
course with an action listener in a backing bean all of my problems 
would fly away, but what is the purpose of SWF than?

Re: [Trinidad] Trinidad, Facelets, multiple forms

Posted by Bart Kummel <bk...@gmail.com>.
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 <ap...@mailbox.hu> 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.
>
>
>