Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Akash Mohan Patil
How to get Calender Event URL in Custom Portlet
July 1, 2012 11:18 PM
Answer

Akash Mohan Patil

Rank: Junior Member

Posts: 70

Join Date: December 12, 2010

Recent Posts

Hi Friends,

Inshort I need url for calevent in custom portlet.

I have created one custom portlet to show the upcoming events.

Here i fetched all the Calendar Events list by using CalEventLocalServiceUtil.getEvents() and sorted to upcoming.

Now i am able to show the list of all Events on Portlet, But my Problem is i am not getting how to add url to that events which redirects it to the Corresponding CalEvent.

Tried all possible things. please Help me to solve this problem.




Thanks,
Akash Patil .
Tejas Kanani
RE: How to get Calender Event URL in Custom Portlet
July 2, 2012 4:16 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

Hi Akash,

We've done similar thing in one of our project.
Try below funtion,

 1
 2private String getEventRenderURL(final CalEvent calEvent, final RenderRequest renderRequest)
 3{
 4    String eventRenderURL = StringPool.BLANK;
 5    final ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest
 6            .getAttribute(WebKeys.THEME_DISPLAY);
 7    Layout previewPageLayout = null;
 8    try
 9    {
10        previewPageLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay
11                .getScopeGroup().getGroupId(), false, [b]"/calevent"[/b]);
12    } catch (final Exception e)
13    {
14        LOG.error(e.getMessage());
15    }
16    if (previewPageLayout == null)
17    {
18        eventRenderURL = themeDisplay.getScopeGroup().getFriendlyURL();
19    } else
20    {
21        final PortletURL calEventURL = PortletURLFactoryUtil.create(
22                PortalUtil.getHttpServletRequest(renderRequest), "8",
23                previewPageLayout.getPlid(), "RENDER_PHASE");
24        calEventURL.setParameter("struts_action", "/calendar/view_event");
25        calEventURL.setParameter("eventId", String.valueOf(calEvent.getEventId()));
26        eventRenderURL = calEventURL.toString();
27    }
28    return eventRenderURL;
29}


Where,
"/calevent" is the friendly url of the page where calendar portlet is already exist.

I hope this will be helpful.

Thanks,
TK
Akash Mohan Patil
RE: How to get Calender Event URL in Custom Portlet
July 4, 2012 1:03 AM
Answer

Akash Mohan Patil

Rank: Junior Member

Posts: 70

Join Date: December 12, 2010

Recent Posts

Hi Tejas Kanani,

The code u given worked properly. really it's a big help., Thanks yar emoticon

Thanks,
Akash Patil