You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Vitaly Baranovsky <vi...@gmail.com> on 2006/09/21 14:59:16 UTC

How can I programmatically set my own title of portal pages?

Good day!

I'm writing news site using jetspeed-2.1-dev. Site has a page that contains
portlet with one news. This news has a caption. I need page title (<title>
tag in <head>) was equals to this caption.

For example. I have collection of two news as objects of class News:
News1:
id: 06091501
caption: Hello world

News2:
id: 06091502
caption: some test caption

When user enters
http://mycompany.net/jetspeed/portal/newscontent.psml?id=06091501, jetspeed
must return page with title "Hello world".

But when user enters
http://mycompany.net/jetspeed/portal/newscontent.psml?id=06091501, jetspeed
must return page with title "some test caption".

How can I do it?

Thanks!

Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Vitaly Baranovsky z 2006-09-25 15:36 brzmiala:

> Thank you very much!!!
:)

> And yet another question. Is there a way to access methods of myClass
> without recompiling sources? For example, can I put myClass in session and
> get it from session in velocity template?
I guess not, as a current request must available to your class (this is 
assured by creating a Velocity context). But you could try, it might 
work, anyway.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: How can I programmatically set my own title of portal pages?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
Thank you very much!!!

And yet another question. Is there a way to access methods of myClass
without recompiling sources? For example, can I put myClass in session and
get it from session in velocity template?


2006/9/22, Jacek Wiślicki <ja...@gmail.com>:
>
> Wiadomosc od Vitaly Baranovsky z 2006-09-22 15:24 brzmiala:
>
> >> You can write a method visible in a Velocity context (add it to one of
> >> existing classes or create a new one and put in in the context)
> >> responsible for such things.
> > Thanks, but I'm new to Jetspeed and Velocity. And I don't no how can I
> > to do
> > this. Can you give me sample of code? Thanks!
> First, write your own class (say MyClass ;) ) with a constructor taking
> as an argument RenderRequest (RenderRequest is available in the
> Jetspeed's Velocity context). In the class add an appropriate method,
> e.g. String getPageTitle(). Basing on the render request, you can
> determine a requested page and return its custom title. Finally, package
> your class as a JAR. Copy the JAR to Jetspeed's WEB-INF/lib.
>
> Now you have to add an instance of your class to the Velocity context.
> Edit org.apache.jetspeed.velocity.JetspeedVelocityViewServlet (a
> "portal" component). In the method Template
> handleRequest(HttpServletRequest, HttpServletResponse, Context ctx) add
> something like ctx.put("myClass", new MyClass(renderRequest)). An
> instance of your class with the method will be accessible within
> Velocity as $myClass.getPageTitle() (similarly, other methods if you
> create them).
>
> Recompile the "portal" component and package it as a JAR. Its name
> should be something like jetspeed-portal-2.1-dev.jar (for Jetspeed 2.1
> dev), for other versions use an appropriate name. Overwrite the existing
> JAR in Jetspeed's WEB-INF/lib. Restart Catalina and it should work.
>
> --
> pozdrawiam,
>     Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How can I programmatically set my own title of portal pages?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
Ok! ;)

2006/10/7, Jacek Wiślicki <ja...@gmail.com>:
>
> Wiadomosc od Vitaly Baranovsky z 2006-10-07 01:51 brzmiala:
>
> > Yes!!!! All is works!
> >
> > Thank you very much! There is a box of beer for you if you will come in
> > Ukraine ;)
> Maybe next year, I'll contact you ;)
>
> --
> pozdrawiam,
>     Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Vitaly Baranovsky z 2006-10-07 01:51 brzmiala:

> Yes!!!! All is works!
> 
> Thank you very much! There is a box of beer for you if you will come in
> Ukraine ;)
Maybe next year, I'll contact you ;)

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: How can I programmatically set my own title of portal pages?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
Yes!!!! All is works!

Thank you very much! There is a box of beer for you if you will come in
Ukraine ;)


