On 6/8/06, Adam Samere <[EMAIL PROTECTED]> wrote:
Niall Pemberton wrote:
> On 6/7/06, Adam Samere <[EMAIL PROTECTED]> wrote:
>> 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 apologies - I was mistaken and I learn't something - you're correct
it is used in TagUtils and that method is used by the tags to retrieve
the messages.

Having said that, it is used to create a brand new ActionMessages
object for a String or String[] and all the messages in it will have a
property of ActionMessages.GLOBAL_MESSAGE - which makes it pretty much
redundant since the property can't be used to filter in any way.

My reason for jumping in on this thread was that it was suggested to use

Glad you did, otherwise I'd have continued under my mistaken belief.

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

I agree.

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.

This is true, but my opinion is that its a mistake to have ever used
it. By deprecating/removing then it would prevent people from making
the mistake in the future and possibly reduce confusion.

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".

As I said in a previous message, my preference is not to enhance
Struts to provide this functionality - but I don't have such strong
feelings about it that I would object to another committer doing it.

If it does get picked up by someone else then the case of "get me all
the messages except those under the GLOBAL_MESSAGE property" might
also be worth considering - or a more general "exclude property" type
feature.

Niall

-Adam

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

Reply via email to