From issues-return-10159-apmail-struts-issues-archive=struts.apache.org@struts.apache.org Wed Jun 04 14:01:28 2008 Return-Path: Delivered-To: apmail-struts-issues-archive@locus.apache.org Received: (qmail 33088 invoked from network); 4 Jun 2008 14:01:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jun 2008 14:01:28 -0000 Received: (qmail 46664 invoked by uid 500); 4 Jun 2008 14:01:29 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 46630 invoked by uid 500); 4 Jun 2008 14:01:29 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 46618 invoked by uid 99); 4 Jun 2008 14:01:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jun 2008 07:01:29 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jun 2008 14:00:48 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 53377234C131 for ; Wed, 4 Jun 2008 07:01:05 -0700 (PDT) Message-ID: <424560411.1212588065339.JavaMail.jira@brutus> Date: Wed, 4 Jun 2008 07:01:05 -0700 (PDT) From: "T.J. Hill (JIRA)" To: issues@struts.apache.org Subject: [jira] Commented: (STR-3151) messagesPresent should not alter ActionMessages.accessed flag In-Reply-To: <1319840911.1212507065316.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/struts/browse/STR-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44016#action_44016 ] T.J. Hill commented on STR-3151: -------------------------------- 20080604 - Comment If logic|nested:messagesPresent was used to display some generic content in a jsp (but not the actual messages) say in a session-scoped ActionMessages object, and then in code, say in an Action class or even jsp snippet executed later, the question as to whether the messages in the object has been consumed, the ActionMessages.isAccessed() method would answer incorrectly. My assumption had been that the logic:messagesPresent tag engages only in interrogative behavior, not mutating behavior. Disclaimer: I have not perused the code behind the other logic tags to analyze whether this is consistent or inconsistent behavior (having interrogative and/or mutating behavior). Whereas for an html:xxx tag, there is clearly an expectation of possible mutating behavior (depending on the use of the html:xxx tag), As for the ActionMessages.isAccessed() method, perhaps I've misinterpreted its intent. Consider the following: 1) I walk to my fridge, open the door and observe three slices of cold pizza. I find the cold pizza unappealing, close the fridge door, and walk away empty handed. 2) I walk to my fridge, open the door and observe three slices of leftover cheesecake. I find the cheesecake very appealing, grab the cheesecake slices, and walk away with dessert. In which scenario did I "access" goods from the fridge? Scenario 1, 2, or possibly both? Thanks - TH > messagesPresent should not alter ActionMessages.accessed flag > ------------------------------------------------------------- > > Key: STR-3151 > URL: https://issues.apache.org/struts/browse/STR-3151 > Project: Struts 1 > Issue Type: Bug > Components: Taglibs > Affects Versions: 1.3.8 > Environment: n/a > Reporter: T.J. Hill > Assignee: Paul Benedict > Fix For: 1.4.0 > > > 20080603 12:53 > The html|nested:messagesPresent tags set ActionMessages.accessed flag to true when interrogating. > Currently, MessagesPresentTag calls the methods get() and get(String) of ActionMessages to determine if any messages exist. However, both get(...) methods in ActionMessages set the accessed field to true. So any subsequent call to ActionMessages.isAccessed() by external code will get true, regardless if the messages were truly consumed. > Below is the current condition method in MessagesPresentTag: > protected boolean condition(boolean desired) > throws JspException { > ActionMessages am = null; > String key = name; > if ((message != null) && "true".equalsIgnoreCase(message)) { > key = Globals.MESSAGE_KEY; > } > try { > am = TagUtils.getInstance().getActionMessages(pageContext, key); > } catch (JspException e) { > TagUtils.getInstance().saveException(pageContext, e); > throw e; > } > Iterator iterator = (property == null) ? am.get() : am.get(property); // HERE is the issue -- using get(...) methods will cause the accessed property of ActionMessages to be set to true. > return (iterator.hasNext() == desired); > } > Perhaps the following change would be appropriate to resolve the issue. > Modify the condition(boolean) method in MesssagesPresentTag to call the existing ActionMessages.size() [when property not specified] and the exsiting ActionMessages.size(String) method above [when property specified]: > > protected boolean condition(boolean desired) > throws JspException { > ActionMessages am = null; > > String key = name; > > if ((message != null) && "true".equalsIgnoreCase(message)) { > key = Globals.MESSAGE_KEY; > } > > try { > am = TagUtils.getInstance().getActionMessages(pageContext, key); > } catch (JspException e) { > TagUtils.getInstance().saveException(pageContext, e); > throw e; > } > > // --- CURRENT --- > //Iterator iterator = (property == null) ? am.get() : am.get(property); > //return (iterator.hasNext() == desired); > > // +++ SUGGESTED +++ > int present = (property == null) ? am.size() : am.size(property); > return ((present > 0) == desired); > } > > Thanks - TH -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.