On 6/7/06, Niall Pemberton <[EMAIL PROTECTED]> wrote:
On 6/7/06, Chris Cheshire <[EMAIL PROTECTED]> wrote:
> In my actions I have messages stored in the session either under
> ActionMessages.GLOBAL_MESSAGE, or my own key (eg 'search').
>
> In my jsp I have a section to display the search specific messages.
> <logic:messagesPresent message="true" property="search">
> ....
> </logic:messagesPresent>
>
> I also need to display the global messages at the top of the page,
> however this displays everything, including the search messages:
>
> <logic:messagesPresent message="true">
> ...
> </logic:messagesPresent>
>
> What do I set for the property to ONLY display the messages keyed by
> ActionMessages.GLOBAL_MESSAGE?

You can do this in different ways:

1) Store the two different sets of messages in different
ActionMessages objects under different keys in the request or session.

<skipped>

2) The second option is to save both sets of messages in one
ActionMessages object and use the "property" attribute to filter the
two different types. So add search messages with a property of
"search" and global messages with a property of "global":

<skipped>

The first approach seems more logical to me. After all, the first
parameter in ActionMessages.add() is supposed to be a property name.

On 6/7/06, Joe Germuska <[EMAIL PROTECTED]> wrote:
me, I just think someone who's been thinking about trying to
contribute to Struts ought to take this one and run with it :-)

I hope they won't jump on this right away :-)

1) Struts 1.3.x misses the implementation corresponding to
processCachedMessages() from 1.2, this must be fixed.

2) Alongside with the fix, the code should be expanded in the following areas:

2.1) processCachedMessages() implements a short-term storage between
requests that is called FlashScope in other frameworks (Tapestry,
Stripes). processCachedMessages() uses a specific
ActionMessages.isAccessed() method to distinguish whether a message
should be removed from the session or not. We need to create a generic
FlashScope storage that would be able to store any arbitrary object
not just messages. My first take is to create Flashable interface with
isAccessed() method or something like it.

2.2) processCachedMessages() cleans up only messages stored under
Globals.MESSAGE_KEY and Globals.ERROR_KEY keys, it does not clean
messages stored under custom keys. This should be fixed too.

2.3) The previous issue is important, because different keys are
needed for component-oriented development. When a page is a solid
thing then one key is ok. When a page consists out of several
components, every particular component should display only messages
that correspond to it.

2) After FlashScope is created, the Redirect-After-Post pattern will
be simpler to use.

3) Would be nice to design FlashScope as a first-class scope object
that could be used in struts-config.xml file too,  for example to
store ActionForms. But this is a longer shot.

So I would like that whoever tackles message-related issues keeps eye
on the above tasks as well. I myself will start working on this,
hopefully I will be able to do something till next Monday. Since I
don't know yet how to modify Struts SVN trunk :) , I will be
submitting regular patches.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to