On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <[email protected]> wrote:
> Hi folks!
>
> I thought quite some time about how we could do the typesafe messging for
> JSF. Today I had the following idea.
>
>
> Imagine a typesafe message
>
> @MessageBundle
> public interface SimpleMessage
> {
> @MessageTemplate("Welcome to %s")
> Message welcomeTo(String name);
> }
>
> This is nice but it's hard to use it for creating FacesMessages that way.
>
> Now imagine the following
>
> @Inject
> JsfMessage<SimpleMessge> message;
>
> ...
>
> message.addInfo().welcomeTo("DeltaSpike);
>
>
>
> public interface JsfMessage<T> {
> T addInfo();
> T addWarning();
> T addError();
> void clear();
> }
>
>
> I think it is possible to implement this, right?
>
> Wdyt from a users perspective?
>
> LieGrue,
> strub
>
>
This looks like a great start. In IRC we discovered we need to determine if
the text goes to the summary or detail. We already have the severity with
the methods. I'd suggest having each of those methods take an enum (DETAIL,
SUMMARY, BOTH or similar). One drawback I see about this is you can't
define a different message for the detail and the summary on one line, but
that may not be the end of the world.
--
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp
Software Engineer
Open Source Advocate
Author of Seam Catch - Next Generation Java Exception Handling
PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu