Hi,
I'm new to portlet development. I'm trying to send data from one
struts portlet to another struts portlet but it is giving error.
struts-config.xml
************************************
<!-- Form Beans -->
<form-beans>
<form-bean name="SelectForm" type="com.gdnindia.strutsnav.forms.SelectForm">
</form-bean>
</form-beans>
<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>
<!-- Global Forwards -->
<global-forwards>
</global-forwards>
<!-- Action Mappings -->
<action-mappings>
<action path="/SendData" type="com.gdnindia.strutsnav.actions.SendDataAction" name="SelectForm" scope="request">
<forward contextRelative="false" name="success" path="/successpage.jsp">
</forward>
</action>
</action-mappings>
***********************************************
index.jsp
********************************************
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<portlet
efineObjects/>
<h3><br>
Select a Team:</h3>
<html:form action="/SendData">
<html:select property="selectedItem" onchange="this.form.submit();">
<html
ption value="TeamA">Team A</html
ption>
<html
ption value="TeamB">Team B</html
ption>
<html
ption value="TeamC">Team C</html
ption>
<html
ption value="TeamD">Team D</html
ption>
<table>
<tbody>
<tr>
<td align="left">SelectedItem:</td>
<td><c
ut value="${sessionScope.selectedItem}" /></td>
</tr>
</tbody>
</table>
</html:select>
</html:form>
**********************************
successpage.jsp
************************************
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="javax.portlet.PortletSession"%>
<portlet
efineObjects />
<% PortletSession s = renderRequest.getPortletSession();
String data = (String) s.getAttribute("javax.portlet.request");
if (data == null || data.length() == 0)
data = "no data found"; %>
<h3>Team selected is:</h3>
<table>
<tbody>
<tr>
<td align="left">SelectedItem:</td>
<td><c
ut value="${data}" /></td>
</tr>
</tbody>
</table>
***************************************
SendDataAction.java
**************************************
public class SendDataAction extends StrutsAction implements IStrutsPrepareRender
{
public ActionForward execute(ActionMapping mapping, ActionForm form, PortletRequest request, PortletResponse response)
throws Exception {
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value
try {
System.out.println(" ---- Entering SendDataAction to retrive the value---");
PortletSession psession = request.getPortletSession();
//RenderRequest pReq = (RenderRequest) request
//.getAttribute("javax.portlet.request");
RenderResponse rRes = (RenderResponse) request
.getAttribute("javax.portlet.response");
//PortletConfig portletConfig = (PortletConfig) request.getAttribute("javax.portlet.config");
String teamname = request.getParameter("selectedItem");
System.out.println("***Team Name VALUE ***" + teamname);
psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE);
System.out.println("***Team Name VALUE ***" + psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE));
rRes.getPortletOutputStream();
System.out.println("***Leaving SendDataAction to retrive the value***");
} catch (Exception e) {
**************************************
SelectForm.java
************************************
public class SelectForm extends ActionForm
{
/**
*
*/
private static final long serialVersionUID = -6313074275445304102L;
private String SelectedItem = null;
/**
* Get SelectedItem
* @return String
*/
public String getSelectedItem() {
return SelectedItem;
}
/**
* Set SelectedItem
* @param <code>String</code>
*/
public void setSelectedItem(String s) {
this.SelectedItem = s;
}
}
**************************
I'm trying to do this from 2 days. but i'm getting "400 Invalid path /SendData was requested" error...I'm going crazy, Please let me know what is wrong with the implementation. I'm using IBM RAD 7.0, Websphere portal 6.0 server
Or if you have any sample code to implement this, please share it with me.