RE: Asset Publisher View url

Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Hi, i am using liferay 7.2 GA 1

i have a custom asset called post entry i have mapped view url in the template.

when a user click the title of the asset it  is displaying the summary from asset renderer in the same page on the same block.

what i want is when a user click on the title it should redirect in to a new page and display the summary in the allocated block. is it possible ?
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Hi,Can Anyone Help me on this please...
thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
To display assets in a separate page use the setting "show in context" for the "asset link behavior" configuration of the asset publisher.More information about the configuration options can be found in the documentation: https://portal.liferay.dev/docs/7-2/user/-/knowledge_base/u/configuring-display-settings
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
No even though the view in context is set it is not working.because the asset is created in the admin panel and given access to the guest user to view it so unfortunely view in context and view fullcontent both resulting in displaying fullcontent.  is there any other way available like web content to mark the display page for the specific asset ? for custom asset or for category.
thumbnail
Mohammed Yasin, modified 5 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
You can  try  setting  path where to display in AssetRenderer of your custom asset 
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest,LiferayPortletResponse liferayPortletResponse,String noSuchEntryRedirect) {
    return url where u want to show;
}
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Mohammed Yasin:

You can  try  setting  path where to display in AssetRenderer of your custom asset 
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest,LiferayPortletResponse liferayPortletResponse,String noSuchEntryRedirect) {
    return url where u want to show;
}


Yea i have tried that too

my method :
    @Override
    protected String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, String noSuchEntryRedirect,
            String path, String primaryKeyParameterName, long primaryKeyParameterValue) {
        // TODO Auto-generated method stub
        System.out.println("Hello world");
        return super.getURLViewInContext(liferayPortletRequest, noSuchEntryRedirect, path, primaryKeyParameterName,
                primaryKeyParameterValue);
    }
but its no luck when the asset behaviour is set to view in context the above method didnt get called i dont know why.

i tried the same in getURLView also  but it was no luck.
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Arun Pandian:


Yea i have tried that too

   ...     System.out.println("Hello world"); ...
I've seen System.out output being swallowed when running from within eclipse. Try logging instead or set a breakpoint to make extra extra sure that this method is indeed not called - that one fooled me once and took quite some time to resolve, until I figured out that it just doesn't end up in eclipse's console.
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Thanks for the suggestion after some workaround i found that there are 2 method of the same name

have to use,
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest,
            LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) throws Exception {

instead of

    protected String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, String noSuchEntryRedirect,
            String path, String primaryKeyParameterName, long primaryKeyParameterValue) {
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Instead of giving static url can it be done dynamically ? like web contents set a display page such scenerio can be done in liferay 7.2 GA 1

and how to get a static url of a portlet to set in the getviewurlincontext can anyone give me an example please.