I think this is not a good solution to have a view page that consists of
form elements. Usually view pages are represented as plain text. But
technically there are two ways to reuse code/markup in tapestry:

1. Composition.
As was mentioned earlier in this thread we can extract all repeatable logic
and markup in components with its own logic(java class), markup(tml file)
and resource bundle(properties file). So we will have all in one place and
it will be simplier to maintain. To make such components look differently
in some places we can introduce all needed parameters. Don't forget that we
can use parameters not only for objects but also for piece of markup. E.g.
instead of using "editMode" parameter we can introduce "actions" parameter:

edit page:
<t:form>
    <t:personeditor>
        <p:actions>
            <t:submit .../> <t:submit mode="cancel" .../>
        </p:actions>
    </ t:personeditor>
</t:form>

view page:
<t:form>
    <t:personeditor/>
</t:form>


2. Inheritance.
The other way is to use base page for view and edit pages. This page will
have its own logic(java class), markup(tml file) and resource
bundle(properties file). And we can change all of this in our child
pages. So again, we will have all in one place and it will be simplier to
maintain. We just need to mark all places that can be changed with
extension-point tag and then change them in child pages with replace tag:
http://tapestry.apache.org/component-templates.html#ComponentTemplates-TemplateInheritance

base page:
<t:form>
    <!-- person editor markup -->
    <t:extension-point id="actions"/>
</t:form>

edit page:
<t:extend xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";>
    <t:replace id="actions">
        <t:submit .../> <t:submit mode="cancel" .../>
    </t:replace>
</t:extend>

view page can live without template.


On Thu, Sep 13, 2012 at 3:56 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Wed, 12 Sep 2012 18:47:35 -0300, netdawg <net.d...@yahoo.com> wrote:
>
>  Sorry, Thiago, I do not see - why not?  Basically, why cannot pages be
>> allowed simply extend each other?
>>
>
> I haven't said that. Anyway, creating a component is the best, most
> flexible and reusable option.
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
BR
Ivan

Reply via email to