write a q&d jsp page to print request, session and Message Resource bundle values
code courtesy of Dom Tay
<% // Print all attributes in the request object out.println("All Attributes in request scope:"); Enumeration paramNames = request.getAttributeNames(); while (paramNames.hasMoreElements()) { String name = (String) paramNames.nextElement(); Object values = request.getAttribute(name); out.println("<br> " + name + ":" + values); } // Print all attributes in the session object out.println("All Attributes in session scope:"); paramNames = session.getAttributeNames(); while (paramNames.hasMoreElements()) { String name = (String) paramNames.nextElement(); Object values = session.getAttribute(name); out.println("<br> " + name + ":" + values); } out.println("Data in ActionMessages:"); // Get the ActionMessages Object o = request.getAttribute(Globals.MESSAGE_KEY); if (o != null) { ActionMessages ae = (ActionMessages)o; // Get the locale and message resources bundle Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY); MessageResources messages = (MessageResources)request.getAttribute (Globals.MESSAGES_KEY); // Loop thru all the labels in the ActionMessage's for (Iterator i = ae.properties(); i.hasNext();) { String property = (String)i.next(); out.println("<br>property " + property + ": "); // Get all messages for this label for (Iterator it = ae.get(property); it.hasNext();) { ActionMessage a = (ActionMessage)it.next(); String key = a.getKey(); Object[] values = a.getValues(); out.println(" [key=" + key + ", message=" + messages.getMessage(locale,key,values) + "]"); } } } %>
Martin Gainty
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relating to the official business of Sender and is proprietary to Sender. It is confidential, legally privileged and protected by law. Sender does not own and endorse any other content.
(mobile) 617-852-7822
(http)www.laconiadatasystems.com
From: <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: <user@struts.apache.org>, <[EMAIL PROTECTED]>
Subject: RE: Help with logic tags, and commas please.
Date: Thu, 3 Feb 2005 18:22:00 -0600
MIME-Version: 1.0
Received: from mail.apache.org ([209.237.227.199]) by mc7-f33.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 3 Feb 2005 16:22:27 -0800
Received: (qmail 74218 invoked by uid 500); 4 Feb 2005 00:22:06 -0000
Received: (qmail 74173 invoked by uid 99); 4 Feb 2005 00:22:06 -0000
Received: neutral (hermes.apache.org: local policy)
Received: from crater.norwest.com (HELO crater.norwest.com) (198.74.20.154) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 03 Feb 2005 16:22:05 -0800
Received: from outback.wellsfargo.com (outback.wellsfargo.com [10.88.26.20])by crater.norwest.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id j1401bEf021602;Thu, 3 Feb 2005 18:01:37 -0600 (CST)
Received: from outback.wellsfargo.com (localhost [127.0.0.1])by outback.wellsfargo.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id j140M1Tj024418;Thu, 3 Feb 2005 18:22:01 -0600 (CST)
Received: from MSGSPSMNMSP05.ent.wfb.bank.corp (msgspsmnmsp05.wellsfargo.com [10.88.230.249])by outback.wellsfargo.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id j140M0Ed024412;Thu, 3 Feb 2005 18:22:00 -0600 (CST)
Received: from MSGSWBMNMSP19.ent.wfb.bank.corp ([10.88.230.217]) by MSGSPSMNMSP05.ent.wfb.bank.corp with Microsoft SMTPSVC(5.0.2195.6713); Thu, 3 Feb 2005 18:22:00 -0600
X-Message-Info: JGTYoYF78jF4JXmRDGdgwX5gdI2mrfSMFliC2IGssb0=
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <mailto:[EMAIL PROTECTED]>
List-Help: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:user@struts.apache.org>
List-Id: "Struts Users Mailing List" <user.struts.apache.org>
Delivered-To: mailing list user@struts.apache.org
X-ASF-Spam-Status: No, hits=0.3 required=10.0tests=FORGED_RCVD_HELO,NO_REAL_NAME,X_PRIORITY_HIGH
X-Spam-Check-By: apache.org
Content-Class: urn:content-classes:message
X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0
X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Help with logic tags, and commas please.
Thread-Index: AcUKNtRyKaSd/IOzQlOYB86XjDx80AAF2vHQ
Priority: Urgent
X-OriginalArrivalTime: 04 Feb 2005 00:22:00.0469 (UTC) FILETIME=[8B3D9450:01C50A4F]
X-Virus-Checked: Checked
Return-Path: [EMAIL PROTECTED]
Can someone please help me to get the print to work.
I keep trying to use the fmt, or the c:out tags, but nothing is actually printing the value of ${product} as converted from the ApplicationResources value.
-------------------- Mick Knutson Wells Fargo Business Direct (415) 222-1020
"This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation."
--------------------
-----Original Message----- From: Kishore Senji [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 1:23 PM To: Struts Users Mailing List Subject: Re: Help with logic tags, and commas please.
> <c:out > value="${creditApplicationListDto.displayProducts[${key}]}"/>,
I would return a collection from teh DTO for only true values. The reason is JSTL cannot invoke the keySet() method on the Map (Since the method doesn't confine to JavaBean specification)
public Collection getDisplayProducts() { Collection c = new ArrayList(); if(Boolean.TRUE.equals(this.getBusinessLine())){ c.add("label.applist.bln"); } if(Boolean.TRUE.equals(this.getBusinessCard())){ c.add("label.applist.bcard"); } if(Boolean.TRUE.equals(this.getSecuredCard())){ c.add("label.applist.seccard"); } if(Boolean.TRUE.equals(this.getEquipmentExpress())){ c.add("label.applist.equipmentExpress"); } if(Boolean.TRUE.equals(this.getSbaLineOfCredit())){ c.add("label.applist.sBALineOfCredit"); } if(Boolean.TRUE.equals(this.getSbaTermLoan())){ c.add("label.applist.sBATermLoan"); } if(Boolean.TRUE.equals(this.getBusinessLoan())){ c.add("label.applist.BusinessLoan"); }
if(c.size() < 1 ) { c.add("label.applist.NoProducts"); } return c; }
<c:forEach items="${creditApplicationListDto.displayProducts}" var="product" varStatus="status"> <c:choose> <c:when test="${not status.last}"> <c:out value="${product}"/>, </c:when> <c:otherwise> <c:out value="${product}"/> </c:otherwise> </c:choose> </c:forEach>
Assuming that "label.applist.*" is only a key to the actual label in the properties file you might want to use <fmt:message/> to render the actual label
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]