Foren
Submit Form to same portlet in other page
Greg L, geändert vor 12 Jahren.
Submit Form to same portlet in other page
New Member Beitrag: 1 Beitrittsdatum: 17.02.12 Neueste Beiträge
Hi,
I have a portal with several pages. One of them (/home) contains a search portlet which sends the results to another portlet using IPC. I want to use the first portlet in another page and redirect to the home page. How may I do that?
Here's the code of my portlet :
search.jsp :
Thanks !
I have a portal with several pages. One of them (/home) contains a search portlet which sends the results to another portlet using IPC. I want to use the first portlet in another page and redirect to the home page. How may I do that?
Here's the code of my portlet :
search.jsp :
<portlet:defineobjects />
<%
String query = (String) renderRequest.getPortletSession().getAttribute("search");
%>
<form method="post" action="<portlet:actionURL name=" simpleSearch">" class="search-simple">
<aui:input label=" " inlineLabel="true" type="text" name="query" value="<%=query%>" />
<aui:button type="submit" name="search" value="Ok" cssClass="search-button" />
</form>
Thanks !
sridhar iyer, geändert vor 12 Jahren.
RE: Submit Form to same portlet in other page
Junior Member Beiträge: 57 Beitrittsdatum: 27.02.09 Neueste Beiträge
Greg,
If you want to use IPC for the portlets in different page then you can try this :
private boolean callPortlet(ActionMapping mapping, ActionForm form,
PortletConfig config, ActionRequest req, ActionResponse res)
throws Exception {
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
HttpSession session = httpReq.getSession(true);
long plid = getPortletId(plidName);
PortletURL url1 = new PortletURLImpl(httpReq,
"Yourporltlet_Name", plid, PortletRequest.ACTION_PHASE);
url1.setWindowState(WindowState.NORMAL);
res.sendRedirect(url1.toString());
return true;
}
public static long getPortletId(String portletId) {
PortletPreferences prfs = null;
try {
DetachedCriteria dCriteria = DetachedCriteria
.forClass(PortletPreferences.class);
dCriteria.add(Restrictions.eq("portletId", portletId));
DynamicQuery dynamicQuery = new DynamicQueryImpl(dCriteria);
List list = PortletPreferencesLocalServiceUtil.dynamicQuery(dynamicQuery);
if (!list.isEmpty()) {
prfs = (PortletPreferences) list.get(0);
}
return prfs.getPlid();
} catch (Exception e) {
e.printStackTrace();
}
return 0l;
}
If you want to use IPC for the portlets in different page then you can try this :
private boolean callPortlet(ActionMapping mapping, ActionForm form,
PortletConfig config, ActionRequest req, ActionResponse res)
throws Exception {
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
HttpSession session = httpReq.getSession(true);
long plid = getPortletId(plidName);
PortletURL url1 = new PortletURLImpl(httpReq,
"Yourporltlet_Name", plid, PortletRequest.ACTION_PHASE);
url1.setWindowState(WindowState.NORMAL);
res.sendRedirect(url1.toString());
return true;
}
public static long getPortletId(String portletId) {
PortletPreferences prfs = null;
try {
DetachedCriteria dCriteria = DetachedCriteria
.forClass(PortletPreferences.class);
dCriteria.add(Restrictions.eq("portletId", portletId));
DynamicQuery dynamicQuery = new DynamicQueryImpl(dCriteria);
List list = PortletPreferencesLocalServiceUtil.dynamicQuery(dynamicQuery);
if (!list.isEmpty()) {
prfs = (PortletPreferences) list.get(0);
}
return prfs.getPlid();
} catch (Exception e) {
e.printStackTrace();
}
return 0l;
}