Re: T5: How to generate page links from Java code?

2007-06-05 Thread Martin Grotzke
On Mon, 2007-06-04 at 17:21 +0700, Ivan Dubrov wrote:
 Nick Westgate wrote:
  Hi Martin.
 
  A typical way to do this in previous Tapestry versions is to have
  some simple logic functions in your component class to provide a
  boolean result (this link is to the current page) which is used
  for each link's disabled parameter, and to select a string supplied
  to an informal CSS style parameter on each link.
 
  T5 would be the same, except that the core PageLink component needs
  a few tweaks to be fit for your task - so roll your own from that -
  and you will have to create an equivalent of the old getPageName().

 
 BTW, you can use resolver.resolvePageClassNameToPageName(pageClassName)
 to get page name for given page class name, where resolver is
 org.apache.tapestry.services.ComponentClassResolver. Current page class
 name could be retrieved as
 resources.getPage().getComponentResources().getComponentModel().getComponentClassName(),
 where resources is org.apache.tapestry.ComponentResources injected in
 component. That's how my menu is working.

Great, thx for this info!

Cheers,
Martin




signature.asc
Description: This is a digitally signed message part


Re: T5: How to generate page links from Java code?

2007-06-04 Thread Nick Westgate
Hi Martin.

A typical way to do this in previous Tapestry versions is to have
some simple logic functions in your component class to provide a
boolean result (this link is to the current page) which is used
for each link's disabled parameter, and to select a string supplied
to an informal CSS style parameter on each link.

T5 would be the same, except that the core PageLink component needs
a few tweaks to be fit for your task - so roll your own from that -
and you will have to create an equivalent of the old getPageName().

In general, use HTML templating whenever practical, as this is the
natural format in which to express HTML structure. Then leave the
fine-tuning of the runtime HTML to existing or home-grown components.

Cheers,
Nick.


Martin Grotzke wrote:
 On Fri, 2007-06-01 at 08:48 -0700, Howard Lewis Ship wrote:
 You have to inject your ComponentResources.

 There are methods for generating page render links and component action
 links as part of the ComponentResources interface.
 Great!
 
 What's then the intended way of rendering the component? Should we
 directly use the MarkupWriter with .element(a ... etc, or is it
 also possible to let the component render itself?
 
 If we create a page link in the template (t:pagelink), there might get
 attributes rendered that are not explicitely specified. Now it would be
 nice to get exactly the same markup, even if the component is created in
 java code. Is this somehow possible, and is it intended to be used like
 this?
 
 Cheers,
 Martin
 
 
 On 6/1/07, Martin Dietze [EMAIL PROTECTED] wrote:
 Hi,

 I'm trying to create a component for a navigation element
 which contains page links for all of my pages but renders the
 currently loaded page differently (i.e. not a href, different
 font etc.).

 It seems to me like the best way to do this is have my
 component's java code write the lines containing the titles and
 the underlying links.

 Unfortunately I have not been able to find any example how to
 do this, in all examples I found the links were created in the
 html template rather than the java code.

 Can anyone here help me out?

 Cheers,

 Martin

 --
 --- / http://herbert.the-little-red-haired-girl.org /
 -
 =+=
 We waste time looking for the perfect lover, instead of creating the
 perfect love.  -- Tom Robbins, _Still Life With Woodpecker_

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: How to generate page links from Java code?

2007-06-04 Thread Ivan Dubrov
Nick Westgate wrote:
 Hi Martin.

 A typical way to do this in previous Tapestry versions is to have
 some simple logic functions in your component class to provide a
 boolean result (this link is to the current page) which is used
 for each link's disabled parameter, and to select a string supplied
 to an informal CSS style parameter on each link.

 T5 would be the same, except that the core PageLink component needs
 a few tweaks to be fit for your task - so roll your own from that -
 and you will have to create an equivalent of the old getPageName().
   

BTW, you can use resolver.resolvePageClassNameToPageName(pageClassName)
to get page name for given page class name, where resolver is
org.apache.tapestry.services.ComponentClassResolver. Current page class
name could be retrieved as
resources.getPage().getComponentResources().getComponentModel().getComponentClassName(),
where resources is org.apache.tapestry.ComponentResources injected in
component. That's how my menu is working.

-- 
WBR,
Ivan S. Dubrov




signature.asc
Description: OpenPGP digital signature


Re: T5: How to generate page links from Java code?

2007-06-01 Thread Howard Lewis Ship

You have to inject your ComponentResources.

There are methods for generating page render links and component action
links as part of the ComponentResources interface.

On 6/1/07, Martin Dietze [EMAIL PROTECTED] wrote:


Hi,

I'm trying to create a component for a navigation element
which contains page links for all of my pages but renders the
currently loaded page differently (i.e. not a href, different
font etc.).

It seems to me like the best way to do this is have my
component's java code write the lines containing the titles and
the underlying links.

Unfortunately I have not been able to find any example how to
do this, in all examples I found the links were created in the
html template rather than the java code.

Can anyone here help me out?

Cheers,

Martin

--
--- / http://herbert.the-little-red-haired-girl.org /
-
=+=
We waste time looking for the perfect lover, instead of creating the
perfect love.  -- Tom Robbins, _Still Life With Woodpecker_

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com