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 "Chan, Tony" <to...@fmr.com> on 2007/04/17 16:48:57 UTC

Jetspeed2 and traversing the site structure in velocity

Hi,

Got a question on the Velocity macro side and about the Jetspeed2 menu
API exposed to it.

Say my portal site structure is like this:

root
 `folder1
    +subfolderA
    | `subfolderB
    |   `subfolderC
    |      `page2
    |
    `page1 [hidden]

Where page1 is hidden and folder1 has page1 set as its default page.  I
keep page1 hidden as I want it to be 'seen' as folder1 and not as a
separate page.

And say I want to build a hierarchical listing of my site or even a
breadcrumb where folders with default pages and pages themselves are
linked but folders without default pages are not linked.

I can do this by getting a PortalSiteRequestContext object via request
attribute org.apache.jetspeed.portalsite.PortalSiteRequestContext and
traversing down getRootFolder(), checking Folder.getType() and
Folder.getDefaultPage().

How can I accomplish the same thing when traversing getMenu()?  As far
as I can tell from the javadoc, you can't determine whether a Menu
object has a default page or not so I'd have to either link all folders
or not link any folder.

A second question I have is, in the above site structure example,
hitting the URLs of subfolderA/ or subfolderB/ or subfolderC/ will show
page2.  If I don't want folders without a default page to automatically
show the first child page it finds, what other options do I have?

My apologies if the guides or previous threads had covered this.

Tony


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


Re: Jetspeed2 and traversing the site structure in velocity

Posted by David Sean Taylor <da...@bluesunrise.com>.
On May 1, 2007, at 6:00 AM, Chan, Tony wrote:

> David;
>
> I do have velocimacro.library.autoreload set to true but it seems like
> its check interval is not affected by the
> file.resource.loader.modificationCheckInterval setting (which comes  
> set
> to at 10 by default).  I often just restart Jetspeed to force  
> changes in
> jetspeed-macros to be picked up.
>
> So we can redirect to an error psml on portlet errors and with the
> changes you made, we can redirect 403s as well.  But what about plain
> 404s and 5xx?


You are limited to handling errors that can be handled by servlets
The errors that occur inside the Jetspeed servlet can be handled as  
described in the last email
You can also handle general servlet errors that do not go through  
Jetspeed by configuring your web.xml
For example:

<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>


>
> BTW, did you get a chance to look the structure we get back from
> PortalSiteRequestContext.getMenu() and how we can determine if a given
> node has a default page set or not?
>
No. That one slipped through.
Im pretty backed up working through several other issues
Will look into that one this week


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


RE: Jetspeed2 and traversing the site structure in velocity

Posted by "Chan, Tony" <to...@fmr.com>.
David;

I do have velocimacro.library.autoreload set to true but it seems like
its check interval is not affected by the
file.resource.loader.modificationCheckInterval setting (which comes set
to at 10 by default).  I often just restart Jetspeed to force changes in
jetspeed-macros to be picked up.

So we can redirect to an error psml on portlet errors and with the
changes you made, we can redirect 403s as well.  But what about plain
404s and 5xx?

BTW, did you get a chance to look the structure we get back from
PortalSiteRequestContext.getMenu() and how we can determine if a given
node has a default page set or not?

Tony


-----Original Message-----
From: David Sean Taylor [mailto:david@bluesunrise.com] 
Sent: Thursday, April 26, 2007 3:03 PM
To: Jetspeed Users List
Subject: Re: Jetspeed2 and traversing the site structure in velocity


On Apr 26, 2007, at 7:57 AM, Chan, Tony wrote:

> David;
>
> Is this the "Modifying the Jetspeed Desktop" thread on the dev list?
>
Yes, this is the dev-list and this is the thread where we were  
discussing "dropping" decorators

> I have no problem with going with a one-page solution; my header and
> footer templates are already just place holders that call macros  
> defined
> else where.

I don't either. I think its time we consider alternatives to the  
current layout system
Just want to make sure that we provide backward compatibility with  
the existing approach
If it can be as simple as a configuration switch to use one or the  
other, Im fine with that

>
> If anything I would suggest making a global user macros library that
> layouts can share to go along with this.  I know there's
> jetspeed-macros.vm but I rather keep that 'original'; plus for some
> reason, changes to it doesn't seem to get picked up as readily as  
> other
> templates.
>

Yes, there is a setting in the velocity.properties

velocimacro.library.autoreload = true

But Im not sure if that always works either

> Going back to my other question, is there a way of having Jetspeed  
> serve
> the http error pages, complete with templating?  For example, my  
> layout
> themes all call the same header/branding macro defined in
> jetspeed-macros, I would want my error pages to call the same macro as
> well.
>
> Tony
>

I think I see what you are getting out.
I think it would be good to have Jetspeed redirect to an error page  
whenever an error occurs
You can have your portlets do this by issuing a send redirect like:

response.sendRedirect("/jetspeed/portal/public/error-page.psml");

I have also extended the profiler valve to handle security access  
exceptions and then redirect (with the servlet api) another portal page:

...
catch (PageNotFoundException pe)
{
	String redirectPath  = request.getRequest().getContextPath() +
"/ 
portal/public/reserved/noaccess.html";
         request.getResponse().sendRedirect(redirectPath);
...





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


Re: Jetspeed2 and traversing the site structure in velocity

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Apr 26, 2007, at 7:57 AM, Chan, Tony wrote:

> David;
>
> Is this the "Modifying the Jetspeed Desktop" thread on the dev list?
>
Yes, this is the dev-list and this is the thread where we were  
discussing "dropping" decorators

> I have no problem with going with a one-page solution; my header and
> footer templates are already just place holders that call macros  
> defined
> else where.

I don't either. I think its time we consider alternatives to the  
current layout system
Just want to make sure that we provide backward compatibility with  
the existing approach
If it can be as simple as a configuration switch to use one or the  
other, Im fine with that

>
> If anything I would suggest making a global user macros library that
> layouts can share to go along with this.  I know there's
> jetspeed-macros.vm but I rather keep that 'original'; plus for some
> reason, changes to it doesn't seem to get picked up as readily as  
> other
> templates.
>

Yes, there is a setting in the velocity.properties

velocimacro.library.autoreload = true

But Im not sure if that always works either

> Going back to my other question, is there a way of having Jetspeed  
> serve
> the http error pages, complete with templating?  For example, my  
> layout
> themes all call the same header/branding macro defined in
> jetspeed-macros, I would want my error pages to call the same macro as
> well.
>
> Tony
>

I think I see what you are getting out.
I think it would be good to have Jetspeed redirect to an error page  
whenever an error occurs
You can have your portlets do this by issuing a send redirect like:

response.sendRedirect("/jetspeed/portal/public/error-page.psml");

I have also extended the profiler valve to handle security access  
exceptions and then redirect (with the servlet api) another portal page:

...
catch (PageNotFoundException pe)
{
	String redirectPath  = request.getRequest().getContextPath() + "/ 
portal/public/reserved/noaccess.html";
         request.getResponse().sendRedirect(redirectPath);
...




RE: Jetspeed2 and traversing the site structure in velocity

Posted by "Chan, Tony" <to...@fmr.com>.
David;

Is this the "Modifying the Jetspeed Desktop" thread on the dev list?

I have no problem with going with a one-page solution; my header and
footer templates are already just place holders that call macros defined
else where.

If anything I would suggest making a global user macros library that
layouts can share to go along with this.  I know there's
jetspeed-macros.vm but I rather keep that 'original'; plus for some
reason, changes to it doesn't seem to get picked up as readily as other
templates.

Going back to my other question, is there a way of having Jetspeed serve
the http error pages, complete with templating?  For example, my layout
themes all call the same header/branding macro defined in
jetspeed-macros, I would want my error pages to call the same macro as
well.

Tony


-----Original Message-----
From: David Sean Taylor [mailto:david@bluesunrise.com] 
Sent: Tuesday, April 24, 2007 6:41 PM
To: Jetspeed Users List
Subject: Re: Jetspeed2 and traversing the site structure in velocity


On Apr 24, 2007, at 5:26 PM, Chan, Tony wrote:

> Hi David,
>
> I like the idea of a default page as well; I'm guessing it'll just be
> the contents of header.vm + body.vm + footer.vm?

I like that, although its contrary to what some of the discussion on  
jetspeed dev list is saying
A few of the developers said they would like to drop decorators and  
instead go with a simpler one page solution
i.e. no top.vm or bottom.vm

Maybe we should move this discussion to the jetspeed-dev list

>
> Related to this is another question: right now, is there a way of
> creating 404 page behaviour?  For example, when I hit
> /jetspeed/portal/invalidpath, it just shows me the contents of the
> default page with status 200.  What if I wanted a standard 404 page?
>

There is a Spring configuration for this in the pipelines.xml for the  
profiler valve, see constructor arg 3:

   <bean id="profilerValve"
         class="org.apache.jetspeed.profiler.impl.ProfilerValveImpl"
         init-method="initialize"
   >
    <constructor-arg index="0">
        <ref bean="org.apache.jetspeed.profiler.Profiler" />
    </constructor-arg>
    <constructor-arg index="1">
        <ref bean="org.apache.jetspeed.portalsite.PortalSite" />
    </constructor-arg>
    <constructor-arg index="2">
        <ref bean="org.apache.jetspeed.page.PageManager" />
    </constructor-arg>
    <!--
        request fallback to root folder/page enabled by default;
        if set to false, requests generate HTTP 403/404 errors
        for access errors or missing pages
    -->
    <constructor-arg index="3"><value>true</value></constructor-arg>
    <!--
        use last visited page histories to select default page
        for folder navigational urls; if set to false, the
        default page specified in PSML, (or the first page in
        the folder), is always selected
    -->
    <constructor-arg index="4"><value>true</value></constructor-arg>
   </bean>





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


Re: Jetspeed2 and traversing the site structure in velocity

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Apr 24, 2007, at 5:26 PM, Chan, Tony wrote:

> Hi David,
>
> I like the idea of a default page as well; I'm guessing it'll just be
> the contents of header.vm + body.vm + footer.vm?

I like that, although its contrary to what some of the discussion on  
jetspeed dev list is saying
A few of the developers said they would like to drop decorators and  
instead go with a simpler one page solution
i.e. no top.vm or bottom.vm

Maybe we should move this discussion to the jetspeed-dev list

>
> Related to this is another question: right now, is there a way of
> creating 404 page behaviour?  For example, when I hit
> /jetspeed/portal/invalidpath, it just shows me the contents of the
> default page with status 200.  What if I wanted a standard 404 page?
>

There is a Spring configuration for this in the pipelines.xml for the  
profiler valve, see constructor arg 3:

   <bean id="profilerValve"
         class="org.apache.jetspeed.profiler.impl.ProfilerValveImpl"
         init-method="initialize"
   >
    <constructor-arg index="0">
        <ref bean="org.apache.jetspeed.profiler.Profiler" />
    </constructor-arg>
    <constructor-arg index="1">
        <ref bean="org.apache.jetspeed.portalsite.PortalSite" />
    </constructor-arg>
    <constructor-arg index="2">
        <ref bean="org.apache.jetspeed.page.PageManager" />
    </constructor-arg>
    <!--
        request fallback to root folder/page enabled by default;
        if set to false, requests generate HTTP 403/404 errors
        for access errors or missing pages
    -->
    <constructor-arg index="3"><value>true</value></constructor-arg>
    <!--
        use last visited page histories to select default page
        for folder navigational urls; if set to false, the
        default page specified in PSML, (or the first page in
        the folder), is always selected
    -->
    <constructor-arg index="4"><value>true</value></constructor-arg>
   </bean>




RE: Jetspeed2 and traversing the site structure in velocity

Posted by "Chan, Tony" <to...@fmr.com>.
Hi David,

I like the idea of a default page as well; I'm guessing it'll just be
the contents of header.vm + body.vm + footer.vm?

Related to this is another question: right now, is there a way of
creating 404 page behaviour?  For example, when I hit
/jetspeed/portal/invalidpath, it just shows me the contents of the
default page with status 200.  What if I wanted a standard 404 page?

Tony


-----Original Message-----
From: David Sean Taylor [mailto:david@bluesunrise.com] 
Sent: Friday, April 20, 2007 3:23 AM
To: Jetspeed Users List
Subject: Re: Jetspeed2 and traversing the site structure in velocity


On Apr 19, 2007, at 3:36 PM, Chan, Tony wrote:

> Hi David,
>
> Inline responses below:
>
>
> From: David Sean Taylor [mailto:david@bluesunrise.com]
> Sent: Wednesday, April 18, 2007 9:38 PM
>
> On Apr 17, 2007, at 4:48 PM, Chan, Tony wrote:
>> A second question I have is, in the above site structure example,
>> hitting the URLs of subfolderA/ or subfolderB/ or subfolderC/ will
>> show
>> page2.  If I don't want folders without a default page to
>> automatically
>> show the first child page it finds, what other options do I have?
>>
>
> David> What do you want to show in your default page, a blank page?
>
> I'm not sure if I would want that either.  I was hoping some other  
> users
> could give their thoughts.  It's just that let's say I go to a folder
> and it displays content from a child - it's not entirely obvious to  
> the
> user.
>
> Intranet
>  ` Reports
>     + Scorecard
>     ` Corporate
>       + page1
>       ` page2
>
> /Intranet/Reports/Corporate will show you the contents of page1 but if
> page1 isn't the 'index' page for Corporate (and Corporate has no need
> for an index page), then it doesn't make sense in this context.
>
> One option is to say that any folder should have its own index page  
> and
> by doing so, we avoid this confusion.  I'm interested in other ways
> users have approached this behaviour.
>
I like the idea of an index page that defaults to an "index" of the  
folder if there isn't a default page defined
The index page would simply list the contents of the folder, and  
display general info about the folder



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



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


