You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Tuan H. Le" <tu...@phsadc.com> on 2002/10/20 21:22:34 UTC
return false
Hi,
In my Action class I set an object in one of the session attribute before forwarding to a JSP view. But, the <logic:present> in the JSP view always return false on that object.
Below is my code. Do you know what I'm missing? employeeList is an ArrayList object.
If I use a for loop below (see comment code block), then it finds the employeeList and return the right data from that array object.
Thanks,
Tuan
**************** My Action code ***********************
...
session.setAttribute( USER_EMPLOYEE_LIST_KEY, employeeList );
// Forward to the appropriate View
return ( mapping.findForward( target ) );
********* My JSP page *********************************
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.phs.ezhr.business.vo.EmployeeVO" %>
<%@ page import="com.phs.ezhr.constant.IConstants" %>
<%
ArrayList employeeList = (ArrayList)session.getAttribute( IConstants.USER_EMPLOYEE_LIST_KEY );
// *************************************************
// THIS CODE WORK, BUT THE <logic:present> does not work
// *************************************************
//for ( int i = 0; i < employeeList.size(); i++ ) {
// out.println( "i = " + i + "<BR>" );
// EmployeeVO e = (EmployeeVO)employeeList.get( i );
// out.println( "Employee ID --> " + e.getEmployeeId() + "<BR>");
//}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<link rel="stylesheet" type="text/css" href="common/styles/styleMid.css">
<html:html locale="true" >
<head>
<html:base/>
<title><bean:message key="app.label.title" /></title>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" style="margin: 0px 0px 0px 0px;">
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
<tr>
<td bgcolor="#F9B949" width="17"> </td>
<td valign="top">
<table cellspacing="0" cellpadding="0" border="0">
<logic:present name="employeeList" scope="session">
<!-- Iterate over the results of the query -->
<logic:iterate name="employeeList" id="employee" scope="session" type="com.phs.ezhr.business.vo.EmployeeVO" indexId="idx">
....
</logic:iterate>
</logic:present>
</table>
</td>
</tr>
</table>
</body>
</html:html>
Re: return false
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Tuan" == Tuan H Le <tu...@phsadc.com> writes:
Tuan> Hi,
Tuan> In my Action class I set an object in one of the session attribute before forwarding to a JSP view. But, the <logic:present> in the JSP view always return false on that object.
Tuan> **************** My Action code ***********************
Tuan> ...
Tuan> session.setAttribute( USER_EMPLOYEE_LIST_KEY, employeeList );
Tuan> // Forward to the appropriate View
Tuan> return ( mapping.findForward( target ) );
Tuan> ********* My JSP page *********************************
Tuan> <%
Tuan> ArrayList employeeList = (ArrayList)session.getAttribute( IConstants.USER_EMPLOYEE_LIST_KEY );
Tuan> // *************************************************
Tuan> // THIS CODE WORK, BUT THE <logic:present> does not work
Tuan> // *************************************************
Tuan> //for ( int i = 0; i < employeeList.size(); i++ ) {
Tuan> // out.println( "i = " + i + "<BR>" );
Tuan> // EmployeeVO e = (EmployeeVO)employeeList.get( i );
Tuan> // out.println( "Employee ID --> " + e.getEmployeeId() + "<BR>");
Tuan> //}
Tuan> %>
Tuan> <logic:present name="employeeList" scope="session">
Tuan> <!-- Iterate over the results of the query -->
Tuan> <logic:iterate name="employeeList" id="employee" scope="session" type="com.phs.ezhr.business.vo.EmployeeVO" indexId="idx">
Tuan> ....
Tuan> </logic:iterate>
Tuan> </logic:present>
What is the value of "IConstants.USER_EMPLOYEE_LIST_KEY"?
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>