Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Not sure if that makes any sense but here goes... For each page in Tapestry,
I know that I need to specify a page class, and a corresponding TML templage
file for that page.

I was wondering if I can have more than one possible TML file for a page...
and programatically decide which one to use?

Hope makes sense.

Dave.


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4505668.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Ah. Maybe this is what I need to dynamically use a different template for a
page...

http://tapestry.apache.org/localization.html



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4505678.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Robert Zeigler
The localization happens automatically according to the user's locale (although 
I suppose you could hijack that override it to suite your purposes). However, 
in trunk (5.3.0/5.3.1-SNAPSHOT), the concept is currently being generalized to 
support skinning, etc. 

Robert

On Jun 20, 2011, at 6/204:32 AM , dkeenan wrote:

 Ah. Maybe this is what I need to dynamically use a different template for a
 page...
 
 http://tapestry.apache.org/localization.html
 
 
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4505678.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 


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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Thiago H. de Paula Figueiredo
On Mon, 20 Jun 2011 06:32:02 -0300, dkeenan david_siedle...@yahoo.co.uk  
wrote:


Ah. Maybe this is what I need to dynamically use a different template  
for a page...

http://tapestry.apache.org/localization.html


You can also use a combination of page class subclassing and URL rewriting  
(LinkTransformer API) for that if localization turns out not enough.


--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Howard Lewis Ship
On Mon, Jun 20, 2011 at 2:26 AM, dkeenan david_siedle...@yahoo.co.uk wrote:
 Not sure if that makes any sense but here goes... For each page in Tapestry,
 I know that I need to specify a page class, and a corresponding TML templage
 file for that page.


It's easy to make a single page dynamic, or to choose one of a number
of different pages to render the response.  I feel you may be sticking
too much to the action-oriented framework's view of actions  views;
in Tapestry a page is the combination of an action and a view. This
drives a lot of what Tapestry does for you, in terms of convention
over configuration, and all the plumbing and request handling that the
framework does automatically.

It's a good idea to backtrack from I need to select two different
output views back towards the actual user requirement or story. For
instance, I need to display input validation errors can be a
condtional portion of a single page.  Many other cases can be handled
in terms of having pages with different responsibilities. It's rather
hard to provide guidance in a vacuum.



 I was wondering if I can have more than one possible TML file for a page...
 and programatically decide which one to use?

 Hope makes sense.

 Dave.


 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4505668.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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





-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Thanks Lewis. I can see what you mean. It does sound like I'm trying to do 
something action-oriented/Struts-like. I'm a big fan of the way Tapestry 
doesn't force you to think in this way and is more intuitive. The reason I ask 
actually, is more to do with wanting to re-skin pages based on a user. Ie. want 
the same content (so just need one page class), but Id like to use a different 
TML file altogether based on the user.
This way, I am hoping to work on 2 separate TML files in design mode, and the 
can be served based on which type of user is logged in. For example... a funky 
design versus a more mature design based on the age of the user. Sounds weird 
:-), but just wondering if there's an easy way to select the TML file at run 
time, that Tapestry uses with a single page class. I think the localization 
functionality would actually do just the trick if I just assign the funky 
styled tml file to one (eg. HomePage_fr.tml) and the refined one 
(HomePage_en.tml).

Then I can programatically set the local based on the logged in user. Does that 
sound like a completely deranged way of going about it? :-)

Thanks, 
Dave.










Mon, 6/20/11, Howard Lewis Ship [via Tapestry] 
ml-node+4507472-1501312819-92...@n5.nabble.com wrote:

From: Howard Lewis Ship [via Tapestry] 
ml-node+4507472-1501312819-92...@n5.nabble.com
Subject: Re: Can you dynamically select which page template to return?
To: dkeenan david_siedle...@yahoo.co.uk
Date: Monday, June 20, 2011, 7:49 PM



On Mon, Jun 20, 2011 at 2:26 AM, dkeenan [hidden email] wrote:

 Not sure if that makes any sense but here goes... For each page in Tapestry,

 I know that I need to specify a page class, and a corresponding TML templage

 file for that page.




It's easy to make a single page dynamic, or to choose one of a number

of different pages to render the response.  I feel you may be sticking

too much to the action-oriented framework's view of actions  views;

in Tapestry a page is the combination of an action and a view. This

drives a lot of what Tapestry does for you, in terms of convention

over configuration, and all the plumbing and request handling that the

framework does automatically.


It's a good idea to backtrack from I need to select two different

output views back towards the actual user requirement or story. For

instance, I need to display input validation errors can be a

condtional portion of a single page.  Many other cases can be handled

in terms of having pages with different responsibilities. It's rather

hard to provide guidance in a vacuum.




 I was wondering if I can have more than one possible TML file for a page...

 and programatically decide which one to use?



 Hope makes sense.



 Dave.





 --

 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4505668.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.



 -

 To unsubscribe, e-mail: [hidden email]

 For additional commands, e-mail: [hidden email]







-- 

Howard M. Lewis Ship


Creator of Apache Tapestry


The source for Tapestry training, mentoring and support. Contact me to

learn how I can get you up and productive in Tapestry fast!


(971) 678-5210

http://howardlewisship.com

-

To unsubscribe, e-mail: [hidden email]

For additional commands, e-mail: [hidden email]