Re: Jetspeed2 and traversing the site structure in velocity

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Apr 19, 2007, at 3:36 PM, Chan, Tony wrote:

> Hi David,
>
> Inline responses below:
>
>
> From: David Sean Taylor [mailto:david@bluesunrise.com]
> Sent: Wednesday, April 18, 2007 9:38 PM
>
> On Apr 17, 2007, at 4:48 PM, Chan, Tony wrote:
>> A second question I have is, in the above site structure example,
>> hitting the URLs of subfolderA/ or subfolderB/ or subfolderC/ will
>> show
>> page2.  If I don't want folders without a default page to
>> automatically
>> show the first child page it finds, what other options do I have?
>>
>
> David> What do you want to show in your default page, a blank page?
>
> I'm not sure if I would want that either.  I was hoping some other  
> users
> could give their thoughts.  It's just that let's say I go to a folder
> and it displays content from a child - it's not entirely obvious to  
> the
> user.
>
> Intranet
>  ` Reports
>     + Scorecard
>     ` Corporate
>       + page1
>       ` page2
>
> /Intranet/Reports/Corporate will show you the contents of page1 but if
> page1 isn't the 'index' page for Corporate (and Corporate has no need
> for an index page), then it doesn't make sense in this context.
>
> One option is to say that any folder should have its own index page  
> and
> by doing so, we avoid this confusion.  I'm interested in other ways
> users have approached this behaviour.
>
I like the idea of an index page that defaults to an "index" of the  
folder if there isn't a default page defined
The index page would simply list the contents of the folder, and  
display general info about the folder



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


RE: Jetspeed2 and traversing the site structure in velocity

Posted by "Chan, Tony" <to...@fmr.com>.
Hi David,

Inline responses below:


From: David Sean Taylor [mailto:david@bluesunrise.com] 
Sent: Wednesday, April 18, 2007 9:38 PM

On Apr 17, 2007, at 4:48 PM, Chan, Tony wrote:
> A second question I have is, in the above site structure example,
> hitting the URLs of subfolderA/ or subfolderB/ or subfolderC/ will  
> show
> page2.  If I don't want folders without a default page to  
> automatically
> show the first child page it finds, what other options do I have?
>

David> What do you want to show in your default page, a blank page?

I'm not sure if I would want that either.  I was hoping some other users
could give their thoughts.  It's just that let's say I go to a folder
and it displays content from a child - it's not entirely obvious to the
user.

Intranet
 ` Reports
    + Scorecard
    ` Corporate
      + page1
      ` page2 
    
