Fórum
How to get the url to a portlet?
Cameron McBride, modificado 11 Anos atrás.
How to get the url to a portlet?
Expert Postagens: 269 Data de Entrada: 08/02/11 Postagens Recentes
I am wanting to get the url to a portlet, so when the user clicks the link in portlet X it shows portlet Y full screen. I copied the below code and tweaked it from the "Create Account" code in login.jsp
"helloWorld_WAR_HelloWorldPortlet" is the name of the portlet if you look in the plugins configuration in Liferay. When I click the link I end up with the Liferay junk at the top and no portlet at all.
The generated URL is:
http://localhost:8080/web/guest/home?p_p_id=helloWorld_WAR_HelloWorldPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1
PortletURL myUrl = PortletURLFactoryUtil.create(
request, "helloWorld_WAR_HelloWorldPortlet", themeDisplay.getPlid(),
PortletRequest.RENDER_PHASE);
myUrl.setWindowState(WindowState.MAXIMIZED);
myUrl.setPortletMode(PortletMode.VIEW);
"helloWorld_WAR_HelloWorldPortlet" is the name of the portlet if you look in the plugins configuration in Liferay. When I click the link I end up with the Liferay junk at the top and no portlet at all.
The generated URL is:
http://localhost:8080/web/guest/home?p_p_id=helloWorld_WAR_HelloWorldPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1
Pinkesh Gandhi, modificado 11 Anos atrás.
RE: How to get the url to a portlet?
Junior Member Postagens: 99 Data de Entrada: 27/01/12 Postagens RecentesThe generated URL is:
http://localhost:8080/web/guest/home?p_p_id=helloWorld_WAR_HelloWorldPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1
This is correct url for your portlet.
If you are using MVCPortlet / GenericPortlet then can you please attach the code of the doView(...) method of your portlet.
biswajit sarkar, modificado 11 Anos atrás.
RE: How to get the url to a portlet?
Regular Member Postagens: 166 Data de Entrada: 17/10/11 Postagens Recentes
use this code.....
public String renderPortlet1()throws Exception{
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
PortletRequest pReq = (PortletRequest)ec.getRequest();
String portletInstaceId = getNameSpaceOfExistingComments(pReq, UniqueId);
final ThemeDisplay themeDisplay = (ThemeDisplay) pReq.getAttribute(WebKeys.THEME_DISPLAY);
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(pReq);
httpRequest = PortalUtil.getOriginalServletRequest(httpRequest);
PortletURL portletURL = PortletURLFactoryUtil.create(httpRequest ,portletInstaceId, themeDisplay.getPlid() ,PortletRequest.RENDER_PHASE);
portletURL.setWindowState(WindowState.MAXIMIZED);
portletURL.setPortletMode(PortletMode.VIEW);
portletURL.setParameter(portletInstaceId, "docroot/xhtml/nav1/portletViewMode.xhtml");
return portletURL.toString();
}
Cameron McBride, modificado 11 Anos atrás.
RE: How to get the url to a portlet?
Expert Postagens: 269 Data de Entrada: 08/02/11 Postagens RecentesPinkesh Gandhi:
If you are using MVCPortlet / GenericPortlet then can you please attach the code of the doView(...) method of your portlet.
That may be the problem. I have a requirement to use SpringMVC, with no ties to Liferay API, except for the few property files that are required. My controller looks like this:
@Controller
@RequestMapping("VIEW")
public class HelloWorldController {
@RenderMapping()
public String helloWorld(RenderResponse response) {
return "index";
}
}
The portlet works great if you drag-n-drop it onto a page.
UPDATE:
I thought I should note that I am trying to show this portlet from another portlet. For example portlet x is on a page and portlet y is not. You click portlet x and it displays portlet y maximized.
In the login.jsp/create account example that I mimicked the portlet being maximized was the same as the portlet being used, not a different portlet.
Pinkesh Gandhi, modificado 11 Anos atrás.
RE: How to get the url to a portlet?
Junior Member Postagens: 99 Data de Entrada: 27/01/12 Postagens Recentes
Hi Cameron,
Try with following scenario,
(1) Create one Page - Page ABC
(2) Put your portlet X on page ABC
(3) Create another Page in same community/organization and keep it Hidden - Page PQR
(4) Put your portlet Y on Page PQR
Now in your portlet X, create one PortletURL to display portlet Y from it and at that time you need to pass plId of the page PQR as a parameter(you can get plId of any page by using LayoutLocalServiceUtil).
For e.g.,
Now use this muUrl on a jsp of portlet X.
So when you click on the link/button the page PQR will be opened containing portlet Y in maximized mode.
I hope this may resolves your problem.
Let me know if you have any query.
Try with following scenario,
(1) Create one Page - Page ABC
(2) Put your portlet X on page ABC
(3) Create another Page in same community/organization and keep it Hidden - Page PQR
(4) Put your portlet Y on Page PQR
Now in your portlet X, create one PortletURL to display portlet Y from it and at that time you need to pass plId of the page PQR as a parameter(you can get plId of any page by using LayoutLocalServiceUtil).
For e.g.,
PortletURL myUrl = PortletURLFactoryUtil.create(
request, "helloWorld_WAR_HelloWorldPortlet", "<plid-of-the-page-pqr>", PortletRequest.RENDER_PHASE);
myUrl.setWindowState(WindowState.MAXIMIZED);
myUrl.setPortletMode(PortletMode.VIEW);
</plid-of-the-page-pqr>
Now use this muUrl on a jsp of portlet X.
So when you click on the link/button the page PQR will be opened containing portlet Y in maximized mode.
I hope this may resolves your problem.
Let me know if you have any query.
Cameron McBride, modificado 11 Anos atrás.
RE: How to get the url to a portlet?
Expert Postagens: 269 Data de Entrada: 08/02/11 Postagens Recentes
I needed to add the following to my liferay-portlet.xml file:
After that it worked perfectly!
<add-default-resource>true</add-default-resource>
After that it worked perfectly!