RE: Getting "view in context" URL in custom search portlet

thumbnail
Steve Weiss, modified 8 Years ago. Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts
I've created a custom search portlet that searches blogs, bookmarks, document library, message boards, web content, and wiki pages. The results are displayed in a table with links generated by an AssetRenderer. One of the links is for "View in Context", this link works fine for all asset types except document library entries. Clicking on the link of a document result leads to the results page simply being re-loaded. However, if my search portlet is in a different site than the Document Library portlet, the link works correctly- it takes the user to the DL portlet showing the document details.

Here is a snippet of my code:

AssetRenderer renderer = asset.getAssetRenderer();
PortletURL purl = renderer.getURLView((LiferayPortletResponse) response, WindowState.MAXIMIZED);
entry.setUrlView(purl);
String urlviewincontext = renderer.getURLViewInContext((LiferayPortletRequest) request, (LiferayPortletResponse) response, null);
_log.debug("urlViewInContext: " + urlviewincontext);
entry.setUrlViewInContext(urlviewincontext);
PortletURL editurl = renderer.getURLEdit((LiferayPortletRequest) request, (LiferayPortletResponse) response);
_log.debug("Edit URL: " + editurl.toString());

The URL appears to be mostly the same as the one shown in the out of the box Liferay search portlet, except I am not setting the "noSuchEntryRedirect" parameter when I call AssetRenderer.getURLViewInContext().

Liferay search URL:
http://localhost:8180/c/document_library/find_file_entry?p_l_id=20586&noSuchEntryRedirect=http%3A%2F%2Flocalhost%3A8180%2Fweb%2Fscienceworks%2Fmain%3Fp_p_auth%3D5BDmDClj%26p_p_id%3D101%26p_p_lifecycle%3D0%26p_p_state%3Dmaximized%26p_p_mode%3Dview%26_101_struts_action%3D%252Fasset_publisher%252Fview_content%26_101_returnToFullPageURL%3D%252Fweb%252Fscienceworks%252Fmain%26_101_assetEntryId%3D20777%26_101_type%3Ddocument%26redirect%3Dhttp%253A%252F%252Flocalhost%253A8180%252Fweb%252Fscienceworks%252Fmain%253Fp_p_id%253D3%2526p_p_lifecycle%253D0%2526p_p_state%253Dmaximized%2526p_p_mode%253Dview%2526_3_redirect%253D%25252Fweb%25252Fscienceworks%25252Fmain%2526_3_keywords%253Dtest7%2526_3_groupId%253D0%2526_3_struts_action%253D%25252Fsearch%25252Fsearch&fileEntryId=20775&inheritRedirect=true

My URL:
http://localhost:8180/c/document_library/find_file_entry?p_l_id=20618&noSuchEntryRedirect=null&fileEntryId=20775

Any help would be greatly appreciated.
thumbnail
Marco Azzalini, modified 8 Years ago. Regular Member Posts: 146 Join Date: 11/18/14 Recent Posts
Hi Steve, did you find any solution? I have the same problem here (Liferay 6.2) with my custom ADT.
The weird thing is that the link for the documents worked for weeks but now, after some modifications to the page, it doesn't work anymore,
and in my case, the url generated by assetRenderer.getURLViewInContext has also the noSuchEntry correctly set.

Let me know if you find something useful.

Marco
thumbnail
Steve Weiss, modified 8 Years ago. Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts
Marco Azzalini:
Hi Steve, did you find any solution? I have the same problem here (Liferay 6.2) with my custom ADT.
The weird thing is that the link for the documents worked for weeks but now, after some modifications to the page, it doesn't work anymore,
and in my case, the url generated by assetRenderer.getURLViewInContext has also the noSuchEntry correctly set.

Let me know if you find something useful.

Marco



No, I haven't found a solution. We're moving to Liferay 7 so I've been focusing on that recently.
thumbnail
Marco Azzalini, modified 8 Years ago. Regular Member Posts: 146 Join Date: 11/18/14 Recent Posts
Steve Weiss:
No, I haven't found a solution. We're moving to Liferay 7 so I've been focusing on that recently.


Hi Steve, I found the solution (!) and looking at yours urls, I think you fallen on the same problem, so it should be useful also for you.
Going back to our problem, the solution concerns the plid parameter. In my case, it turned out that after an import of one page, the new page with a different name was binded to the plid of a previous one ( I don't know why, probably because the friendly url was the same). Deleting that page and importing it again did the trick ;-)
I am not sure if this can solve also your problema but, if you still have the LR 6.2 available, give it a try and let me know.

regards,
Marco
thumbnail
Steve Weiss, modified 8 Years ago. Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts
Marco Azzalini:
Steve Weiss:
No, I haven't found a solution. We're moving to Liferay 7 so I've been focusing on that recently.


Hi Steve, I found the solution (!) and looking at yours urls, I think you fallen on the same problem, so it should be useful also for you.
Going back to our problem, the solution concerns the plid parameter. In my case, it turned out that after an import of one page, the new page with a different name was binded to the plid of a previous one ( I don't know why, probably because the friendly url was the same). Deleting that page and importing it again did the trick ;-)
I am not sure if this can solve also your problema but, if you still have the LR 6.2 available, give it a try and let me know.

regards,
Marco



Marco, thank you. I will give this a try as soon as I get the chance. It sounds like it could be the same issue.
Vishnu S Kumar, modified 7 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts

Did you find any solution for this?