/Intranet/Reports/Corporate will show you the contents of page1 but if
page1 isn't the 'index' page for Corporate (and Corporate has no need
for an index page), then it doesn't make sense in this context.

One option is to say that any folder should have its own index page and
by doing so, we avoid this confusion.  I'm interested in other ways
users have approached this behaviour.



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



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


Re: Jetspeed2 and traversing the site structure in velocity

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Apr 17, 2007, at 4:48 PM, Chan, Tony wrote:

> Hi,
>
> Got a question on the Velocity macro side and about the Jetspeed2 menu
> API exposed to it.
>
> Say my portal site structure is like this:
>
> root
>  `folder1
>     +subfolderA
>     | `subfolderB
>     |   `subfolderC
>     |      `page2
>     |
>     `page1 [hidden]
>
> Where page1 is hidden and folder1 has page1 set as its default  
> page.  I
> keep page1 hidden as I want it to be 'seen' as folder1 and not as a
> separate page.

I don't think its a good idea to make the default-page hidden as its  
contradictory to the purpose of default pages
It doesn't make sense to me and will take some custom logic to work  
properly AFAIK

>
> And say I want to build a hierarchical listing of my site or even a
> breadcrumb where folders with default pages and pages themselves are
> linked but folders without default pages are not linked.
>
> I can do this by getting a PortalSiteRequestContext object via request
> attribute org.apache.jetspeed.portalsite.PortalSiteRequestContext and
> traversing down getRootFolder(), checking Folder.getType() and
> Folder.getDefaultPage().
>
> How can I accomplish the same thing when traversing getMenu()?  As far
> as I can tell from the javadoc, you can't determine whether a Menu
> object has a default page or not so I'd have to either link all  
> folders
> or not link any folder.

This one I need to look into further and get back to you

>
> A second question I have is, in the above site structure example,
> hitting the URLs of subfolderA/ or subfolderB/ or subfolderC/ will  
> show
> page2.  If I don't want folders without a default page to  
> automatically
> show the first child page it finds, what other options do I have?
>

What do you want to show in your default page, a blank page?

> My apologies if the guides or previous threads had covered this.
>
I



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