If you reply to this email, your message will be added to the 
discussion below:

http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4507472.html



To unsubscribe from Can you dynamically select which page 
template to return?, click here.


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4507615.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Thanks Lewis. I can see what you mean. It does sound like I'm trying to do
something action-oriented/Struts-like. I'm a big fan of the way Tapestry
doesn't force you to think in this way and is more intuitive. The reason I
ask actually, is more to do with wanting to re-skin pages based on a user.
Ie. want the same content (so just need one page class), but Id like to use
a different TML file altogether based on the user.

This way, I am hoping to work on 2 separate TML files in design mode, and
the can be served based on which type of user is logged in. For example... a
funky design versus a more mature design based on the age of the user.
Sounds weird :-), but just wondering if there's an easy way to select the
TML file at run time, that Tapestry uses with a single page class. I think
the localization functionality would actually do just the trick if I just
assign the funky styled tml file to one (eg. HomePage_fr.tml) and the
refined one (HomePage_en.tml).

Then I can programatically set the local based on the logged in user. Does
that sound like a completely deranged way of going about it? :-)

Thanks, 

Dave.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4507623.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Thiago H. de Paula Figueiredo
On Mon, 20 Jun 2011 16:17:21 -0300, dkeenan david_siedle...@yahoo.co.uk  
wrote:


This way, I am hoping to work on 2 separate TML files in design mode,  
and the can be served based on which type of user is logged in. For  
example... a funky design versus a more mature design based on the age  
of the user. Sounds weird :-),


I don't think so. I guess most of what you want to do is implementable  
using CSS alone and a single template. Check csszengarden.com for that.  
Having more information about what would be different for these two user  
types would be helpful for us to be helpful to you. :)


--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Thanks Thiago. Yeah I see what you mean also. Ideally the HTML should be the
content, and be completely separate from styling (that's CSS's job). This is
exactly how it should be done as you say, but I'm also keen to reuse
existing HTML templates without having to re-factor too much (some changes
would def be needed of course, but I'd rather avoid having do a major
re-write of existing designs I have). I'm more looking to resuse my existing
designs, but plug them into the same backend page class as they will be
using the same data (just doing slightly different things with the data).

I do like the idea of using the localisation functionality that Tapesty has.
Just feels a little weird as I know that's not it's purpose.

Thanks.

Dave.


 



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4508071.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Howard Lewis Ship
On Mon, Jun 20, 2011 at 2:03 PM, dkeenan david_siedle...@yahoo.co.uk wrote:
 Thanks Thiago. Yeah I see what you mean also. Ideally the HTML should be the
 content, and be completely separate from styling (that's CSS's job). This is
 exactly how it should be done as you say, but I'm also keen to reuse
 existing HTML templates without having to re-factor too much (some changes
 would def be needed of course, but I'd rather avoid having do a major
 re-write of existing designs I have). I'm more looking to resuse my existing
 designs, but plug them into the same backend page class as they will be
 using the same data (just doing slightly different things with the data).

 I do like the idea of using the localisation functionality that Tapesty has.
 Just feels a little weird as I know that's not it's purpose.

Which is why Tapestry 5.3 extends the selection logic from locale to
locale + other things, that you can define by overriding a few
built-in public services.


 Thanks.

 Dave.






 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4508071.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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





-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread Thiago H. de Paula Figueiredo
On Mon, 20 Jun 2011 18:03:33 -0300, dkeenan david_siedle...@yahoo.co.uk  
wrote:


Thanks Thiago. Yeah I see what you mean also. Ideally the HTML should be  
the
content, and be completely separate from styling (that's CSS's job).  
This is

exactly how it should be done as you say, but I'm also keen to reuse
existing HTML templates without having to re-factor too much (some  
changes

would def be needed of course, but I'd rather avoid having do a major
re-write of existing designs I have). I'm more looking to resuse my  
existing

designs, but plug them into the same backend page class as they will be
using the same data (just doing slightly different things with the data).


Now it makes more sense to do what you want the way you want. :)

And don't forget that reusing HTML snippets is very easy and quick in  
Tapestry: just write a component.


I do like the idea of using the localisation functionality that Tapesty  
has. Just feels a little weird as I know that's not it's purpose.


The 5.3 new localization features target exactly this kind of scenario you  
have.


--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Sounds great. I'll take that approach in that case. Thanks for your help.


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4508195.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Can you dynamically select which page template to return?

2011-06-20 Thread dkeenan
Hi. I just gave that a go, using localization to serve a different TML
template. Started by adding following lines to AppModule:

public static void contributeApplicationDefaults(
  MappedConfigurationlt;String, Stringgt; configuration) {

configuration.add(tapestry.supported-locales, en,fr);
}

Then set locale programatically:

@Inject 
private PersistentLocale localeService;
.
.
.
localeService.set(new Locale(fr)); (did this in Activate method of a super
Page class that all my page classes extend.


I have a page called Home.tml (Backed by Home.java which extends Page.java)

I renamed Home.tml to Home_fr.tml.

When I try to access this page however the broser navigates to /fr/Home. I
was thinking that it should just display /Home in the URL as before, but
serve the html from the new template file (Home_fr.tml)?


Thanks again!!






--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-you-dynamically-select-which-page-template-to-return-tp4505668p4508411.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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