2006/10/7, Jacek Wiślicki <ja...@gmail.com>:
>
> Wiadomosc od Vitaly Baranovsky z 2006-10-06 23:52 brzmiala:
>
> > Help me, please! How can I recompile "portal" component with my jar on
> > classpath?
> Run maven from [jetspeed source root]\components\portal (no need to
> perform a complex build). In order to make a JAR visible to maven, add
> it as a dependency in project.xml, e.g.
>        <dependency>
>                <groupId>yourgroup</groupId>
>                <artifactId>yourjar</artifactId>
>                <version>yourjarversion</version>
>                <type>jar</type>
>                <properties>
>                        <war.bundle>false</war.bundle>
>                </properties>
>        </dependency>
> The JAR should be named as "yourjar-yourjarversion.jar", e.g.
> my-jetspeed-utils-1.0.jar and located as maven's artifact in:
> ~/.maven/repository/yourgroup/jars/
>
> --
> pozdrawiam,
>     Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Jacek Wiślicki z 2006-10-07 00:00 brzmiala:

> Wiadomosc od Vitaly Baranovsky z 2006-10-06 23:52 brzmiala:
> 
>> Help me, please! How can I recompile "portal" component with my jar on
>> classpath?
> Run maven from [jetspeed source root]\components\portal (no need to 
> perform a complex build). In order to make a JAR visible to maven, add 
> it as a dependency in project.xml, e.g.
>     <dependency>
>         <groupId>yourgroup</groupId>
>         <artifactId>yourjar</artifactId>
>         <version>yourjarversion</version>
>         <type>jar</type>
>         <properties>
>             <war.bundle>false</war.bundle>
>         </properties>
>     </dependency>
> The JAR should be named as "yourjar-yourjarversion.jar", e.g. 
> my-jetspeed-utils-1.0.jar and located as maven's artifact in: 
> ~/.maven/repository/yourgroup/jars/
And finally put your JAR in Tomcat's shared/lib or Jetspeed's 
WEB-INF/lib, of course ;)

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Vitaly Baranovsky z 2006-10-06 23:52 brzmiala:

> Help me, please! How can I recompile "portal" component with my jar on
> classpath?
Run maven from [jetspeed source root]\components\portal (no need to 
perform a complex build). In order to make a JAR visible to maven, add 
it as a dependency in project.xml, e.g.
	<dependency>
		<groupId>yourgroup</groupId>
		<artifactId>yourjar</artifactId>
		<version>yourjarversion</version>
		<type>jar</type>
		<properties>
			<war.bundle>false</war.bundle>
		</properties>
	</dependency>
The JAR should be named as "yourjar-yourjarversion.jar", e.g. 
my-jetspeed-utils-1.0.jar and located as maven's artifact in: 
~/.maven/repository/yourgroup/jars/

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: How can I programmatically set my own title of portal pages?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
> Recompile the "portal" component and package it as a JAR.

How can I recompile "portal" component with my own jar on classpath?

I've created my jar (my-jetspeed-utils.jar) with class PageTitleUtils. But I
don't know how can I recompile the "portal" component. I'm very new to
maven. I don't know place to copy my-jetspeed-utils.jar. So, when I run
maven allBuild, it says me

D:\java\src\portals-jetspeed-2\components\portal\src\java\org\apache\jetspeed\velocity\JetspeedVelocityViewServlet.java:258:
cannot find symbol
 symbol  : class PageTitleUtils
 location: class org.apache.jetspeed.velocity.JetspeedVelocityViewServlet
             ctx.put("PageTitleUtils", new PageTitleUtils(renderRequest));

Help me, please! How can I recompile "portal" component with my jar on
classpath?

Thanks!


