portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sean Taylor <da...@bluesunrise.com>
Subject Re: Passing a Collection of Objects to a JSP
Date Tue, 22 Apr 2008 03:47:27 GMT

On Apr 21, 2008, at 1:11 PM, Dan Olsen wrote:

> But how do I get the Collection of object from the doView function  
> to the JSP page?

Here is an example of using JSP and portlet tags, also showing both  
app and portlet session scoping as well:

the JSP view:

<%@ page session="true" contentType="text/html;charset=utf-8"%>
<%@ taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix='c' %>
<%@include file="/WEB-INF/view/include/portletDefineObjects.jsp" %>

<jsp:useBean id="appScoped" scope="session" class="java.lang.String" />
<jsp:useBean id="portltScoped" scope="request"  
class="java.lang.String" />

<form method="POST" action="<portlet:actionURL/>">
     <label for='portletScoped'>Portlet Scope Value:</label>
	<input type="text" name="portletScoped" value='<c:out value="$ 
{portletScoped}"/>' size="20"/>
	<input type="submit" value="Submit"/>

<form method="POST" action="<portlet:actionURL/>">
     <label for='appScopedCount'>Application Scope Value:</label>
	<input type="text" name="appScoped" value='<c:out value="$ 
{appScoped}"/>' size="20"/>	
	<input type="submit" value="Submit"/>

the java doView:

	public void doView(RenderRequest request, RenderResponse response)  
throws PortletException, IOException {
		String portletScoped = (String)
		if (portletScoped == null)
			portletScoped = "";
         request.setAttribute("portletScoped", portletScoped);		
		super.doView(request, response);

the action:

	public void processAction(ActionRequest request, ActionResponse  
response) throws PortletException, IOException
		PortletSession session = request.getPortletSession(true);
		String appScoped = request.getParameter("appScoped");
		if (!StringUtils.isEmpty(appScoped))
			session.setAttribute("appScoped", appScoped,  
		String portletScoped = request.getParameter("portletScoped");
		if (!StringUtils.isEmpty(portletScoped))
			session.setAttribute("portletScoped", portletScoped,  

To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org

View raw message