Yes, as i wrote this would be the way to impose a custom sorting on messages but at the moment the FilterMessage class does not provide dedicated fields that could be used for a sorting metric. So i was wondering if there are plans to provide such a thing or if we will be bound to incooperate this kind of information into the messages themselves.

The Sanity Resort <http://sanityresort.blogspot.com/>

Am 23.08.2011 19:21, schrieb Martin Grigorov:
I think 
org.apache.wicket.markup.html.panel.FeedbackPanel.setSortingComparator(Comparator<FeedbackMessage>)
is for that

On Tue, Aug 23, 2011 at 8:10 PM, Christian Huber<[email protected]>  wrote:
Hi,

I was wondering if there is a way to have feedback messages show up in
certain order. Like, when you have multiple messages for the user you might
want to have the most general one (e.g. success/failure) at the top and
other detail messages shown below.

 From what I have seen so far it looks like this is not possible (at least
not with 1.4.18)

As a default messages are rendered in the order they have been provided, so
usually you can just collect the messages you want to display and then add
them at the end of your request in the desired order. But there can be
circumstances where this is not feasible or at least pretty anoying.

I have seen that a FeedbackPanel can be given a comparator to sort the
messages but the feedback messages only provide a level field to distinguish
between info, debug, errror etc. To impose a proper priority order one would
need a metric orthogonal to message levels preferrably represented by a
primitive (double would give the biggest freedom here).

The Component class could be extended to provide additional methods like
Component#info(String message, double priority) and messages which do not
have a priority get assigned a default value specified in the Application
class (could be 0 in the standard implementation).

Would this be a useful/sensible addition? Is such a thing planned for future
releases or maybe already available and I just did not see it?

One workaround/hack to implement this with the current version could be to
prefix all messages with a numeric string and use a Comparator to parse this
string and sort accordingly.

Cheers, Chris

--
The Sanity Resort<http://sanityresort.blogspot.com/>



Reply via email to