You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Gilberto <gi...@gmail.com> on 2011/08/22 14:29:09 UTC

Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Hi,

After read this[1] post about how to benchmark the response time and
the rendering engine of some component based frameworks, I felt
comfortable to try it with Apache Click. The example used by the
author's post uses a panel or other artifact provided by the framework
to create a reusable component.
This one[2] is my first try and I've used the filterPanel[3] as
sample, but I think I've missed something on the model setup because
the the new panel (ProductPanel) has not been rendered.

Can someone take time to look at in the source and provide some
feedback before I send it to the post's author to publish it?


Regards,

[1] http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/
[2] http://dl.dropbox.com/u/9093640/clickapp.zip
[3] http://click.avoka.com/click-examples/panel/filter-panel-demo.htm

Gilberto Caetano de Andrade
www.secad.to.gov.br
blog.gilbertoca.com

Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by Gilberto <gi...@gmail.com>.
Hi, Bob!

On Mon, Aug 22, 2011 at 3:00 PM, Bob Schellink <sa...@gmail.com> wrote:
> On 2011/08/22 19:44 PM, gilbertoca wrote:
>>>
>>> $productPanel
>>> <table>
>>>     #foreach( $p in $products )
>>>     <tr>
>>>         <td>$productPanel.product($p)</td>
>
> I'm not sure what you are trying to achieve with the above snippet?
>

I was showing that $productPanel works (while using just one Product).

> You are calling panel.setProduct(p)?
And here was showing that if I use one list of product I couldn't make
it work. In this case I use a for loop to show the product in the
list: $productPanel.product($p)

Regards,

Giberto

Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by Bob Schellink <sa...@gmail.com>.
On 2011/08/22 19:44 PM, gilbertoca wrote:
>> $productPanel
>> <table>
>>      #foreach( $p in $products )
>>      <tr>
>>          <td>$productPanel.product($p)</td>
I'm not sure what you are trying to achieve with the above snippet?

You are calling panel.setProduct(p)?

This call is made *after* the panel rendered via $productPanel.

setProduct adds the product to the model again? But the products are already made available to Velocity.

Bob

Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by gilbertoca <gi...@gmail.com>.
For some reason the panel isn't rendering when using it in velocity way:


> Products listing
> 
>  New Product, 5
> $productPanel.product($p)	 1001 , 1000 , 1003 , 1004 , 1002
> $productPanel.product($p)	 1001 , 1000 , 1003 , 1004 , 1002
> 

The ProductPanel source:


> /**
>  * Provides a custom product Panel.
>  */
> public class ProductPanel extends Panel {
> 
>     private static final long serialVersionUID = 1L;
> 
>     public ProductPanel(String name, Product p) {
>         setName(name);
>         getModel().put("product", p);
>     }
>     public ProductPanel(String name) { setName(name);}
>     public void setProduct(Product p) {getModel().put("product", p);}
>     public Product getProduct() {return (Product)
> getModel().get("product");
>     }
> }
> 
The ProductPanel template:


> <div class="product">
>      3.jpg 
>     $product.name, $product.price
> </div>
> 


In the ProductsPage we are using it:


