You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kamath_svk <ka...@yahoo.co.in> on 2010/09/21 12:22:03 UTC

Creating Grid component at runtime

Hello All,

I am new to tapestry & facing lot of problem in understanding internal
working of grid.

I have a requirement where I need to display certain data from database
obtained as result list using grid.  

1.       I use query to retrieve certain column names of a particular table
depending on some criteria & those selected columns are to be displayed, so
the number & column names are decided at runtime.

2.       I need to Use Grid component. As far as I know each row of grid is
stored as objects & grid uses getters to retrieve the values.

Ex. Assume a table named TableA consists of Col1, Col2, Col3, Col4, Col5,
Col6, Col7, Col8, Col9 and Col10. Using query, I select say 4 columns (Col1,
Col5, Col7 and Col8) 

I came across Tapestry’s Bean Model class which says we can dynamically add
new columns. I tried that & was able to add new column but was unable to
display any value in that column. 

1.       Can I add those column names at runtime using BeanModel in the pojo
so that grid automatically displays value?
2.        If not is there any way to display the values.

Please help me in this regard


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-Grid-component-at-runtime-tp2847820p2847820.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Creating Grid component at runtime

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Re-reading your email Kamath I can see you have already been advised on this
approach.  Perhaps if the non-primitive properties used for the display
class were only initialised to a value by their setters the memory issue
would be not relevant, and you would already have the names of the
properties for the include/exclude parameter of the grid by taking them from
the query.

Regards,
Jim.

-----Original Message-----
From: Jim O'Callaghan [mailto:jc1000001@yahoo.co.uk] 
Sent: 26 September 2010 15:55
To: 'Tapestry users'
Subject: RE: Creating Grid component at runtime

Can you use a helper class that contains getters for all the possible fields
you require, and them dynamically build a comman delimited "include" (or
"exclude") string, that you pass to your grid using include/exclude via a
page property?

Regards,
Jim.

-----Original Message-----
From: kamath_svk [mailto:kamath_sv@yahoo.co.in] 
Sent: 26 September 2010 15:40
To: users@tapestry.apache.org
Subject: Re: Creating Grid component at runtime


As advised in the previous reply, i can create a class which contains all
the
column & display only those column names which are present in the query.
But i think that will be waste of memory since, I have 50 column names from
col1,col2,.. col50.
Consider the situation where only one column is select by query, the object
created will use the storage for all 50 columns where as only 1 is actually
useful.

so i wanted to know, if i can use beanmodel to add the columns dynamically
at runtime.
-- 
View this message in context:
http://tapestry.1045711.n5.nabble.com/Creating-Grid-component-at-runtime-tp2
847820p2854386.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Creating Grid component at runtime

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Can you use a helper class that contains getters for all the possible fields
you require, and them dynamically build a comman delimited "include" (or
"exclude") string, that you pass to your grid using include/exclude via a
page property?

Regards,
Jim.

-----Original Message-----
From: kamath_svk [mailto:kamath_sv@yahoo.co.in] 
Sent: 26 September 2010 15:40
To: users@tapestry.apache.org
Subject: Re: Creating Grid component at runtime


As advised in the previous reply, i can create a class which contains all
the
column & display only those column names which are present in the query.
But i think that will be waste of memory since, I have 50 column names from
col1,col2,.. col50.
Consider the situation where only one column is select by query, the object
created will use the storage for all 50 columns where as only 1 is actually
useful.

so i wanted to know, if i can use beanmodel to add the columns dynamically
at runtime.
-- 
View this message in context:
http://tapestry.1045711.n5.nabble.com/Creating-Grid-component-at-runtime-tp2
847820p2854386.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating Grid component at runtime

Posted by kamath_svk <ka...@yahoo.co.in>.
As advised in the previous reply, i can create a class which contains all the
column & display only those column names which are present in the query.
But i think that will be waste of memory since, I have 50 column names from
col1,col2,.. col50.
Consider the situation where only one column is select by query, the object
created will use the storage for all 50 columns where as only 1 is actually
useful.

so i wanted to know, if i can use beanmodel to add the columns dynamically
at runtime.
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-Grid-component-at-runtime-tp2847820p2854386.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating Grid component at runtime

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 21 Sep 2010 07:22:03 -0300, kamath_svk <ka...@yahoo.co.in>  
wrote:

> 2.       I need to Use Grid component. As far as I know each row of grid  
> is stored as objects & grid uses getters to retrieve the values.
>
> Ex. Assume a table named TableA consists of Col1, Col2, Col3, Col4, Col5,
> Col6, Col7, Col8, Col9 and Col10. Using query, I select say 4 columns  
> (Col1,
> Col5, Col7 and Col8)

Create a class that represents lines from this query. That's the easiest,  
cleanest solution. Using raw data from the database in the view layer is  
not recommended at all.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org