In my application, I need to access the remote applications (The application which is running on other tomcat instance) dynamically in my portlet. So I have created the portlet in view and edit mode so that I am able see the "preferences" option in portlet setting options. my preference page has three input fields with submit button. Now based on the input fields I need to render my portlet content. On click of submit button I am able to get the URL in configuraionActionImpl
class. Now I can I set the portlet view as that URL web page content? Let's say in preferences If user enters "http://localhost:8080/Myapp/events" and on click of submit button in preference configation page then the portlet view should be changed to events page of Myapp application, If user wants to modify the URL from "http://localhost:8080/Myapp/events" to "http://localhost:8080/Myapp/tasks" and on click of submit button in preference page of the config page, Then the portlet view should render the Tasks page.
portlet.xml
<portlet-name>FRunner</portlet-name>
<display-name>FRunner</display-name>
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
<init-param>
<name>view-template</name>
<value>/view.jsp</value>
</init-param>
<init-param>
<name>config-template</name>
<value>/preferences.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
liferay-portlet.xml
<liferay-portlet-app>
<portlet>
<portlet-name>FRunner</portlet-name>
<icon>/icon.png</icon>
<configuration-action-class>com.demo.formrunner.ConfigurationActionImpl</configuration-action-class>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>FRunner-portlet</css-class-wrapper>
</portlet>
</liferay-portlet-app>
preferences.jsp
<portletefineObjects />
<liferay-portlet:actionURL portletConfiguration="true" var="configurationURL" />
<aui:form action="<%= configurationURL %>" method="post">
<aui:fieldset label="Form Runner Portlet Settings">
<aui:layout>
<aui:column>
<aui:input type="text" name="url" label="URL:" inlineLabel="true"/>
</aui:column>
<aui:button-row>
<aui:button type="submit" value="Submit"/>
<aui:button type="button" value="Cancel" last="true"/>
</aui:button-row>
</aui:layout>
</aui:fieldset>
</aui:form>
ConfigurationActionImpl.java
package com.demo.formrunner;
public class ConfigurationActionImpl extends DefaultConfigurationAction {
@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
super.processAction(portletConfig, actionRequest, actionResponse);
PortletPreferences prefs = actionRequest.getPreferences();
String urlVal= prefs.getValue("url", "");
System.out.println("URL Value is" + urlVal); // able to get the url value here. Now How to update the portlet view with this URL
}
}
1) How do I need to render my portlet view based on the input URL? the URL should be like http request (http://localhost:8080/Demo/myPage)
Please suggest me the guidelines to archive the same.