2006/9/22, Jacek Wiślicki <ja...@gmail.com>:
>
> Wiadomosc od Vitaly Baranovsky z 2006-09-22 15:24 brzmiala:
>
> >> You can write a method visible in a Velocity context (add it to one of
> >> existing classes or create a new one and put in in the context)
> >> responsible for such things.
> > Thanks, but I'm new to Jetspeed and Velocity. And I don't no how can I
> > to do
> > this. Can you give me sample of code? Thanks!
> First, write your own class (say MyClass ;) ) with a constructor taking
> as an argument RenderRequest (RenderRequest is available in the
> Jetspeed's Velocity context). In the class add an appropriate method,
> e.g. String getPageTitle(). Basing on the render request, you can
> determine a requested page and return its custom title. Finally, package
> your class as a JAR. Copy the JAR to Jetspeed's WEB-INF/lib.
>
> Now you have to add an instance of your class to the Velocity context.
> Edit org.apache.jetspeed.velocity.JetspeedVelocityViewServlet (a
> "portal" component). In the method Template
> handleRequest(HttpServletRequest, HttpServletResponse, Context ctx) add
> something like ctx.put("myClass", new MyClass(renderRequest)). An
> instance of your class with the method will be accessible within
> Velocity as $myClass.getPageTitle() (similarly, other methods if you
> create them).
>
> Recompile the "portal" component and package it as a JAR. Its name
> should be something like jetspeed-portal-2.1-dev.jar (for Jetspeed 2.1
> dev), for other versions use an appropriate name. Overwrite the existing
> JAR in Jetspeed's WEB-INF/lib. Restart Catalina and it should work.
>
> --
> pozdrawiam,
>     Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Vitaly Baranovsky z 2006-09-22 15:24 brzmiala:

>> You can write a method visible in a Velocity context (add it to one of
>> existing classes or create a new one and put in in the context)
>> responsible for such things.
> Thanks, but I'm new to Jetspeed and Velocity. And I don't no how can I 
> to do
> this. Can you give me sample of code? Thanks!
First, write your own class (say MyClass ;) ) with a constructor taking 
as an argument RenderRequest (RenderRequest is available in the 
Jetspeed's Velocity context). In the class add an appropriate method, 
e.g. String getPageTitle(). Basing on the render request, you can 
determine a requested page and return its custom title. Finally, package 
your class as a JAR. Copy the JAR to Jetspeed's WEB-INF/lib.

Now you have to add an instance of your class to the Velocity context. 
Edit org.apache.jetspeed.velocity.JetspeedVelocityViewServlet (a 
"portal" component). In the method Template 
handleRequest(HttpServletRequest, HttpServletResponse, Context ctx) add 
something like ctx.put("myClass", new MyClass(renderRequest)). An 
instance of your class with the method will be accessible within 
Velocity as $myClass.getPageTitle() (similarly, other methods if you 
create them).

Recompile the "portal" component and package it as a JAR. Its name 
should be something like jetspeed-portal-2.1-dev.jar (for Jetspeed 2.1 
dev), for other versions use an appropriate name. Overwrite the existing 
JAR in Jetspeed's WEB-INF/lib. Restart Catalina and it should work.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: How can I programmatically set my own title of portal pages?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
> You can write a method visible in a Velocity context (add it to one of
> existing classes or create a new one and put in in the context)
> responsible for such things.

Thanks, but I'm new to Jetspeed and Velocity. And I don't no how can I to do
this. Can you give me sample of code? Thanks!

With best regards,
Vitaly Baranovsky


2006/9/21, Jacek Wiślicki <ja...@gmail.com>:
>
> Wiadomosc od Vitaly Baranovsky z 2006-09-21 14:59 brzmiala:
>
> > I'm writing news site using jetspeed-2.1-dev. Site has a page that
> contains
> > portlet with one news. This news has a caption. I need page title
> (<title>
> > tag in <head>) was equals to this caption.
> You can write a method visible in a Velocity context (add it to one of
> existing classes or create a new one and put in in the context)
> responsible for such things.
>
> --
> pozdrawiam,
>     Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How can I programmatically set my own title of portal pages?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Vitaly Baranovsky z 2006-09-21 14:59 brzmiala:

> I'm writing news site using jetspeed-2.1-dev. Site has a page that contains
> portlet with one news. This news has a caption. I need page title (<title>
> tag in <head>) was equals to this caption.
You can write a method visible in a Velocity context (add it to one of 
existing classes or create a new one and put in in the context) 
responsible for such things.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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