>     // Constructor
> ------------------------------------------------------------
>     public ProductsPage() {
>         //Page's title
>         super("Products listing");
>         //add the custom product panel to the page
>         addControl(productPanel);
>         productPanel.setProduct(new Product("New Product", 5, "A great
> product"));        
>         
>         //add the product's list to the page model
>         addModel("products", Service.getProducts());
>     }
> 

The products htm file:


> $productPanel
> <table>
>     #foreach( $p in $products )
>     <tr>
>         <td>$productPanel.product($p)</td>
>         <td class="categories">
>             #foreach( $c in $p.categories ) 
>             #if ($foreach.count>1),#end $c.name#end
>         </td>
>     </tr>
>     #end
> </table>
> 

Can't I use a component in Velocity template?

Regards,

Gilberto


gilbertoca wrote:
> 
> Hi,
> 
> After read this[1] post about how to benchmark the response time and
> the rendering engine of some component based frameworks, I felt
> comfortable to try it with Apache Click. The example used by the
> author's post uses a panel or other artifact provided by the framework
> to create a reusable component.
> This one[2] is my first try and I've used the filterPanel[3] as
> sample, but I think I've missed something on the model setup because
> the the new panel (ProductPanel) has not been rendered.
> 
> Can someone take time to look at in the source and provide some
> feedback before I send it to the post's author to publish it?
> 
> 
> Regards,
> 
> [1] http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/
> [2] http://dl.dropbox.com/u/9093640/clickapp.zip
> [3] http://click.avoka.com/click-examples/panel/filter-panel-demo.htm
> 
> Gilberto Caetano de Andrade
> www.secad.to.gov.br
> blog.gilbertoca.com
> 


--
View this message in context: http://click.1134972.n2.nabble.com/Rails-Wicket-Grails-Play-Tapestry-Lift-JSP-Context-and-Click-tp6711340p6712533.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by Gilberto <gi...@gmail.com>.
The benchmark has some requisites[1]:
<quote>
Framework features

For each framework, the page needs to use the following framework features:
-rendering of a list of products, each rendered as a custom component
so that the layout of each product can be reused on other pages. For
each product, it’s associated categories are shown.
-Separation of the page into a template that can also be used for
other pages, and the content that is unique for each page (this
content is surrounded by the template).
-Injection of the page name (including the number of products) in the
title tag, and in the master template page name.
</quote>

The final page products should look like this one:
https://github.com/jtdev/blogpost_files/blob/master/template.xhtml
The resulting page uses a product panel and the associated categories
of each product in each table row. So, I can't move all the page
template code into the panel template since it will break the rules.

Regards,

Gilberto

[1]http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/


On Tue, Aug 23, 2011 at 1:50 AM, Bob Schellink <sa...@gmail.com> wrote:
> Currently the panel is rendered and only then is products added to it. You
> need to swap the order around. First add, then render.
>
> Basically your page template should contain only: $panel
>
> Move the page template code into the panel template, and lastly add the
> products to the panel inside the Java Page. This means you populate the
> panel with products before rendering it.
>
> Bob
>
> On 2011/08/22 20:49 PM, Gilberto wrote:
>>
>> Thinking a little more about it[1]:
>> <quote>
>> <table>
>>     #foreach( $p in $products )
>>     <tr>
>>         <td>$productPanel($p)</td>
>>         <td class="categories">
>>             #foreach( $c in $p.categories )
>>             #if ($foreach.count>1),#end $c.name #end
>>         </td>
>>     </tr>
>>     #end
>> </table>
>> </quote>
>>
>> I guess it can't work because the panel component can't be used in the
>> loop. I would need a repeatable panel in this case, right?
>>
>> Regards,
>>
>> Gilberto
>>
>> [1] http://dl.dropbox.com/u/9093640/clickapp.zip
>>
>
>

Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by Bob Schellink <sa...@gmail.com>.
Currently the panel is rendered and only then is products added to it. You need to swap the order 
around. First add, then render.

Basically your page template should contain only: $panel

Move the page template code into the panel template, and lastly add the products to the panel inside 
the Java Page. This means you populate the panel with products before rendering it.

Bob

On 2011/08/22 20:49 PM, Gilberto wrote:
> Thinking a little more about it[1]:
> <quote>
> <table>
>      #foreach( $p in $products )
>      <tr>
>          <td>$productPanel($p)</td>
>          <td class="categories">
>              #foreach( $c in $p.categories )
>              #if ($foreach.count>1),#end $c.name #end
>          </td>
>      </tr>
>      #end
> </table>
> </quote>
>
> I guess it can't work because the panel component can't be used in the
> loop. I would need a repeatable panel in this case, right?
>
> Regards,
>
> Gilberto
>
> [1] http://dl.dropbox.com/u/9093640/clickapp.zip
>


Re: Rails, Wicket, Grails, Play, Tapestry, Lift, JSP, Context and Click

Posted by Gilberto <gi...@gmail.com>.
Thinking a little more about it[1]:
<quote>
<table>
    #foreach( $p in $products )
    <tr>
        <td>$productPanel($p)</td>
        <td class="categories">
            #foreach( $c in $p.categories )
            #if ($foreach.count>1),#end $c.name #end
        </td>
    </tr>
    #end
</table>
</quote>

I guess it can't work because the panel component can't be used in the
loop. I would need a repeatable panel in this case, right?

Regards,

Gilberto

[1] http://dl.dropbox.com/u/9093640/clickapp.zip