• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Not able to send data from one struts portlet to another struts portlet

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typically, porlets can't talk to each other. If they are in a common war, they can share information through the APPLICATION_SCOPE of the Session, but even that can be tricky with a Struts portlet.

If your portlets are packaged in separate war files, standard development won't allow them to communicate. You need to roll your own solution. A shared database table is a common way to allow portlets to share information. For IBM Portlets, you can use the PortletService.

-Cameron McKenzie
 
Bharath Gowda
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Cameron. We decided to use JSR 168 basic portlets instead of using struts portlets.
 
Are you here to take over the surface world? Because this tiny ad will stop you!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic