You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sparqle <ds...@gmail.com> on 2009/08/27 02:14:01 UTC
t5: Dynamic Forms & Grids
Hi,
I would like to understand how to create dynamic forms and grids in T5. For
example, suppose I am trying to build a site like Amazon.com with lot of
items for sale (including books, tvs, computers etc.). Each type of item may
have its own set of attributes - books (author, number of pages, publication
year, isbn etc.), tv (brand, refresh rate, crt/lcd/plasma, size etc.). Now I
would like to store all of item types (book, car, tv etc.) in 1 database
table called "itemtypes", and all the attributes in one database table
called "attributes". Both these tables are linked by a many-to-many
relationship. I will create another table called "items", where the
individual items are stored ("Gone with the wind", "Lord of the Rings"
etc.). I will create another table called "itemAttributeValues" where the
values for the attributes for each item will be stored ("Gone with the wind"
- 900 pages, "Margaret Mitchell", 1937).
Now I would like to provide some forms for the users to edit/input this
information, and some grids to view this information. I obviously don't want
to create a separate form/grid for each "item type" as there may be hundreds
of such categories. What I want is to store the "UI Component" associated
with each attribute in the database, and then display dynamic forms based on
this, depending on the specific item being viewed/edited. The "UI Component"
could be numeric (integer/double etc.), textfield, select, checkbox/radio,
or date.
So the end effect should be:
If user goes to url: http://mydomain.com/item/edit/1 - a list of controls
may be presented that are relevant to that item, and may be completely
different from the controls displayed on http://mydomain.com/item/edit/2.
Also, the column names on the grid should change dynamically based on the
itemtypes being displayed in the grid. it is safe to assume that only items
belonging to one itemtype will be displayed within the same grid.
I have been able to implement such a user interface quite easily using pure
"Java" based frameworks like ZK, but I can't figure out how to implement it
in Tapestry. I think there is way to do this in T5, and people have referred
to the "FormInjector" component, but I looked at some examples and cannot
understand how it relates to my problem. Some others have hinted at the
"Delegate" component, but i can't understand that either. Then some others
have hinted at the "Block" component, but i have not been able to understand
that either:-(
Can anybody help me here?? I assume this must be a common requirement in
many systems!!
--
View this message in context: http://www.nabble.com/t5%3A-Dynamic-Forms---Grids-tp25163809p25163809.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: t5: Dynamic Forms & Grids
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 27 Aug 2009 13:06:14 -0300, Sparqle <ds...@gmail.com> escreveu:
> Hi Thiago,
Hi!
> Based on your post, I am thinking that this type of behavior is not
> supported by T5.
I would say that it is supported, but out-of-the-box you would be way
better supported if not using this modeling you're using.
> I am wondering whether the "if" component, and the
> "AjaxFormLoop" could combine to simulate this same functionality.
Take a look at how BeanEditor works. Maybe it could help you.
> For the
> Grids though, I am not sure whether I can achieve this result without
> predefined classes.
You can work with Grid without predefined classes. Internally, Grid uses a
BeanModel (that can be passed as a parameter) to get the properties of the
object and their values. Take a look at BeanModel and PropertyConduit.
> This has to be a common requirement for many sites. I know some of the
> largest sites on the Internet use this type of a system.
Could you give use some examples?
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: t5: Dynamic Forms & Grids
Posted by Sparqle <ds...@gmail.com>.
Hi Thiago,
Thanks for reviewing my long post and responding. I understand your concerns
about the database schema not being ideal, but creating separate Java
classes for each one of the "itemtypes" is not acceptable as we are planning
to create a site where end-users can define their own categories and
attributes and the associated UI controls. There could be hundreds of
thousands of these categories and millions of attributes.
Based on your post, I am thinking that this type of behavior is not
supported by T5. I am wondering whether the "if" component, and the
"AjaxFormLoop" could combine to simulate this same functionality. For the
Grids though, I am not sure whether I can achieve this result without
predefined classes.
This has to be a common requirement for many sites. I know some of the
largest sites on the Internet use this type of a system. I would appreciate
if you can point me to any other alternatives without "predefined" classes
for "Book", "DVD" etc in T5.
Thiago H. de Paula Figueiredo wrote:
>
> Em Wed, 26 Aug 2009 21:14:01 -0300, sparqle <ds...@gmail.com>
> escreveu:
>
>> Hi,
>
> Hi!
>
>> I would like to understand how to create dynamic forms and grids in T5.
>
> T5 is all about static structure, dynamic behaviour.
>
>> Now I would like to store all of item types (book, car, tv etc.) in 1
>> database
>> table called "itemtypes", and all the attributes in one database table
>> called "attributes". Both these tables are linked by a many-to-many
>> relationship. I will create another table called "items", where the
>> individual items are stored ("Gone with the wind", "Lord of the Rings"
>> etc.). I will create another table called "itemAttributeValues" where the
>> values for the attributes for each item will be stored ("Gone with the
>> wind" - 900 pages, "Margaret Mitchell", 1937).
>
> I'm sorry to be so sincere, but this kind of database approach is
> absolutely awful. Something awful enough to appear in TheDailyWTF.com (if
> it wasn't featured there already). Tapestry 5 has BeanEditForm,
> BeanEditor, Grid and BeanDisplay, all them time-savers when writing a form
> or grid or object view, but they only work if you provide them
> decently-modelled entity classes (a Book class with title and author
> properties, a DVD class with title and director properties).
>
>> Can anybody help me here?? I assume this must be a common requirement in
>> many systems!!
>
> This is already implemented in Tapestry 5, as long as you have
> decently-modelled classes.
> Take a look at the documentation of the components cited above and the
> BeanEditor or BeanEditForm examples in
> http://jumpstart.doublenegative.com.au:8080/jumpstart/.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://n2.nabble.com/t5-Dynamic-Forms-Grids-tp3520407p3527617.html
Sent from the Tapestry Users 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: t5: Dynamic Forms & Grids
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 26 Aug 2009 21:14:01 -0300, sparqle <ds...@gmail.com> escreveu:
> Hi,
Hi!
> I would like to understand how to create dynamic forms and grids in T5.
T5 is all about static structure, dynamic behaviour.
> Now I would like to store all of item types (book, car, tv etc.) in 1
> database
> table called "itemtypes", and all the attributes in one database table
> called "attributes". Both these tables are linked by a many-to-many
> relationship. I will create another table called "items", where the
> individual items are stored ("Gone with the wind", "Lord of the Rings"
> etc.). I will create another table called "itemAttributeValues" where the
> values for the attributes for each item will be stored ("Gone with the
> wind" - 900 pages, "Margaret Mitchell", 1937).
I'm sorry to be so sincere, but this kind of database approach is
absolutely awful. Something awful enough to appear in TheDailyWTF.com (if
it wasn't featured there already). Tapestry 5 has BeanEditForm,
BeanEditor, Grid and BeanDisplay, all them time-savers when writing a form
or grid or object view, but they only work if you provide them
decently-modelled entity classes (a Book class with title and author
properties, a DVD class with title and director properties).
> Can anybody help me here?? I assume this must be a common requirement in
> many systems!!
This is already implemented in Tapestry 5, as long as you have
decently-modelled classes.
Take a look at the documentation of the components cited above and the
BeanEditor or BeanEditForm examples in
http://jumpstart.doublenegative.com.au:8080/jumpstart/.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org