You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Studarus <jo...@yahoo.com> on 2003/11/01 18:42:31 UTC

multiple HTML sharing one page spec

  I've got the following series of pages that are identical except
for the HTML.  However, I have to duplicate page spec files - is
there any way to reuse the same spec file for multiple pages?
Or should I be using a component somewhere?  Should I
create a component Foo and plug that into each page?
 
  ViewFoo  (ViewFoo.page, ViewFoo.html, base class FooPage.java)
  EditFoo  (EditFoo.page, EditFoo.html, base class FooPage.java)
  AddFoo  (AddFoo.page, AddFoo.html, base class FooPage.java)
 
  They all use the same base page (FooPage.java) which has all
the update/add database logic (using Hibernate).  I would like to do:
 
  ViewFoo (Foo.page, ViewFoo.html, FooPage.java)
  EditFoo (Foo.page, EditFoo.html, FooPage.java)
  AddFoo (Foo.page, AddFoo.html, FooPage.java)
 
  This could be done if the .application file had a spot to put
the name of the HTML template, but it doesn't.
  Any suggestions?
  Thanks,
 
        John


 
 


---------------------------------
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears

Re: multiple HTML sharing one page spec

Posted by "Kevin C. Dorff" <kd...@dorffweb.com>.
I can speak to how I implemented add/edit entity ... I use the EXACT 
same page and template for both add and edit. The difference is "add" 
starts up with a new entity object, edit starts off with an existing 
entity object. I store object (the existing or the new) in a hidden 
field on the form.

The template/page retrieves/stores the form values directly using the 
entity (JavaBeans properties).

When the form is posted back, the fields are filled in by the user 
automatically (via JavaBeans properties). The form listener makes sure 
the entity object is "valid" (required fields filled in, etc.) I save 
the object. When I save the entity object, I look at the objectid (key 
field for the database). If it represents a new object (id = -1 or 
whatever default you set) I add the record, otherwise I update the 
record database with the object.

The view could certainly be the same page/tempate with a @Conditional, or ??

Hope this helps.
Kevin

John Studarus wrote:

>  I've got the following series of pages that are identical except
>for the HTML.  However, I have to duplicate page spec files - is
>there any way to reuse the same spec file for multiple pages?
>Or should I be using a component somewhere?  Should I
>create a component Foo and plug that into each page?
> 
>  ViewFoo  (ViewFoo.page, ViewFoo.html, base class FooPage.java)
>  EditFoo  (EditFoo.page, EditFoo.html, base class FooPage.java)
>  AddFoo  (AddFoo.page, AddFoo.html, base class FooPage.java)
> 
>  They all use the same base page (FooPage.java) which has all
>the update/add database logic (using Hibernate).  I would like to do:
> 
>  ViewFoo (Foo.page, ViewFoo.html, FooPage.java)
>  EditFoo (Foo.page, EditFoo.html, FooPage.java)
>  AddFoo (Foo.page, AddFoo.html, FooPage.java)
> 
>  This could be done if the .application file had a spot to put
>the name of the HTML template, but it doesn't.
>  Any suggestions?
>  Thanks,
> 
>        John
>  
>



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