You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by netdawg <ne...@yahoo.com> on 2012/09/12 21:10:15 UTC

One Template to include another TML - JSP style

Basically, looking for jsp style include.  

However, in the user guide, under Layout Component I see "Tapestry doesn't
have a mechanism for such includes – nor does it need one."  Hmmm...

Well, here is the problem I have: 

1.  Create/Update Page featuring an input form, say, a Person with fields
like name, address etc. 
2.  VIEW Person which is EXACTLY same update form - just no submit/cancel
buttons. 

Not clear to me how doing nested layouts would be better than nested tmls.  
In fact, I found this so obtuse that I am maintaining two separate tmls
(Sorry for the low IQ I bring to this ;-))

Any better ideas, examples?  Should I just do JSP - and have it coexist with
TML - is that the intended design of the framework?  All that is needed is
for that gigantic form to be maintained in one place - even if it has to
included in various tmls - just so edits are centralized.  

Thanks.  







--
View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240.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: One Template to include another TML - JSP style

Posted by Robert Zeigler <ro...@roxanemy.com>.
... It seems like the framework already handles this complexity nicely, in the form of components, but maybe I'm missing something in your requirements. I think there are at least two viable, very simple options.

Option 1: 
  Extract all of the fields into a "PersonEditor" component. This component will NOT have <t:form>, nor will it have the submit/cancel buttons.
  Now the edit page looks something like:
    <t:form>
      <t:personeditor/>
      <t:submit .../> <t:submit mode="cancel" .../>
    </t:form>
   Then you can handle the save/update logic within the page. Your view page would look like:
   <t:form>
     <t:personeditor/>
   </t:form>

Option 2:
  Move all control to the personeditor and use conditional rendering based on a "mode" parameter, or something of that nature.. Now PersonEditor.tml looks something like:
  <t:form>
     ...
     <t:if test="editMode">
       <t:submit .../> <t:submit mode="cancel" .../>
     </t:if>
  </t:form>

  PersonEditor.java:
  @Parameter(required=true)
  private boolean editMode;


You could even enable/disable fields based on whether the editMode was true or false (or some other value: you could make it an enum).

Now your pages look like:
  <t:personeditor editMode="true"/>
and
  <t:personeditor editMode="false"/>



Robert
  
On Sep 12, 2012, at 9/122:46 PM , netdawg wrote:

> Thanks, Michael.   Your suggestion makes sense - for most.  
> 
> Unfortunately, I have to using a fully customized form - not bean editor.  
> 
> In addition to TML, there is the property files that need to be not repeated
> - I know there is the app level properties for this - but still project
> demands this to avoid label clashes.  
> 
> I think there needs to be a way to contrive this include - simple on the
> outside - but the framework handles the complexity somehow in the back-end. 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716242.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: One Template to include another TML - JSP style

Posted by Michael Prescott <mi...@gmail.com>.
No problem.  Yes, I know the simple solution sometimes isn't the right fit.

For a component, I wonder if you can pass in a shared message catalog as a
parameter?

Are you literally using HTML <input> fields for display?  Or are you
writing text in display mode and form fields in edit mode?

Michael

On 12 September 2012 15:46, netdawg <ne...@yahoo.com> wrote:

> Thanks, Michael.   Your suggestion makes sense - for most.
>
> Unfortunately, I have to using a fully customized form - not bean editor.
>
> In addition to TML, there is the property files that need to be not
> repeated
> - I know there is the app level properties for this - but still project
> demands this to avoid label clashes.
>
> I think there needs to be a way to contrive this include - simple on the
> outside - but the framework handles the complexity somehow in the back-end.
>
>
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716242.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: One Template to include another TML - JSP style

Posted by netdawg <ne...@yahoo.com>.
Thanks, Michael.   Your suggestion makes sense - for most.  

Unfortunately, I have to using a fully customized form - not bean editor.  

In addition to TML, there is the property files that need to be not repeated
- I know there is the app level properties for this - but still project
demands this to avoid label clashes.  

I think there needs to be a way to contrive this include - simple on the
outside - but the framework handles the complexity somehow in the back-end. 






--
View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716242.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: One Template to include another TML - JSP style

Posted by Michael Prescott <mi...@gmail.com>.
Tapestry doesn't let you include text from a file into another file, but
you could certainly create a PersonViewEdit component that renders itself
in two modes.

For this particular case, you might find that a reflection-based
BeanEditForm on one page, and a BeanDisplay on another is the right way to
go.

http://tapestry.apache.org/component-reference.html#ComponentReference-BeanDisplaying%2526Editing


Michael

On 12 September 2012 15:10, netdawg <ne...@yahoo.com> wrote:

> Basically, looking for jsp style include.
>
> However, in the user guide, under Layout Component I see "Tapestry doesn't
> have a mechanism for such includes – nor does it need one."  Hmmm...
>
> Well, here is the problem I have:
>
> 1.  Create/Update Page featuring an input form, say, a Person with fields
> like name, address etc.
> 2.  VIEW Person which is EXACTLY same update form - just no submit/cancel
> buttons.
>
> Not clear to me how doing nested layouts would be better than nested tmls.
> In fact, I found this so obtuse that I am maintaining two separate tmls
> (Sorry for the low IQ I bring to this ;-))
>
> Any better ideas, examples?  Should I just do JSP - and have it coexist
> with
> TML - is that the intended design of the framework?  All that is needed is
> for that gigantic form to be maintained in one place - even if it has to
> included in various tmls - just so edits are centralized.
>
> Thanks.
>
>
>
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240.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: One Template to include another TML - JSP style

Posted by Robert Zeigler <ro...@roxanemy.com>.
Doesn't really seem that different to me than including a jsp. ;) And instead of having two page properties files, you'll have a single component properties file, a single template of code to maintain, etc. The only new complexity is that you'll be passing the entity for edit/view into your component as a component parameter, and introducing the "editMode" parameter. Seems a lot better than maintaining two nearly identical pages. :)

Robert

On Sep 12, 2012, at 9/124:37 PM , netdawg wrote:

> Thanks, Robert.  Excellent suggestion, especially the second one about
> editMode.  Looking into this.  Fighting my laziness of moving all the logic
> from page level to component level - classes, properties, templates - ugh -
> if I am understanding correctly.    
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716247.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: One Template to include another TML - JSP style

Posted by netdawg <ne...@yahoo.com>.
Thanks, Robert.  Excellent suggestion, especially the second one about
editMode.  Looking into this.  Fighting my laziness of moving all the logic
from page level to component level - classes, properties, templates - ugh -
if I am understanding correctly.    



--
View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716247.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: One Template to include another TML - JSP style

Posted by netdawg <ne...@yahoo.com>.
Sorry, Thiago, I do not see - why not?  Basically, why cannot pages be
allowed simply extend each other?   



--
View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716249.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: One Template to include another TML - JSP style

Posted by netdawg <ne...@yahoo.com>.
Thanks, Ivan, Thiago.  Indeed, message being - this is possible - and
desirable - at the component level.  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/One-Template-to-include-another-TML-JSP-style-tp5716240p5716300.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