Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Generate Friendly URL through programatically Craeted URL
Hi everyone ,
I am learning generating friendly URL , in that I am getting some problems like , If I create my url on tag based then I am getting correctly friendlyURL which I excepected , but If go with programatically URL then Liferay not generating friendly URL .. Anyone faced this issue ?
<portlet:renderURL var="testURL">
<portlet:param name="mvcRenderCommandName" value="render/viewData"></portlet:param>
<portlet:param name="userName" value="John"></portlet:param>
</portlet:renderURL>
In above case I am getting perfectlty friendly URL , But in below case same URL I am creating through Programmatically , then its not generating any friendly URL and I am getting that old large URL only .
Layout testLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getLayout().getGroup().getGroupId(), true, "/test-URL");
LiferayPortletURL testUrl = PortletURLFactoryUtil.create(request, "frienddemoclass",testLayout.getPlid(), PortletRequest.RENDER_PHASE);
testUrl .setParameter("userName", "John");
testUrl .setParameter("mvcRenderCommandName", "render/viewData");
anyone having idea , how can we generate friendlyURL when work with programatic URL ?
I am learning generating friendly URL , in that I am getting some problems like , If I create my url on tag based then I am getting correctly friendlyURL which I excepected , but If go with programatically URL then Liferay not generating friendly URL .. Anyone faced this issue ?
<portlet:renderURL var="testURL">
<portlet:param name="mvcRenderCommandName" value="render/viewData"></portlet:param>
<portlet:param name="userName" value="John"></portlet:param>
</portlet:renderURL>
In above case I am getting perfectlty friendly URL , But in below case same URL I am creating through Programmatically , then its not generating any friendly URL and I am getting that old large URL only .
Layout testLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getLayout().getGroup().getGroupId(), true, "/test-URL");
LiferayPortletURL testUrl = PortletURLFactoryUtil.create(request, "frienddemoclass",testLayout.getPlid(), PortletRequest.RENDER_PHASE);
testUrl .setParameter("userName", "John");
testUrl .setParameter("mvcRenderCommandName", "render/viewData");
anyone having idea , how can we generate friendlyURL when work with programatic URL ?
Hi everyone ,
I reached next step now , But here I am getting some issues
http://locacourse:7080/welcome/-/UserProfile/ERZ4txCK76tp/selectedPackageDetail?p_p_state=maximized&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_subscriptionPackageId=4&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_isPackageSubscribe=false
How can I hide Parameters subscriptionPackageId , isPackageSubscribe and p_p_state in URL ?
we cannot go with <ignored-parameter> because it removes from request object , I want to hide this parameters from URL only , because we are using this parameter values in Controller .
below I am adding my route info. -
I reached next step now , But here I am getting some issues
http://locacourse:7080/welcome/-/UserProfile/ERZ4txCK76tp/selectedPackageDetail?p_p_state=maximized&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_subscriptionPackageId=4&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_isPackageSubscribe=false
How can I hide Parameters subscriptionPackageId , isPackageSubscribe and p_p_state in URL ?
we cannot go with <ignored-parameter> because it removes from request object , I want to hide this parameters from URL only , because we are using this parameter values in Controller .
below I am adding my route info. -
- <route>
- <pattern>/{instanceId}/selectedPackageDetail</pattern>
- <ignored-parameter name="p_p_mode" />
- <ignored-parameter name="p_auth" />
- <ignored-parameter name="p_p_id" />
- <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
- <implicit-parameter name="mvcRenderCommandName">/userprofileassociates/fetch-package-detail</implicit-parameter>
- </route>
I think you cannot "hide" those parameters, because the information needs to be somewhere.
If you want to shorten the URL you could think of adding those parameters as part of the URL or define them as implicit parameters (e.g p_p_state=maximized) . For example like this:
If you want to shorten the URL you could think of adding those parameters as part of the URL or define them as implicit parameters (e.g p_p_state=maximized) . For example like this:
<route>
<pattern>/{instanceId}/selectedPackageDetail/{subscriptionPackageId}/{isPackageSubscribe}</pattern>
<ignored-parameter name="p_p_mode" />
<ignored-parameter name="p_auth" />
<ignored-parameter name="p_p_id" />
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="mvcRenderCommandName">/userprofileassociates/fetch-package-detail</implicit-parameter>
<implicit-parameter name="p_p_state">maximized</implicit-parameter>
</route>
Hi Dominik sir ,
Thanks for valuable suggestion , I tried above approach but after above approach I am seeing mvcRenderCommandName also came in friendly URL
/-/UserProfile/ERZ4txCK76tp/PackageDetails?p_p_state=maximized&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_mvcRenderCommandName=%2Fuserprofileassociates%fetch-package-detail&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_subscriptionPackageId=4&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_isPackageSubscribe=false
Do u have any other approach to make more less the URL to hidding parameters ?
Thanks & Regards,
Pradip
Thanks for valuable suggestion , I tried above approach but after above approach I am seeing mvcRenderCommandName also came in friendly URL
/-/UserProfile/ERZ4txCK76tp/PackageDetails?p_p_state=maximized&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_mvcRenderCommandName=%2Fuserprofileassociates%fetch-package-detail&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_subscriptionPackageId=4&_UserProfileAssociatesPortlet_INSTANCE_ERZ4txCK76tp_isPackageSubscribe=false
Do u have any other approach to make more less the URL to hidding parameters ?
Thanks & Regards,
Pradip
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™