Niall Pemberton wrote:
On 6/7/06, Adam Samere <[EMAIL PROTECTED]> wrote:
Niall Pemberton wrote:
> On 6/7/06, Joe Germuska <[EMAIL PROTECTED]> wrote:
>> At 12:47 PM -0700 6/7/06, Chris Cheshire 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?
>>
>> technically, you would use
>>
>> <logic:messagesPresent message="true"
>> property="org.apache.struts.action.GLOBAL_MESSAGE">
>> ....
>> </logic:messagesPresent>
>>
>> It has been observed that this is kind of cumbersome.  A nice
>> enhancement (that just about any willing volunteer could do, hint
>> hint :-) ) would be to enhance the logic:messagesPresent,
>> logic:messagesNotPresent, and html:messages and html:errors tags to
>> have another attribute, "global" which if it had the value"true"
>> would save you from needing to know that verbose property name.
>
> AFAIK there is no actual processing related to
> ActionMessages.GLOBAL_MESSAGE in Struts and it just means its a far
> more cumbersome key to use than something simple like a property name
> of "global" and IMO property="global" is not much different than
> global="true". I also think adding another attribute just adds
> confusion with global="true" being an alias for
> property="org.apache.struts.action.GLOBAL_MESSAGE"
>
>
> AFAIK there is no actual processing related to
> ActionMessages.GLOBAL_MESSAGE in Struts and adding another attribute
> just adds confusion with global="true" being an alias for
> property="org.apache.struts.action.GLOBAL_MESSAGE". Better for people
> to just use their own simpler property names to achieve the same thing
> - for example property="global" works just as well?
>
> Niall
>
This works fine if you handle it in the manner you described previously,
but does not account for any messages added by the framework, other
developers, etc. and forces developers to either implement their own
solution for "Give me all messages that have not been stored under a
custom property", hard code the org.apache.struts.action.GLOBAL_MESSAGE
key, or use scriptlets to grab the value. No?

Not sure I understand this - to my knowledge the framework doesn't add
any "global" messages. Also how does implementing a key of
"org.apache.struts.action.GLOBAL_MESSAGE" differ from implementing
your "own solution" of another key value - except that the other key
value doesn't have to be as cumbersome? Whatever you and "other
developers" do you have to agree to handshake on these things -
whether its with this value of the key or your own.

My sense of reading your comment is that you think that Struts is
providing you with some sort of solution - when in reality it isn't
actually doing anything wrt to this constant.

Niall

getActionMessages in org.apache.struts.taglib.TagUtils converts String and String[] to ActionMessage instances and stores them under ActionMessages.GLOBAL_MESSAGE.

My reason for jumping in on this thread was that it was suggested to use the literal key org.apache.struts.action.GLOBAL_MESSAGE in the messages tag, where my general intuition tells me it is a bad idea to resolve the value of a constant inside a 3rd party framework and plug it in as literal text. What happens to everyone who took this approach if the key is ever changed, or as Joe mentioned deprecated/removed? It just adds up to another task during a future upgrade. Your solution of storing the messages under your own less cumbersome key is probably the best one, but with the ActionMessages.GLOBAL_MESSAGE constant out there many people will continue to use it when manually creating and storing messages, forcing the use of either scriptlet expressions, direct reference to the literal, or additional code maintenance in order to achieve the relatively simple concept of "get me all the messages stored under the GLOBAL_MESSAGE key, but none of the others".

-Adam
>> Joe
>>
>> --
>> Joe Germuska
>> [EMAIL PROTECTED] * http://blog.germuska.com

---------------------------------------------------------------------
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]

Reply via email to