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 Edgar Poce <ed...@gmail.com> on 2006/09/10 00:48:47 UTC
How to get the portlet entity path from a portlet request?
Hi,
I'm working in a portlet that provides CMS features backed by JCR
(jsr 170, java content repository), AFAIK jetspeed uses a rdbms to
store the pages and there are some efforts in graffito towards a jcr
implementation. I'd like the content to be stored replicating the
portal hierarchy.
Could anyone help me to implement the following method with j2 api or
portlet api?:
/**
* resolves the path for the given request
*
* @param request
* the portlet request
* @return the path to the portlet entity
*/
public String getPath(PortletRequest theRequest);
One more question, is there any way to add a custom portlet mode in
j2?, I'd like to add a "content" mode to my portlet.
thanks in advance,
edgar
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: How to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
Hi jacek,
On 9/15/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Edgar Poce z 2006-09-15 19:53 brzmiala:
>
> >> > Unfortunately this code only works when the request is a
> >> > RenderRequest, it seems that in ActionRequests the ContentFragment can
> >> > not be retrieved. Is there any way to get the ContentFragment from an
> >> > ActionRequest?
> >> I afraid not :(
> > is there any reason for it not being available in ActionRequests?,
> > shoud I open a JIRA issue?
> See JSR-168 for details...
>
I will, thanks. I guess I'll have to pass the path in a hidden field.
> >> > Another problem is that I can't navigate the hierarchy from a fragment
> >> > to the parent page. There's no method in ContentFragment that allows
> >> > me to get the parent fragment and thus build a path that includes the
> >> > decorator fragments. Is there any way to build that path that I'm
> >> > missing.
> >> As far as I remember, a Fragment implements a Node interface. This
> >> interface ensures getParent() method.
> > Well, as far as I can see the inheritance is something like
> > SecuredResource > BaseElement > Fragment > ContentFragment
> > and none of those interfaces has a method to get the parent.
> You are right, my memory seems to be worse than I thought ;) (Node
> implements BaseElement, not BaseElement implements Node). And what about
> looping throuh all page fragments in order to establish a child-parent
> relationship? A number of page fragments is rather limited (just a few
> ones) and such a process should be efficient, I guess.
>
I'll give it a try.
thank you very much for your help,
edgar
> --
> 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 to get the portlet entity path from a portlet request?
Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Edgar Poce z 2006-09-15 19:53 brzmiala:
>> > Unfortunately this code only works when the request is a
>> > RenderRequest, it seems that in ActionRequests the ContentFragment can
>> > not be retrieved. Is there any way to get the ContentFragment from an
>> > ActionRequest?
>> I afraid not :(
> is there any reason for it not being available in ActionRequests?,
> shoud I open a JIRA issue?
See JSR-168 for details...
>> > Another problem is that I can't navigate the hierarchy from a fragment
>> > to the parent page. There's no method in ContentFragment that allows
>> > me to get the parent fragment and thus build a path that includes the
>> > decorator fragments. Is there any way to build that path that I'm
>> > missing.
>> As far as I remember, a Fragment implements a Node interface. This
>> interface ensures getParent() method.
> Well, as far as I can see the inheritance is something like
> SecuredResource > BaseElement > Fragment > ContentFragment
> and none of those interfaces has a method to get the parent.
You are right, my memory seems to be worse than I thought ;) (Node
implements BaseElement, not BaseElement implements Node). And what about
looping throuh all page fragments in order to establish a child-parent
relationship? A number of page fragments is rather limited (just a few
ones) and such a process should be efficient, I guess.
--
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 to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
On 9/15/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Edgar Poce z 2006-09-15 17:53 brzmiala:
>
> > Unfortunately this code only works when the request is a
> > RenderRequest, it seems that in ActionRequests the ContentFragment can
> > not be retrieved. Is there any way to get the ContentFragment from an
> > ActionRequest?
> I afraid not :(
>
is there any reason for it not being available in ActionRequests?,
shoud I open a JIRA issue?
> > Another problem is that I can't navigate the hierarchy from a fragment
> > to the parent page. There's no method in ContentFragment that allows
> > me to get the parent fragment and thus build a path that includes the
> > decorator fragments. Is there any way to build that path that I'm
> > missing.
> As far as I remember, a Fragment implements a Node interface. This
> interface ensures getParent() method.
>
Well, as far as I can see the inheritance is something like
SecuredResource > BaseElement > Fragment > ContentFragment
and none of those interfaces has a method to get the parent.
br,
edgar
> --
> 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 to get the portlet entity path from a portlet request?
Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Edgar Poce z 2006-09-15 17:53 brzmiala:
> Unfortunately this code only works when the request is a
> RenderRequest, it seems that in ActionRequests the ContentFragment can
> not be retrieved. Is there any way to get the ContentFragment from an
> ActionRequest?
I afraid not :(
> Another problem is that I can't navigate the hierarchy from a fragment
> to the parent page. There's no method in ContentFragment that allows
> me to get the parent fragment and thus build a path that includes the
> decorator fragments. Is there any way to build that path that I'm
> missing.
As far as I remember, a Fragment implements a Node interface. This
interface ensures getParent() method.
--
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 to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
Hi,
I was able to build a path to the fragment of type portlet with the
following code:
public String getPath(PortletContext context, PortletRequest request) {
try {
String path = ((RequestContext)
request.getAttribute(RequestContext.REQUEST_PORTALENV)).getPath();
ContentFragment contentFragment = (ContentFragment)
request.getAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE);
return path + contentFragment.getId();
...
Unfortunately this code only works when the request is a
RenderRequest, it seems that in ActionRequests the ContentFragment can
not be retrieved. Is there any way to get the ContentFragment from an
ActionRequest?
Another problem is that I can't navigate the hierarchy from a fragment
to the parent page. There's no method in ContentFragment that allows
me to get the parent fragment and thus build a path that includes the
decorator fragments. Is there any way to build that path that I'm
missing.
One more question, am I trying to use the portal for a use case that
is not recommendable?. I mean that I see the portal as an integration
application, among lots of other things it provides a site hierarchy
to navigate contents. I'm trying to integrate my contents with that
hierarchy, is it a wrong practice?.
br,
edgar
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: How to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
hi Jacek,
On 9/12/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Edgar Poce z 2006-09-12 18:45 brzmiala:
>
> > My main problem is how to get the path from a PortletRequest, see the
> > method in my first post. Once I get that path to the *fragment* of
> > type portlet the snippet bellow will surely help me.
> RequestContext requestContext =
> (RequestContext)request.getAttribute(RequestContext.REQUEST_PORTALENV);
> String currentPage = requestContext.getPortalURL().getBasePath() +
> requestContext.getPath();
>
I think this is what I'm looking for :), I'll try it ASAP.
thanks,
edgar
> --
> 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 to get the portlet entity path from a portlet request?
Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Edgar Poce z 2006-09-12 18:45 brzmiala:
> My main problem is how to get the path from a PortletRequest, see the
> method in my first post. Once I get that path to the *fragment* of
> type portlet the snippet bellow will surely help me.
RequestContext requestContext =
(RequestContext)request.getAttribute(RequestContext.REQUEST_PORTALENV);
String currentPage = requestContext.getPortalURL().getBasePath() +
requestContext.getPath();
--
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 to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
Hi Jacek,
On 9/12/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Edgar Poce z 2006-09-12 17:58 brzmiala:
>
> > Sorry I wasn't clear, let me try again :). I'd like the portlet to
> > know the path where it's deployed in the portal site hierarchy. The
> > above method should return the path to the fragment of type portlet
> > where the portlet was added. E.g. if I deploy a wysiwyg portlet at
> > /default.psml I'd like to get the path to the fragment of type portlet
> > where the portlet is shown. Something like "/default.psml/twocolumns
> > fragment-id1/portlet fragment-id12/".
> Start with PageManager. It can retrieve a node corresponding to any page
> by its path:
> Page page pageManager.getPage(path);
My main problem is how to get the path from a PortletRequest, see the
method in my first post. Once I get that path to the *fragment* of
type portlet the snippet bellow will surely help me.
thanks,
edgar
> A Page object can retrieve its root fragment with:
> Fragment = page.getRootFragment();
> Once you have a fragment (e.g. the root one), you can get all its
> children with the following method:
> protected List listFragments(Fragment rootFragment, String type, List list)
> {
> List fragments = rootFragment.getFragments();
> for(Iterator iterator = fragments.iterator(); iterator.hasNext();)
> {
> Fragment fragment = (Fragment)iterator.next();
> if(fragment.getType().equals(type))
> list.add(fragment);
>
> listFragments(fragment, type, list);
> }
>
> return list;
> }
> The method retrieves recursively all the subfragments of a give type
> (i.e. Fragment.PORTLET, Fragment.LAYOUT). I hope this example helps 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 to get the portlet entity path from a portlet request?
Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Edgar Poce z 2006-09-12 17:58 brzmiala:
> Sorry I wasn't clear, let me try again :). I'd like the portlet to
> know the path where it's deployed in the portal site hierarchy. The
> above method should return the path to the fragment of type portlet
> where the portlet was added. E.g. if I deploy a wysiwyg portlet at
> /default.psml I'd like to get the path to the fragment of type portlet
> where the portlet is shown. Something like "/default.psml/twocolumns
> fragment-id1/portlet fragment-id12/".
Start with PageManager. It can retrieve a node corresponding to any page
by its path:
Page page pageManager.getPage(path);
A Page object can retrieve its root fragment with:
Fragment = page.getRootFragment();
Once you have a fragment (e.g. the root one), you can get all its
children with the following method:
protected List listFragments(Fragment rootFragment, String type, List list)
{
List fragments = rootFragment.getFragments();
for(Iterator iterator = fragments.iterator(); iterator.hasNext();)
{
Fragment fragment = (Fragment)iterator.next();
if(fragment.getType().equals(type))
list.add(fragment);
listFragments(fragment, type, list);
}
return list;
}
The method retrieves recursively all the subfragments of a give type
(i.e. Fragment.PORTLET, Fragment.LAYOUT). I hope this example helps 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 to get the portlet entity path from a portlet request?
Posted by David Sean Taylor <da...@bluesunrise.com>.
Edgar Poce wrote:
> Hi,
>
> On 9/12/06, David Sean Taylor <da...@bluesunrise.com> wrote:
>
>> Edgar Poce wrote:
>> > Could anyone help me to implement the following method with j2 api or
>> > portlet api?:
>> >
>> > /**
>> > * resolves the path for the given request
>> > *
>> > * @param request
>> > * the portlet request
>> > * @return the path to the portlet entity
>> > */
>> > public String getPath(PortletRequest theRequest);
>>
>> Let me understand, you want to make the URL available to portlets and
>> then return "the path to the portlet entity"?
>>
>> Im not sure if I follow...
>>
>
> Sorry I wasn't clear, let me try again :). I'd like the portlet to
> know the path where it's deployed in the portal site hierarchy. The
> above method should return the path to the fragment of type portlet
> where the portlet was added. E.g. if I deploy a wysiwyg portlet at
> /default.psml I'd like to get the path to the fragment of type portlet
> where the portlet is shown. Something like "/default.psml/twocolumns
> fragment-id1/portlet fragment-id12/".
That is not a part of the standard.
Jetspeed does provide a non-standard way to access a fragment using the
portlet pipeline. Here is an example of getting the content of the
locale selector portlet on the sample portal home page:
http://localhost:8080/jetspeed/portlet/default-page.psml?entity=dp-3&portlet=j2-admin::LocaleSelector
Take a look at the Jetspeed Desktop, as it using the portlet pipeline to
do client side aggregation
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: How to get the portlet entity path from a portlet request?
Posted by Edgar Poce <ed...@gmail.com>.
Hi,
On 9/12/06, David Sean Taylor <da...@bluesunrise.com> wrote:
> Edgar Poce wrote:
> > Could anyone help me to implement the following method with j2 api or
> > portlet api?:
> >
> > /**
> > * resolves the path for the given request
> > *
> > * @param request
> > * the portlet request
> > * @return the path to the portlet entity
> > */
> > public String getPath(PortletRequest theRequest);
>
> Let me understand, you want to make the URL available to portlets and
> then return "the path to the portlet entity"?
>
> Im not sure if I follow...
>
Sorry I wasn't clear, let me try again :). I'd like the portlet to
know the path where it's deployed in the portal site hierarchy. The
above method should return the path to the fragment of type portlet
where the portlet was added. E.g. if I deploy a wysiwyg portlet at
/default.psml I'd like to get the path to the fragment of type portlet
where the portlet is shown. Something like "/default.psml/twocolumns
fragment-id1/portlet fragment-id12/".
With this path I can integrate the content of the wysiwyg portlet to
the portal site hierarchy and users might access the content from
other interfaces than the portal, e.g. via webdav, with a URL
consistent with the portal.
If fragments had names the http URL to edit the content via webdav
would look like: http://myjetspeed.com/default.psml/App and help in
two columns/help/content.html
> >
> > One more question, is there any way to add a custom portlet mode in
> > j2?, I'd like to add a "content" mode to my portlet.
>
> Look into how we implemented the custom Print Mode.
> See jetspeed.properties for starters where extended portlet modes and
> window states are defined.
>
thanks for your help,
edgar
> ---------------------------------------------------------------------
> 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: How to get the portlet entity path from a portlet request?
Posted by David Sean Taylor <da...@bluesunrise.com>.
Edgar Poce wrote:
> Hi,
>
> I'm working in a portlet that provides CMS features backed by JCR
> (jsr 170, java content repository), AFAIK jetspeed uses a rdbms to
> store the pages and there are some efforts in graffito towards a jcr
> implementation. I'd like the content to be stored replicating the
> portal hierarchy.
>
> Could anyone help me to implement the following method with j2 api or
> portlet api?:
>
> /**
> * resolves the path for the given request
> *
> * @param request
> * the portlet request
> * @return the path to the portlet entity
> */
> public String getPath(PortletRequest theRequest);
Let me understand, you want to make the URL available to portlets and
then return "the path to the portlet entity"?
Im not sure if I follow...
>
> One more question, is there any way to add a custom portlet mode in
> j2?, I'd like to add a "content" mode to my portlet.
Look into how we implemented the custom Print Mode.
See jetspeed.properties for starters where extended portlet modes and
window states are defined.
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org