You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by Mark Struberg <st...@yahoo.de> on 2012/10/05 19:24:28 UTC

proposal for JSF Messages

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


Re: proposal for JSF Messages

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi Mark,

That's more or less the same spirit of the typed logger which is in my
opinion really useful.
For example, I like how it has been defined in Seam Solder.

Using the same idea for messages is also relevant in my opinion even if I
don't like your example with the logger ;-) Indeed, IMHO the logger level
should be defined in the typed logger itself to make it consistent all over
the application (i.e.. you should not be able to define a different level
each time you wanna use a message).

Then, getting the message only without producing a log is useful and can be
an option to the typed logger.

Jean-Louis



2012/10/5 Mark Struberg <st...@yahoo.de>

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

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
+1

regards,
gerhard



2012/10/5 Mark Struberg <st...@yahoo.de>

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

Re: proposal for JSF Messages

Posted by Jason Porter <li...@gmail.com>.
Yeah, been talking about that one as well.

On Fri, Oct 5, 2012 at 1:18 PM, Gerhard Petracek <gerhard.petracek@gmail.com
> wrote:

> hi jason,
>
> that's for sure just a first idea.
> e.g. we also need the possibility to add messages for a specific component.
>
> regards,
> gerhard
>
>
>
> 2012/10/5 Jason Porter <li...@gmail.com>
>
> > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <st...@yahoo.de>
> 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
> >
>



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

Re: proposal for JSF Messages

Posted by Nicklas Karlsson <ni...@gmail.com>.
Sure, but what I was getting at was that with a MessageSource interface,
you wouldn't have to edit the resolver every time you want to add a message
source. The default resolver could just use the beans implementing that
interface that were found.

On Sun, Oct 7, 2012 at 4:49 PM, Mark Struberg <st...@yahoo.de> wrote:

> There is already an interface: MessageResolver
>
> Just providing an @Alternative should be perfectly enough!
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Nicklas Karlsson <ni...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org; Mark Struberg <
> struberg@yahoo.de>
> > Cc:
> > Sent: Sunday, October 7, 2012 3:41 PM
> > Subject: Re: proposal for JSF Messages
> >
> > It's pretty trivial to @Specialize the resolver and inject an entity
> with a
> > cached Map<String, String> from the DB.
> >
> > Like Mark said, it would probably be possible to generalize fetching
> from a
> > flat file with (key, value, locale) rows but it's probably not worth the
> > while when custom implementations are that simple to write.
> >
> > Still trying to sell the MessageSource interface so you wouldn't have to
> > @Specialize the resolver to get away from the properties files ;-)
> >
> > On Sun, Oct 7, 2012 at 2:40 PM, Mark Struberg <st...@yahoo.de> wrote:
> >
> >>  Yes, just provide your own MessageResolver as @Alternative.
> >>
> >>  I think Nicklas Karlson already implemented a database backed version.
> >>  I'm not sure we can add it to DS itself as the database schema is
> > usually
> >>  different for each company.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>  > From: Thomas Andraschko <zo...@gmail.com>
> >>  > To: deltaspike-dev@incubator.apache.org
> >>  > Cc:
> >>  > Sent: Sunday, October 7, 2012 1:14 PM
> >>  > Subject: Re: proposal for JSF Messages
> >>  >
> >>  > Will it also be possible to use the messages stuff without
> properties?
> > We
> >>  > always have our translations in the database.
> >>  >
> >>
> >
> >
> >
> > --
> > Nicklas Karlsson, +358 40 5062266
> > Vaakunatie 10 as 7, 20780 Kaarina
> >
>



-- 
Nicklas Karlsson, +358 40 5062266
Vaakunatie 10 as 7, 20780 Kaarina

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
yes - the MessageResolver interface was introduced exactly for such
use-cases.

regards,
gerhard



2012/10/7 Mark Struberg <st...@yahoo.de>

> There is already an interface: MessageResolver
>
> Just providing an @Alternative should be perfectly enough!
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Nicklas Karlsson <ni...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org; Mark Struberg <
> struberg@yahoo.de>
> > Cc:
> > Sent: Sunday, October 7, 2012 3:41 PM
> > Subject: Re: proposal for JSF Messages
> >
> > It's pretty trivial to @Specialize the resolver and inject an entity
> with a
> > cached Map<String, String> from the DB.
> >
> > Like Mark said, it would probably be possible to generalize fetching
> from a
> > flat file with (key, value, locale) rows but it's probably not worth the
> > while when custom implementations are that simple to write.
> >
> > Still trying to sell the MessageSource interface so you wouldn't have to
> > @Specialize the resolver to get away from the properties files ;-)
> >
> > On Sun, Oct 7, 2012 at 2:40 PM, Mark Struberg <st...@yahoo.de> wrote:
> >
> >>  Yes, just provide your own MessageResolver as @Alternative.
> >>
> >>  I think Nicklas Karlson already implemented a database backed version.
> >>  I'm not sure we can add it to DS itself as the database schema is
> > usually
> >>  different for each company.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>  > From: Thomas Andraschko <zo...@gmail.com>
> >>  > To: deltaspike-dev@incubator.apache.org
> >>  > Cc:
> >>  > Sent: Sunday, October 7, 2012 1:14 PM
> >>  > Subject: Re: proposal for JSF Messages
> >>  >
> >>  > Will it also be possible to use the messages stuff without
> properties?
> > We
> >>  > always have our translations in the database.
> >>  >
> >>
> >
> >
> >
> > --
> > Nicklas Karlsson, +358 40 5062266
> > Vaakunatie 10 as 7, 20780 Kaarina
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
There is already an interface: MessageResolver

Just providing an @Alternative should be perfectly enough!

LieGrue,
strub




----- Original Message -----
> From: Nicklas Karlsson <ni...@gmail.com>
> To: deltaspike-dev@incubator.apache.org; Mark Struberg <st...@yahoo.de>
> Cc: 
> Sent: Sunday, October 7, 2012 3:41 PM
> Subject: Re: proposal for JSF Messages
> 
> It's pretty trivial to @Specialize the resolver and inject an entity with a
> cached Map<String, String> from the DB.
> 
> Like Mark said, it would probably be possible to generalize fetching from a
> flat file with (key, value, locale) rows but it's probably not worth the
> while when custom implementations are that simple to write.
> 
> Still trying to sell the MessageSource interface so you wouldn't have to
> @Specialize the resolver to get away from the properties files ;-)
> 
> On Sun, Oct 7, 2012 at 2:40 PM, Mark Struberg <st...@yahoo.de> wrote:
> 
>>  Yes, just provide your own MessageResolver as @Alternative.
>> 
>>  I think Nicklas Karlson already implemented a database backed version.
>>  I'm not sure we can add it to DS itself as the database schema is 
> usually
>>  different for each company.
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>> 
>>  ----- Original Message -----
>>  > From: Thomas Andraschko <zo...@gmail.com>
>>  > To: deltaspike-dev@incubator.apache.org
>>  > Cc:
>>  > Sent: Sunday, October 7, 2012 1:14 PM
>>  > Subject: Re: proposal for JSF Messages
>>  >
>>  > Will it also be possible to use the messages stuff without properties? 
> We
>>  > always have our translations in the database.
>>  >
>> 
> 
> 
> 
> -- 
> Nicklas Karlsson, +358 40 5062266
> Vaakunatie 10 as 7, 20780 Kaarina
> 

Re: proposal for JSF Messages

Posted by Nicklas Karlsson <ni...@gmail.com>.
It's pretty trivial to @Specialize the resolver and inject an entity with a
cached Map<String, String> from the DB.

Like Mark said, it would probably be possible to generalize fetching from a
flat file with (key, value, locale) rows but it's probably not worth the
while when custom implementations are that simple to write.

Still trying to sell the MessageSource interface so you wouldn't have to
@Specialize the resolver to get away from the properties files ;-)

On Sun, Oct 7, 2012 at 2:40 PM, Mark Struberg <st...@yahoo.de> wrote:

> Yes, just provide your own MessageResolver as @Alternative.
>
> I think Nicklas Karlson already implemented a database backed version.
> I'm not sure we can add it to DS itself as the database schema is usually
> different for each company.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Thomas Andraschko <zo...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org
> > Cc:
> > Sent: Sunday, October 7, 2012 1:14 PM
> > Subject: Re: proposal for JSF Messages
> >
> > Will it also be possible to use the messages stuff without properties? We
> > always have our translations in the database.
> >
>



-- 
Nicklas Karlsson, +358 40 5062266
Vaakunatie 10 as 7, 20780 Kaarina

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
Yes, just provide your own MessageResolver as @Alternative.

I think Nicklas Karlson already implemented a database backed version.
I'm not sure we can add it to DS itself as the database schema is usually different for each company.

LieGrue,
strub




----- Original Message -----
> From: Thomas Andraschko <zo...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Sunday, October 7, 2012 1:14 PM
> Subject: Re: proposal for JSF Messages
> 
> Will it also be possible to use the messages stuff without properties? We
> always have our translations in the database.
> 

Re: proposal for JSF Messages

Posted by Thomas Andraschko <zo...@gmail.com>.
Will it also be possible to use the messages stuff without properties? We
always have our translations in the database.

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
that's why i said:
"i would skip the #getCategory part for now."

regards,
gerhard



2012/10/7 Mark Struberg <st...@yahoo.de>

> The default categories in JsfMessage will be constants.
> This is the most flexible and least restricting way.
>
> We could introduce an own Category interface. That would work as well, but
> then we wont be able to easily implement dynamic categories.
> Also the mapping is a String inside the property file or database anyway.
> You would then need to define another mapping to a String in any case.
> Imo this is not worth all the effort. But I'd be happy for a review and of
> getting more pros and cons.
> We should just try to avoid overcomplicating it. If people think there is
> a good reason for an own Interface than it's easy to add it. I'm just not
> sure about the value it brings.
>
>
> LieGrue,
> strub
>
>
>
> ----- Original Message -----
> > From: Gerhard Petracek <ge...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org
> > Cc:
> > Sent: Sunday, October 7, 2012 1:01 PM
> > Subject: Re: proposal for JSF Messages
> >
> > @ "We already found an easy solution.":
> >
> > can't be, because this discussion wasn't even near to be finished.
> >
> > @"This part is already implemented.":
> >
> > i saw it - to say it differently: -1 to category as a string
> > (back then that was also part of the discussion about the bv constraint
> > payload.)
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/10/7 Mark Struberg <st...@yahoo.de>
> >
> >>  Hi Gerhard!
> >>
> >>  We already found an easy solution.
> >>
> >>  I removed the restriction that @MessageBundles are only allowed to
> return
> >>  a Message if they have a MessageContext parameter. I found no reason to
> >>  restrict that.
> >>
> >>  If a user returns a Message intead of a String then we will use the
> >>  categories 'summary' and 'detail' for creating the
> > FacesMessage. Both fall
> >>  back to the default value in their property files if they don't have a
> >>  .summary or .detail entry in that language. If a String is being
> returned
> >>  we use it for both summary and detail Strings.
> >>
> >>  This part is already implemented. I'm currently working on the Proxy
> > for
> >>  creating the JsfMessage<YourMessage> part.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>  > From: Gerhard Petracek <ge...@gmail.com>
> >>  > To: deltaspike-dev@incubator.apache.org
> >>  > Cc:
> >>  > Sent: Sunday, October 7, 2012 12:37 PM
> >>  > Subject: Re: proposal for JSF Messages
> >>  >
> >>  > i would skip the #getCategory part for now. it's very similar to
> > the
> >>  > type-safe message-payload used in codi and those parts are quite
> > special
> >>  > already.
> >>  >
> >>  > regards,
> >>  > gerhard
> >>  >
> >>  >
> >>  >
> >>  > 2012/10/6 Mark Struberg <st...@yahoo.de>
> >>  >
> >>  >>  I agree with Christian. From a developer perspective you will
> > just use
> >>  >>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the
> >>  > parameters. The
> >>  >>  developer usually doesn't care about the exact wording anyway
> > ;)
> >>  >>
> >>  >>  For the 3.) I think you should just use 2 different message
> > template
> >>  >>  identifiers.
> >>  >>
> >>  >>  LieGrue,
> >>  >>  strub
> >>  >>
> >>  >>
> >>  >>
> >>  >>
> >>  >>  ----- Original Message -----
> >>  >>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
> >>  >>  > To: deltaspike-dev@incubator.apache.org
> >>  >>  > Cc: Mark Struberg <st...@yahoo.de>
> >>  >>  > Sent: Saturday, October 6, 2012 11:42 AM
> >>  >>  > Subject: Re: proposal for JSF Messages
> >>  >>  >
> >>  >>  > Hey Bernard,
> >>  >>  >
> >>  >>  > I think the user shouldn't actually care about 1) and
> > 2). IMHO the
> >>  > main
> >>  >>  > point is to hide these details from the actual business
> > code. In your
> >>  >>  code
> >>  >>  > you just say "send message X to the user". If
> > summary and
> >>  > details are
> >>  >>  > the
> >>  >>  > same or not shouldn't be relevant at this point.
> >>  >>  >
> >>  >>  > Just my feelings regarding this. :)
> >>  >>  >
> >>  >>  > Christian
> >>  >>  >
> >>  >>  >
> >>  >>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
> >>  >>  >
> >>  >>  >>  Mark,
> >>  >>  >>
> >>  >>  >>  As I've cited
> >>  >>  >>  hello_you = Hello You
> >>  >>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
> >>  >>  >>
> >>  >>  >>  Imagine i'm user. Now i have such questions:
> >>  >>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set
> > summary
> >>  > or
> >>  >>  details?
> >>  >>  >>  2) Hm i've set summary, how do I set details? The
> > API
> >>  > doesn't tell
> >>  >>  > me this,
> >>  >>  >>  I have to reference some manuals to learn how to set
> > details.
> >>  >>  >>  3) What if (in one case in entire app) I want to set
> > summary with
> >>  > key
> >>  >>  >>  {hello_you} and details from {goodbye_you}? In the rest
> > of app I
> >>  > could
> >>  >>  use
> >>  >>  >>  approach as you've proposed, but this once i want
> > to do
> >>  > custom?
> >>  >>  >>
> >>  >>  >>  Please, do not take this as criticism, it's just my
> > gut
> >>  > feeling.
> >>  >>  >>
> >>  >>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
> >>  >>  >>
> >>  >>  >>  > Hi Bernard!
> >>  >>  >>  >
> >>  >>  >>  > which part of it do you consider as magic?
> >>  >>  >>  >
> >>  >>  >>  > I think the Message.getCategory(String) is fine
> > (feel free
> >>  > to suggest
> >>  >>  > a
> >>  >>  >>  > better name for the method)
> >>  >>  >>  > A category is just a different resource pattern
> > for the same
> >>  >>  > parameters.
> >>  >>  >>  > Like short text and long text of the same message.
> >>  >>  >>  >
> >>  >>  >>  > Imagine a user makes
> >>  >>  >>  >
> >>  >>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > msg.addError().userNotAllowed(loggedInUser);
> >>  >>  >>  >
> >>  >>  >>  > which would automatically use the property without
> > as
> >>  > fallback and
> >>  >>  the
> >>  >>  >>  > categories 'summary' and 'detail'
> > for
> >>  > creating the
> >>  >>  > FacesMessage.
> >>  >>  >>  > Those 2 categories are of course a contract of the
> >>  > JsfMessage
> >>  >>  >>  > implementation.
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > But even for non JSF messages it would make sense.
> >>  >>  >>  >
> >>  >>  >>  > @Inject MyCheckMessages msg;
> >>  >>  >>  >
> >>  >>  >>  >
> >>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
> >>  >>  >>  >
> >>  >>  >>  > The category String should be a well documented
> > final static
> >>  > String
> >>  >>  >>  > somewhere of course.
> >>  >>  >>  >
> >>  >>  >>  > LieGrue,
> >>  >>  >>  > strub
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > >________________________________
> >>  >>  >>  > > From: Bernard Łabno
> > <s4...@pjwstk.edu.pl>
> >>  >>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark
> > Struberg
> >>  > <
> >>  >>  >>  struberg@yahoo.de
> >>  >>  >>  > >
> >>  >>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
> >>  >>  >>  > >Subject: Re: proposal for JSF Messages
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >Mark,
> >>  >>  >>  > >
> >>  >>  >>  > >Most of ideas are great, but I think that
> > following will
> >>  > be
> >>  >>  > considered
> >>  >>  >>  as
> >>  >>  >>  > "magic" (too magic) by users.
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >for a "{hello_you}" you can have
> > entries in
> >>  > your
> >>  >>  > properties file
> >>  >>  >>  > >>
> >>  >>  >>  > >>hello_you = Hello You
> >>  >>  >>  > >>hello_you.detail = Good evening Ladies and
> >>  > Gentlemen!
> >>  >>  >>  > >>
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >2012/10/5 Mark Struberg
> > <st...@yahoo.de>
> >>  >>  >>  > >
> >>  >>  >>  > >Yes, that was the final idea.
> >>  >>  >>  > >>
> >>  >>  >>  > >>I originally thought about extending the
> >>  > @MessageBundle and
> >>  >>  > let the
> >>  >>  >>  > interface optionally return a String[]. But I
> > think this is
> >>  > too
> >>  >>  > complex
> >>  >>  >>  to
> >>  >>  >>  > get right
> >>  >>  >>  > >>
> >>  >>  >>  > >>Instead I'd rather introduce a
> >>  >>  >>  > >>Message#toString(String category); and
> >>  >>  >>  > >>
> >>  >>  >>  > >>Message#toString(MessageContext context,
> > String
> >>  > category);
> >>  >>  >>  > >>
> >>  >>  >>  > >>for a "{hello_you}" you can have
> > entries
> >>  > in your
> >>  >>  > properties file
> >>  >>  >>  > >>
> >>  >>  >>  > >>hello_you = Hello You
> >>  >>  >>  > >>hello_you.detail = Good evening Ladies and
> >>  > Gentlemen!
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>If a user just returns a String in his
> > interface,
> >>  > then both
> >>  >>  > detail and
> >>  >>  >>  > summary will be set with the same text
> >>  >>  >>  > >>If a user returns a Message, then we can
> > look
> >>  > deeper.
> >>  >>  >>  > >>
> >>  >>  >>  > >>LieGrue,
> >>  >>  >>  > >>strub
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>----- Original Message -----
> >>  >>  >>  > >>> From: Gerhard Petracek
> >>  > <ge...@gmail.com>
> >>  >>  >>  > >>> To:
> > deltaspike-dev@incubator.apache.org
> >>  >>  >>  > >>> Cc:
> >>  >>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
> >>  >>  >>  > >>> Subject: Re: proposal for JSF
> > Messages
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>t he example provided by mark could
> > add a global
> >>  > message
> >>  >>  > with the same
> >>  >>  >>  > >>
> >>  >>  >>  > >>> summary- and detail-message.
> >>  >>  >>  > >>> -> we just need those methods with
> >>  > additional
> >>  >>  > parameters.
> >>  >>  >>  > >>>
> >>  >>  >>  > >>> regards,
> >>  >>  >>  > >>> gerhard
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>> 2012/10/5 Ken Finnigan
> >>  > <ke...@kenfinnigan.me>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>>  Some additional plans for
> > messages that
> >>  > may be
> >>  >>  > relevant to JSF have
> >>  >>  >>  > been
> >>  >>  >>  > >>>>  documented in [1].
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  In Seam 3 International we had
> > some ideas
> >>  > around
> >>  >>  > targeting a
> >>  >>  >>  message
> >>  >>  >>  > at a
> >>  >>  >>  > >>>>  specific component which are
> > noted here
> >>  > [2].
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  Ken
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  [1]
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>  >>  >>  > >>>>  [2]
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM,
> > Gerhard
> >>  > Petracek
> >>  >>  > <
> >>  >>  >>  > >>>>  gerhard.petracek@gmail.com
> >>  >>  >>  > >>>>  > wrote:
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  > hi jason,
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > that's for sure just a
> > first
> >>  > idea.
> >>  >>  >>  > >>>>  > e.g. we also need the
> > possibility to
> >>  > add
> >>  >>  > messages for a specific
> >>  >>  >>  > >>>>  component.
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > regards,
> >>  >>  >>  > >>>>  > gerhard
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > 2012/10/5 Jason Porter
> >>  >>  > <li...@gmail.com>
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > > On Fri, Oct 5, 2012 at
> > 11:24 AM,
> >>  > Mark
> >>  >>  > Struberg
> >>  >>  >>  > >>> <st...@yahoo.de>
> >>  >>  >>  > >>>>  > 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
> >>  >>  >>  > >>>>  > >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  > --
> >>  >>  > Christian Kaltepoth
> >>  >>  > Blog: http://chkal.blogspot.com/
> >>  >>  > Twitter: http://twitter.com/chkal
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
The default categories in JsfMessage will be constants. 
This is the most flexible and least restricting way.

We could introduce an own Category interface. That would work as well, but then we wont be able to easily implement dynamic categories. 
Also the mapping is a String inside the property file or database anyway. You would then need to define another mapping to a String in any case.
Imo this is not worth all the effort. But I'd be happy for a review and of getting more pros and cons. 
We should just try to avoid overcomplicating it. If people think there is a good reason for an own Interface than it's easy to add it. I'm just not sure about the value it brings.


LieGrue,
strub



----- Original Message -----
> From: Gerhard Petracek <ge...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Sunday, October 7, 2012 1:01 PM
> Subject: Re: proposal for JSF Messages
> 
> @ "We already found an easy solution.":
> 
> can't be, because this discussion wasn't even near to be finished.
> 
> @"This part is already implemented.":
> 
> i saw it - to say it differently: -1 to category as a string
> (back then that was also part of the discussion about the bv constraint
> payload.)
> 
> regards,
> gerhard
> 
> 
> 
> 2012/10/7 Mark Struberg <st...@yahoo.de>
> 
>>  Hi Gerhard!
>> 
>>  We already found an easy solution.
>> 
>>  I removed the restriction that @MessageBundles are only allowed to return
>>  a Message if they have a MessageContext parameter. I found no reason to
>>  restrict that.
>> 
>>  If a user returns a Message intead of a String then we will use the
>>  categories 'summary' and 'detail' for creating the 
> FacesMessage. Both fall
>>  back to the default value in their property files if they don't have a
>>  .summary or .detail entry in that language. If a String is being returned
>>  we use it for both summary and detail Strings.
>> 
>>  This part is already implemented. I'm currently working on the Proxy 
> for
>>  creating the JsfMessage<YourMessage> part.
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>> 
>>  ----- Original Message -----
>>  > From: Gerhard Petracek <ge...@gmail.com>
>>  > To: deltaspike-dev@incubator.apache.org
>>  > Cc:
>>  > Sent: Sunday, October 7, 2012 12:37 PM
>>  > Subject: Re: proposal for JSF Messages
>>  >
>>  > i would skip the #getCategory part for now. it's very similar to 
> the
>>  > type-safe message-payload used in codi and those parts are quite 
> special
>>  > already.
>>  >
>>  > regards,
>>  > gerhard
>>  >
>>  >
>>  >
>>  > 2012/10/6 Mark Struberg <st...@yahoo.de>
>>  >
>>  >>  I agree with Christian. From a developer perspective you will 
> just use
>>  >>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the
>>  > parameters. The
>>  >>  developer usually doesn't care about the exact wording anyway 
> ;)
>>  >>
>>  >>  For the 3.) I think you should just use 2 different message 
> template
>>  >>  identifiers.
>>  >>
>>  >>  LieGrue,
>>  >>  strub
>>  >>
>>  >>
>>  >>
>>  >>
>>  >>  ----- Original Message -----
>>  >>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
>>  >>  > To: deltaspike-dev@incubator.apache.org
>>  >>  > Cc: Mark Struberg <st...@yahoo.de>
>>  >>  > Sent: Saturday, October 6, 2012 11:42 AM
>>  >>  > Subject: Re: proposal for JSF Messages
>>  >>  >
>>  >>  > Hey Bernard,
>>  >>  >
>>  >>  > I think the user shouldn't actually care about 1) and 
> 2). IMHO the
>>  > main
>>  >>  > point is to hide these details from the actual business 
> code. In your
>>  >>  code
>>  >>  > you just say "send message X to the user". If 
> summary and
>>  > details are
>>  >>  > the
>>  >>  > same or not shouldn't be relevant at this point.
>>  >>  >
>>  >>  > Just my feelings regarding this. :)
>>  >>  >
>>  >>  > Christian
>>  >>  >
>>  >>  >
>>  >>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
>>  >>  >
>>  >>  >>  Mark,
>>  >>  >>
>>  >>  >>  As I've cited
>>  >>  >>  hello_you = Hello You
>>  >>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
>>  >>  >>
>>  >>  >>  Imagine i'm user. Now i have such questions:
>>  >>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set 
> summary
>>  > or
>>  >>  details?
>>  >>  >>  2) Hm i've set summary, how do I set details? The 
> API
>>  > doesn't tell
>>  >>  > me this,
>>  >>  >>  I have to reference some manuals to learn how to set 
> details.
>>  >>  >>  3) What if (in one case in entire app) I want to set 
> summary with
>>  > key
>>  >>  >>  {hello_you} and details from {goodbye_you}? In the rest 
> of app I
>>  > could
>>  >>  use
>>  >>  >>  approach as you've proposed, but this once i want 
> to do
>>  > custom?
>>  >>  >>
>>  >>  >>  Please, do not take this as criticism, it's just my 
> gut
>>  > feeling.
>>  >>  >>
>>  >>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
>>  >>  >>
>>  >>  >>  > Hi Bernard!
>>  >>  >>  >
>>  >>  >>  > which part of it do you consider as magic?
>>  >>  >>  >
>>  >>  >>  > I think the Message.getCategory(String) is fine 
> (feel free
>>  > to suggest
>>  >>  > a
>>  >>  >>  > better name for the method)
>>  >>  >>  > A category is just a different resource pattern 
> for the same
>>  >>  > parameters.
>>  >>  >>  > Like short text and long text of the same message.
>>  >>  >>  >
>>  >>  >>  > Imagine a user makes
>>  >>  >>  >
>>  >>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > msg.addError().userNotAllowed(loggedInUser);
>>  >>  >>  >
>>  >>  >>  > which would automatically use the property without 
> as
>>  > fallback and
>>  >>  the
>>  >>  >>  > categories 'summary' and 'detail' 
> for
>>  > creating the
>>  >>  > FacesMessage.
>>  >>  >>  > Those 2 categories are of course a contract of the
>>  > JsfMessage
>>  >>  >>  > implementation.
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > But even for non JSF messages it would make sense.
>>  >>  >>  >
>>  >>  >>  > @Inject MyCheckMessages msg;
>>  >>  >>  >
>>  >>  >>  >
>>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
>>  >>  >>  >
>>  >>  >>  > The category String should be a well documented 
> final static
>>  > String
>>  >>  >>  > somewhere of course.
>>  >>  >>  >
>>  >>  >>  > LieGrue,
>>  >>  >>  > strub
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > >________________________________
>>  >>  >>  > > From: Bernard Łabno 
> <s4...@pjwstk.edu.pl>
>>  >>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark 
> Struberg
>>  > <
>>  >>  >>  struberg@yahoo.de
>>  >>  >>  > >
>>  >>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
>>  >>  >>  > >Subject: Re: proposal for JSF Messages
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >Mark,
>>  >>  >>  > >
>>  >>  >>  > >Most of ideas are great, but I think that 
> following will
>>  > be
>>  >>  > considered
>>  >>  >>  as
>>  >>  >>  > "magic" (too magic) by users.
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >for a "{hello_you}" you can have 
> entries in
>>  > your
>>  >>  > properties file
>>  >>  >>  > >>
>>  >>  >>  > >>hello_you = Hello You
>>  >>  >>  > >>hello_you.detail = Good evening Ladies and
>>  > Gentlemen!
>>  >>  >>  > >>
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >2012/10/5 Mark Struberg 
> <st...@yahoo.de>
>>  >>  >>  > >
>>  >>  >>  > >Yes, that was the final idea.
>>  >>  >>  > >>
>>  >>  >>  > >>I originally thought about extending the
>>  > @MessageBundle and
>>  >>  > let the
>>  >>  >>  > interface optionally return a String[]. But I 
> think this is
>>  > too
>>  >>  > complex
>>  >>  >>  to
>>  >>  >>  > get right
>>  >>  >>  > >>
>>  >>  >>  > >>Instead I'd rather introduce a
>>  >>  >>  > >>Message#toString(String category); and
>>  >>  >>  > >>
>>  >>  >>  > >>Message#toString(MessageContext context, 
> String
>>  > category);
>>  >>  >>  > >>
>>  >>  >>  > >>for a "{hello_you}" you can have 
> entries
>>  > in your
>>  >>  > properties file
>>  >>  >>  > >>
>>  >>  >>  > >>hello_you = Hello You
>>  >>  >>  > >>hello_you.detail = Good evening Ladies and
>>  > Gentlemen!
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>If a user just returns a String in his 
> interface,
>>  > then both
>>  >>  > detail and
>>  >>  >>  > summary will be set with the same text
>>  >>  >>  > >>If a user returns a Message, then we can 
> look
>>  > deeper.
>>  >>  >>  > >>
>>  >>  >>  > >>LieGrue,
>>  >>  >>  > >>strub
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>----- Original Message -----
>>  >>  >>  > >>> From: Gerhard Petracek
>>  > <ge...@gmail.com>
>>  >>  >>  > >>> To: 
> deltaspike-dev@incubator.apache.org
>>  >>  >>  > >>> Cc:
>>  >>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
>>  >>  >>  > >>> Subject: Re: proposal for JSF 
> Messages
>>  >>  >>  > >>>
>>  >>  >>  > >>>t he example provided by mark could 
> add a global
>>  > message
>>  >>  > with the same
>>  >>  >>  > >>
>>  >>  >>  > >>> summary- and detail-message.
>>  >>  >>  > >>> -> we just need those methods with
>>  > additional
>>  >>  > parameters.
>>  >>  >>  > >>>
>>  >>  >>  > >>> regards,
>>  >>  >>  > >>> gerhard
>>  >>  >>  > >>>
>>  >>  >>  > >>>
>>  >>  >>  > >>>
>>  >>  >>  > >>> 2012/10/5 Ken Finnigan
>>  > <ke...@kenfinnigan.me>
>>  >>  >>  > >>>
>>  >>  >>  > >>>>  Some additional plans for 
> messages that
>>  > may be
>>  >>  > relevant to JSF have
>>  >>  >>  > been
>>  >>  >>  > >>>>  documented in [1].
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  In Seam 3 International we had 
> some ideas
>>  > around
>>  >>  > targeting a
>>  >>  >>  message
>>  >>  >>  > at a
>>  >>  >>  > >>>>  specific component which are 
> noted here
>>  > [2].
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  Ken
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  [1]
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>
>>  >
>> 
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>  >>  >>  > >>>>  [2]
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>
>>  >
>> 
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, 
> Gerhard
>>  > Petracek
>>  >>  > <
>>  >>  >>  > >>>>  gerhard.petracek@gmail.com
>>  >>  >>  > >>>>  > wrote:
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  > hi jason,
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > that's for sure just a 
> first
>>  > idea.
>>  >>  >>  > >>>>  > e.g. we also need the 
> possibility to
>>  > add
>>  >>  > messages for a specific
>>  >>  >>  > >>>>  component.
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > regards,
>>  >>  >>  > >>>>  > gerhard
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > 2012/10/5 Jason Porter
>>  >>  > <li...@gmail.com>
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > > On Fri, Oct 5, 2012 at 
> 11:24 AM,
>>  > Mark
>>  >>  > Struberg
>>  >>  >>  > >>> <st...@yahoo.de>
>>  >>  >>  > >>>>  > 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
>>  >>  >>  > >>>>  > >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  > >>
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > --
>>  >>  > Christian Kaltepoth
>>  >>  > Blog: http://chkal.blogspot.com/
>>  >>  > Twitter: http://twitter.com/chkal
>>  >>  >
>>  >>
>>  >
>> 
> 

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
in any case - the discussion on the list wasn't even near to be finished.

regards,
gerhard



2012/10/7 Mark Struberg <st...@yahoo.de>

> Btw, the discussion is in DELTASPIKE-278 DELTASPIKE-277 and on the list 3
> days ago
> http://markmail.org/thread/pnv2kipdd5bmzxzw
>
> Happy to get better ideas on that.
>
> LieGrue,
> strub
>
>
>
>
>
> ----- Original Message -----
> > From: Gerhard Petracek <ge...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org
> > Cc:
> > Sent: Sunday, October 7, 2012 1:01 PM
> > Subject: Re: proposal for JSF Messages
> >
> > @ "We already found an easy solution.":
> >
> > can't be, because this discussion wasn't even near to be finished.
> >
> > @"This part is already implemented.":
> >
> > i saw it - to say it differently: -1 to category as a string
> > (back then that was also part of the discussion about the bv constraint
> > payload.)
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/10/7 Mark Struberg <st...@yahoo.de>
> >
> >>  Hi Gerhard!
> >>
> >>  We already found an easy solution.
> >>
> >>  I removed the restriction that @MessageBundles are only allowed to
> return
> >>  a Message if they have a MessageContext parameter. I found no reason to
> >>  restrict that.
> >>
> >>  If a user returns a Message intead of a String then we will use the
> >>  categories 'summary' and 'detail' for creating the
> > FacesMessage. Both fall
> >>  back to the default value in their property files if they don't have a
> >>  .summary or .detail entry in that language. If a String is being
> returned
> >>  we use it for both summary and detail Strings.
> >>
> >>  This part is already implemented. I'm currently working on the Proxy
> > for
> >>  creating the JsfMessage<YourMessage> part.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>  > From: Gerhard Petracek <ge...@gmail.com>
> >>  > To: deltaspike-dev@incubator.apache.org
> >>  > Cc:
> >>  > Sent: Sunday, October 7, 2012 12:37 PM
> >>  > Subject: Re: proposal for JSF Messages
> >>  >
> >>  > i would skip the #getCategory part for now. it's very similar to
> > the
> >>  > type-safe message-payload used in codi and those parts are quite
> > special
> >>  > already.
> >>  >
> >>  > regards,
> >>  > gerhard
> >>  >
> >>  >
> >>  >
> >>  > 2012/10/6 Mark Struberg <st...@yahoo.de>
> >>  >
> >>  >>  I agree with Christian. From a developer perspective you will
> > just use
> >>  >>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the
> >>  > parameters. The
> >>  >>  developer usually doesn't care about the exact wording anyway
> > ;)
> >>  >>
> >>  >>  For the 3.) I think you should just use 2 different message
> > template
> >>  >>  identifiers.
> >>  >>
> >>  >>  LieGrue,
> >>  >>  strub
> >>  >>
> >>  >>
> >>  >>
> >>  >>
> >>  >>  ----- Original Message -----
> >>  >>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
> >>  >>  > To: deltaspike-dev@incubator.apache.org
> >>  >>  > Cc: Mark Struberg <st...@yahoo.de>
> >>  >>  > Sent: Saturday, October 6, 2012 11:42 AM
> >>  >>  > Subject: Re: proposal for JSF Messages
> >>  >>  >
> >>  >>  > Hey Bernard,
> >>  >>  >
> >>  >>  > I think the user shouldn't actually care about 1) and
> > 2). IMHO the
> >>  > main
> >>  >>  > point is to hide these details from the actual business
> > code. In your
> >>  >>  code
> >>  >>  > you just say "send message X to the user". If
> > summary and
> >>  > details are
> >>  >>  > the
> >>  >>  > same or not shouldn't be relevant at this point.
> >>  >>  >
> >>  >>  > Just my feelings regarding this. :)
> >>  >>  >
> >>  >>  > Christian
> >>  >>  >
> >>  >>  >
> >>  >>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
> >>  >>  >
> >>  >>  >>  Mark,
> >>  >>  >>
> >>  >>  >>  As I've cited
> >>  >>  >>  hello_you = Hello You
> >>  >>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
> >>  >>  >>
> >>  >>  >>  Imagine i'm user. Now i have such questions:
> >>  >>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set
> > summary
> >>  > or
> >>  >>  details?
> >>  >>  >>  2) Hm i've set summary, how do I set details? The
> > API
> >>  > doesn't tell
> >>  >>  > me this,
> >>  >>  >>  I have to reference some manuals to learn how to set
> > details.
> >>  >>  >>  3) What if (in one case in entire app) I want to set
> > summary with
> >>  > key
> >>  >>  >>  {hello_you} and details from {goodbye_you}? In the rest
> > of app I
> >>  > could
> >>  >>  use
> >>  >>  >>  approach as you've proposed, but this once i want
> > to do
> >>  > custom?
> >>  >>  >>
> >>  >>  >>  Please, do not take this as criticism, it's just my
> > gut
> >>  > feeling.
> >>  >>  >>
> >>  >>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
> >>  >>  >>
> >>  >>  >>  > Hi Bernard!
> >>  >>  >>  >
> >>  >>  >>  > which part of it do you consider as magic?
> >>  >>  >>  >
> >>  >>  >>  > I think the Message.getCategory(String) is fine
> > (feel free
> >>  > to suggest
> >>  >>  > a
> >>  >>  >>  > better name for the method)
> >>  >>  >>  > A category is just a different resource pattern
> > for the same
> >>  >>  > parameters.
> >>  >>  >>  > Like short text and long text of the same message.
> >>  >>  >>  >
> >>  >>  >>  > Imagine a user makes
> >>  >>  >>  >
> >>  >>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > msg.addError().userNotAllowed(loggedInUser);
> >>  >>  >>  >
> >>  >>  >>  > which would automatically use the property without
> > as
> >>  > fallback and
> >>  >>  the
> >>  >>  >>  > categories 'summary' and 'detail'
> > for
> >>  > creating the
> >>  >>  > FacesMessage.
> >>  >>  >>  > Those 2 categories are of course a contract of the
> >>  > JsfMessage
> >>  >>  >>  > implementation.
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > But even for non JSF messages it would make sense.
> >>  >>  >>  >
> >>  >>  >>  > @Inject MyCheckMessages msg;
> >>  >>  >>  >
> >>  >>  >>  >
> >>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
> >>  >>  >>  >
> >>  >>  >>  > The category String should be a well documented
> > final static
> >>  > String
> >>  >>  >>  > somewhere of course.
> >>  >>  >>  >
> >>  >>  >>  > LieGrue,
> >>  >>  >>  > strub
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  >
> >>  >>  >>  > >________________________________
> >>  >>  >>  > > From: Bernard Łabno
> > <s4...@pjwstk.edu.pl>
> >>  >>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark
> > Struberg
> >>  > <
> >>  >>  >>  struberg@yahoo.de
> >>  >>  >>  > >
> >>  >>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
> >>  >>  >>  > >Subject: Re: proposal for JSF Messages
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >Mark,
> >>  >>  >>  > >
> >>  >>  >>  > >Most of ideas are great, but I think that
> > following will
> >>  > be
> >>  >>  > considered
> >>  >>  >>  as
> >>  >>  >>  > "magic" (too magic) by users.
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >for a "{hello_you}" you can have
> > entries in
> >>  > your
> >>  >>  > properties file
> >>  >>  >>  > >>
> >>  >>  >>  > >>hello_you = Hello You
> >>  >>  >>  > >>hello_you.detail = Good evening Ladies and
> >>  > Gentlemen!
> >>  >>  >>  > >>
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >2012/10/5 Mark Struberg
> > <st...@yahoo.de>
> >>  >>  >>  > >
> >>  >>  >>  > >Yes, that was the final idea.
> >>  >>  >>  > >>
> >>  >>  >>  > >>I originally thought about extending the
> >>  > @MessageBundle and
> >>  >>  > let the
> >>  >>  >>  > interface optionally return a String[]. But I
> > think this is
> >>  > too
> >>  >>  > complex
> >>  >>  >>  to
> >>  >>  >>  > get right
> >>  >>  >>  > >>
> >>  >>  >>  > >>Instead I'd rather introduce a
> >>  >>  >>  > >>Message#toString(String category); and
> >>  >>  >>  > >>
> >>  >>  >>  > >>Message#toString(MessageContext context,
> > String
> >>  > category);
> >>  >>  >>  > >>
> >>  >>  >>  > >>for a "{hello_you}" you can have
> > entries
> >>  > in your
> >>  >>  > properties file
> >>  >>  >>  > >>
> >>  >>  >>  > >>hello_you = Hello You
> >>  >>  >>  > >>hello_you.detail = Good evening Ladies and
> >>  > Gentlemen!
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>If a user just returns a String in his
> > interface,
> >>  > then both
> >>  >>  > detail and
> >>  >>  >>  > summary will be set with the same text
> >>  >>  >>  > >>If a user returns a Message, then we can
> > look
> >>  > deeper.
> >>  >>  >>  > >>
> >>  >>  >>  > >>LieGrue,
> >>  >>  >>  > >>strub
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>
> >>  >>  >>  > >>----- Original Message -----
> >>  >>  >>  > >>> From: Gerhard Petracek
> >>  > <ge...@gmail.com>
> >>  >>  >>  > >>> To:
> > deltaspike-dev@incubator.apache.org
> >>  >>  >>  > >>> Cc:
> >>  >>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
> >>  >>  >>  > >>> Subject: Re: proposal for JSF
> > Messages
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>t he example provided by mark could
> > add a global
> >>  > message
> >>  >>  > with the same
> >>  >>  >>  > >>
> >>  >>  >>  > >>> summary- and detail-message.
> >>  >>  >>  > >>> -> we just need those methods with
> >>  > additional
> >>  >>  > parameters.
> >>  >>  >>  > >>>
> >>  >>  >>  > >>> regards,
> >>  >>  >>  > >>> gerhard
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>> 2012/10/5 Ken Finnigan
> >>  > <ke...@kenfinnigan.me>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>>>  Some additional plans for
> > messages that
> >>  > may be
> >>  >>  > relevant to JSF have
> >>  >>  >>  > been
> >>  >>  >>  > >>>>  documented in [1].
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  In Seam 3 International we had
> > some ideas
> >>  > around
> >>  >>  > targeting a
> >>  >>  >>  message
> >>  >>  >>  > at a
> >>  >>  >>  > >>>>  specific component which are
> > noted here
> >>  > [2].
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  Ken
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  [1]
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>  >>  >>  > >>>>  [2]
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM,
> > Gerhard
> >>  > Petracek
> >>  >>  > <
> >>  >>  >>  > >>>>  gerhard.petracek@gmail.com
> >>  >>  >>  > >>>>  > wrote:
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>>  > hi jason,
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > that's for sure just a
> > first
> >>  > idea.
> >>  >>  >>  > >>>>  > e.g. we also need the
> > possibility to
> >>  > add
> >>  >>  > messages for a specific
> >>  >>  >>  > >>>>  component.
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > regards,
> >>  >>  >>  > >>>>  > gerhard
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > 2012/10/5 Jason Porter
> >>  >>  > <li...@gmail.com>
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>  > > On Fri, Oct 5, 2012 at
> > 11:24 AM,
> >>  > Mark
> >>  >>  > Struberg
> >>  >>  >>  > >>> <st...@yahoo.de>
> >>  >>  >>  > >>>>  > 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
> >>  >>  >>  > >>>>  > >
> >>  >>  >>  > >>>>  >
> >>  >>  >>  > >>>>
> >>  >>  >>  > >>>
> >>  >>  >>  > >>
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  > >
> >>  >>  >>  >
> >>  >>  >>
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  > --
> >>  >>  > Christian Kaltepoth
> >>  >>  > Blog: http://chkal.blogspot.com/
> >>  >>  > Twitter: http://twitter.com/chkal
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
Btw, the discussion is in DELTASPIKE-278 DELTASPIKE-277 and on the list 3 days ago
http://markmail.org/thread/pnv2kipdd5bmzxzw

Happy to get better ideas on that.

LieGrue,
strub





----- Original Message -----
> From: Gerhard Petracek <ge...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Sunday, October 7, 2012 1:01 PM
> Subject: Re: proposal for JSF Messages
> 
> @ "We already found an easy solution.":
> 
> can't be, because this discussion wasn't even near to be finished.
> 
> @"This part is already implemented.":
> 
> i saw it - to say it differently: -1 to category as a string
> (back then that was also part of the discussion about the bv constraint
> payload.)
> 
> regards,
> gerhard
> 
> 
> 
> 2012/10/7 Mark Struberg <st...@yahoo.de>
> 
>>  Hi Gerhard!
>> 
>>  We already found an easy solution.
>> 
>>  I removed the restriction that @MessageBundles are only allowed to return
>>  a Message if they have a MessageContext parameter. I found no reason to
>>  restrict that.
>> 
>>  If a user returns a Message intead of a String then we will use the
>>  categories 'summary' and 'detail' for creating the 
> FacesMessage. Both fall
>>  back to the default value in their property files if they don't have a
>>  .summary or .detail entry in that language. If a String is being returned
>>  we use it for both summary and detail Strings.
>> 
>>  This part is already implemented. I'm currently working on the Proxy 
> for
>>  creating the JsfMessage<YourMessage> part.
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>> 
>>  ----- Original Message -----
>>  > From: Gerhard Petracek <ge...@gmail.com>
>>  > To: deltaspike-dev@incubator.apache.org
>>  > Cc:
>>  > Sent: Sunday, October 7, 2012 12:37 PM
>>  > Subject: Re: proposal for JSF Messages
>>  >
>>  > i would skip the #getCategory part for now. it's very similar to 
> the
>>  > type-safe message-payload used in codi and those parts are quite 
> special
>>  > already.
>>  >
>>  > regards,
>>  > gerhard
>>  >
>>  >
>>  >
>>  > 2012/10/6 Mark Struberg <st...@yahoo.de>
>>  >
>>  >>  I agree with Christian. From a developer perspective you will 
> just use
>>  >>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the
>>  > parameters. The
>>  >>  developer usually doesn't care about the exact wording anyway 
> ;)
>>  >>
>>  >>  For the 3.) I think you should just use 2 different message 
> template
>>  >>  identifiers.
>>  >>
>>  >>  LieGrue,
>>  >>  strub
>>  >>
>>  >>
>>  >>
>>  >>
>>  >>  ----- Original Message -----
>>  >>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
>>  >>  > To: deltaspike-dev@incubator.apache.org
>>  >>  > Cc: Mark Struberg <st...@yahoo.de>
>>  >>  > Sent: Saturday, October 6, 2012 11:42 AM
>>  >>  > Subject: Re: proposal for JSF Messages
>>  >>  >
>>  >>  > Hey Bernard,
>>  >>  >
>>  >>  > I think the user shouldn't actually care about 1) and 
> 2). IMHO the
>>  > main
>>  >>  > point is to hide these details from the actual business 
> code. In your
>>  >>  code
>>  >>  > you just say "send message X to the user". If 
> summary and
>>  > details are
>>  >>  > the
>>  >>  > same or not shouldn't be relevant at this point.
>>  >>  >
>>  >>  > Just my feelings regarding this. :)
>>  >>  >
>>  >>  > Christian
>>  >>  >
>>  >>  >
>>  >>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
>>  >>  >
>>  >>  >>  Mark,
>>  >>  >>
>>  >>  >>  As I've cited
>>  >>  >>  hello_you = Hello You
>>  >>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
>>  >>  >>
>>  >>  >>  Imagine i'm user. Now i have such questions:
>>  >>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set 
> summary
>>  > or
>>  >>  details?
>>  >>  >>  2) Hm i've set summary, how do I set details? The 
> API
>>  > doesn't tell
>>  >>  > me this,
>>  >>  >>  I have to reference some manuals to learn how to set 
> details.
>>  >>  >>  3) What if (in one case in entire app) I want to set 
> summary with
>>  > key
>>  >>  >>  {hello_you} and details from {goodbye_you}? In the rest 
> of app I
>>  > could
>>  >>  use
>>  >>  >>  approach as you've proposed, but this once i want 
> to do
>>  > custom?
>>  >>  >>
>>  >>  >>  Please, do not take this as criticism, it's just my 
> gut
>>  > feeling.
>>  >>  >>
>>  >>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
>>  >>  >>
>>  >>  >>  > Hi Bernard!
>>  >>  >>  >
>>  >>  >>  > which part of it do you consider as magic?
>>  >>  >>  >
>>  >>  >>  > I think the Message.getCategory(String) is fine 
> (feel free
>>  > to suggest
>>  >>  > a
>>  >>  >>  > better name for the method)
>>  >>  >>  > A category is just a different resource pattern 
> for the same
>>  >>  > parameters.
>>  >>  >>  > Like short text and long text of the same message.
>>  >>  >>  >
>>  >>  >>  > Imagine a user makes
>>  >>  >>  >
>>  >>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > msg.addError().userNotAllowed(loggedInUser);
>>  >>  >>  >
>>  >>  >>  > which would automatically use the property without 
> as
>>  > fallback and
>>  >>  the
>>  >>  >>  > categories 'summary' and 'detail' 
> for
>>  > creating the
>>  >>  > FacesMessage.
>>  >>  >>  > Those 2 categories are of course a contract of the
>>  > JsfMessage
>>  >>  >>  > implementation.
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > But even for non JSF messages it would make sense.
>>  >>  >>  >
>>  >>  >>  > @Inject MyCheckMessages msg;
>>  >>  >>  >
>>  >>  >>  >
>>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
>>  >>  >>  >
>>  >>  >>  > The category String should be a well documented 
> final static
>>  > String
>>  >>  >>  > somewhere of course.
>>  >>  >>  >
>>  >>  >>  > LieGrue,
>>  >>  >>  > strub
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > >________________________________
>>  >>  >>  > > From: Bernard Łabno 
> <s4...@pjwstk.edu.pl>
>>  >>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark 
> Struberg
>>  > <
>>  >>  >>  struberg@yahoo.de
>>  >>  >>  > >
>>  >>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
>>  >>  >>  > >Subject: Re: proposal for JSF Messages
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >Mark,
>>  >>  >>  > >
>>  >>  >>  > >Most of ideas are great, but I think that 
> following will
>>  > be
>>  >>  > considered
>>  >>  >>  as
>>  >>  >>  > "magic" (too magic) by users.
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >for a "{hello_you}" you can have 
> entries in
>>  > your
>>  >>  > properties file
>>  >>  >>  > >>
>>  >>  >>  > >>hello_you = Hello You
>>  >>  >>  > >>hello_you.detail = Good evening Ladies and
>>  > Gentlemen!
>>  >>  >>  > >>
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >2012/10/5 Mark Struberg 
> <st...@yahoo.de>
>>  >>  >>  > >
>>  >>  >>  > >Yes, that was the final idea.
>>  >>  >>  > >>
>>  >>  >>  > >>I originally thought about extending the
>>  > @MessageBundle and
>>  >>  > let the
>>  >>  >>  > interface optionally return a String[]. But I 
> think this is
>>  > too
>>  >>  > complex
>>  >>  >>  to
>>  >>  >>  > get right
>>  >>  >>  > >>
>>  >>  >>  > >>Instead I'd rather introduce a
>>  >>  >>  > >>Message#toString(String category); and
>>  >>  >>  > >>
>>  >>  >>  > >>Message#toString(MessageContext context, 
> String
>>  > category);
>>  >>  >>  > >>
>>  >>  >>  > >>for a "{hello_you}" you can have 
> entries
>>  > in your
>>  >>  > properties file
>>  >>  >>  > >>
>>  >>  >>  > >>hello_you = Hello You
>>  >>  >>  > >>hello_you.detail = Good evening Ladies and
>>  > Gentlemen!
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>If a user just returns a String in his 
> interface,
>>  > then both
>>  >>  > detail and
>>  >>  >>  > summary will be set with the same text
>>  >>  >>  > >>If a user returns a Message, then we can 
> look
>>  > deeper.
>>  >>  >>  > >>
>>  >>  >>  > >>LieGrue,
>>  >>  >>  > >>strub
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>
>>  >>  >>  > >>----- Original Message -----
>>  >>  >>  > >>> From: Gerhard Petracek
>>  > <ge...@gmail.com>
>>  >>  >>  > >>> To: 
> deltaspike-dev@incubator.apache.org
>>  >>  >>  > >>> Cc:
>>  >>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
>>  >>  >>  > >>> Subject: Re: proposal for JSF 
> Messages
>>  >>  >>  > >>>
>>  >>  >>  > >>>t he example provided by mark could 
> add a global
>>  > message
>>  >>  > with the same
>>  >>  >>  > >>
>>  >>  >>  > >>> summary- and detail-message.
>>  >>  >>  > >>> -> we just need those methods with
>>  > additional
>>  >>  > parameters.
>>  >>  >>  > >>>
>>  >>  >>  > >>> regards,
>>  >>  >>  > >>> gerhard
>>  >>  >>  > >>>
>>  >>  >>  > >>>
>>  >>  >>  > >>>
>>  >>  >>  > >>> 2012/10/5 Ken Finnigan
>>  > <ke...@kenfinnigan.me>
>>  >>  >>  > >>>
>>  >>  >>  > >>>>  Some additional plans for 
> messages that
>>  > may be
>>  >>  > relevant to JSF have
>>  >>  >>  > been
>>  >>  >>  > >>>>  documented in [1].
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  In Seam 3 International we had 
> some ideas
>>  > around
>>  >>  > targeting a
>>  >>  >>  message
>>  >>  >>  > at a
>>  >>  >>  > >>>>  specific component which are 
> noted here
>>  > [2].
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  Ken
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  [1]
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>
>>  >
>> 
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>  >>  >>  > >>>>  [2]
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>
>>  >
>> 
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, 
> Gerhard
>>  > Petracek
>>  >>  > <
>>  >>  >>  > >>>>  gerhard.petracek@gmail.com
>>  >>  >>  > >>>>  > wrote:
>>  >>  >>  > >>>>
>>  >>  >>  > >>>>  > hi jason,
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > that's for sure just a 
> first
>>  > idea.
>>  >>  >>  > >>>>  > e.g. we also need the 
> possibility to
>>  > add
>>  >>  > messages for a specific
>>  >>  >>  > >>>>  component.
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > regards,
>>  >>  >>  > >>>>  > gerhard
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > 2012/10/5 Jason Porter
>>  >>  > <li...@gmail.com>
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>  > > On Fri, Oct 5, 2012 at 
> 11:24 AM,
>>  > Mark
>>  >>  > Struberg
>>  >>  >>  > >>> <st...@yahoo.de>
>>  >>  >>  > >>>>  > 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
>>  >>  >>  > >>>>  > >
>>  >>  >>  > >>>>  >
>>  >>  >>  > >>>>
>>  >>  >>  > >>>
>>  >>  >>  > >>
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  > >
>>  >>  >>  >
>>  >>  >>
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > --
>>  >>  > Christian Kaltepoth
>>  >>  > Blog: http://chkal.blogspot.com/
>>  >>  > Twitter: http://twitter.com/chkal
>>  >>  >
>>  >>
>>  >
>> 
> 

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
@ "We already found an easy solution.":

can't be, because this discussion wasn't even near to be finished.

@"This part is already implemented.":

i saw it - to say it differently: -1 to category as a string
(back then that was also part of the discussion about the bv constraint
payload.)

regards,
gerhard



2012/10/7 Mark Struberg <st...@yahoo.de>

> Hi Gerhard!
>
> We already found an easy solution.
>
> I removed the restriction that @MessageBundles are only allowed to return
> a Message if they have a MessageContext parameter. I found no reason to
> restrict that.
>
> If a user returns a Message intead of a String then we will use the
> categories 'summary' and 'detail' for creating the FacesMessage. Both fall
> back to the default value in their property files if they don't have a
> .summary or .detail entry in that language. If a String is being returned
> we use it for both summary and detail Strings.
>
> This part is already implemented. I'm currently working on the Proxy for
> creating the JsfMessage<YourMessage> part.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Gerhard Petracek <ge...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org
> > Cc:
> > Sent: Sunday, October 7, 2012 12:37 PM
> > Subject: Re: proposal for JSF Messages
> >
> > i would skip the #getCategory part for now. it's very similar to the
> > type-safe message-payload used in codi and those parts are quite special
> > already.
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/10/6 Mark Struberg <st...@yahoo.de>
> >
> >>  I agree with Christian. From a developer perspective you will just use
> >>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the
> > parameters. The
> >>  developer usually doesn't care about the exact wording anyway ;)
> >>
> >>  For the 3.) I think you should just use 2 different message template
> >>  identifiers.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
> >>  > To: deltaspike-dev@incubator.apache.org
> >>  > Cc: Mark Struberg <st...@yahoo.de>
> >>  > Sent: Saturday, October 6, 2012 11:42 AM
> >>  > Subject: Re: proposal for JSF Messages
> >>  >
> >>  > Hey Bernard,
> >>  >
> >>  > I think the user shouldn't actually care about 1) and 2). IMHO the
> > main
> >>  > point is to hide these details from the actual business code. In your
> >>  code
> >>  > you just say "send message X to the user". If summary and
> > details are
> >>  > the
> >>  > same or not shouldn't be relevant at this point.
> >>  >
> >>  > Just my feelings regarding this. :)
> >>  >
> >>  > Christian
> >>  >
> >>  >
> >>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
> >>  >
> >>  >>  Mark,
> >>  >>
> >>  >>  As I've cited
> >>  >>  hello_you = Hello You
> >>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
> >>  >>
> >>  >>  Imagine i'm user. Now i have such questions:
> >>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set summary
> > or
> >>  details?
> >>  >>  2) Hm i've set summary, how do I set details? The API
> > doesn't tell
> >>  > me this,
> >>  >>  I have to reference some manuals to learn how to set details.
> >>  >>  3) What if (in one case in entire app) I want to set summary with
> > key
> >>  >>  {hello_you} and details from {goodbye_you}? In the rest of app I
> > could
> >>  use
> >>  >>  approach as you've proposed, but this once i want to do
> > custom?
> >>  >>
> >>  >>  Please, do not take this as criticism, it's just my gut
> > feeling.
> >>  >>
> >>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
> >>  >>
> >>  >>  > Hi Bernard!
> >>  >>  >
> >>  >>  > which part of it do you consider as magic?
> >>  >>  >
> >>  >>  > I think the Message.getCategory(String) is fine (feel free
> > to suggest
> >>  > a
> >>  >>  > better name for the method)
> >>  >>  > A category is just a different resource pattern for the same
> >>  > parameters.
> >>  >>  > Like short text and long text of the same message.
> >>  >>  >
> >>  >>  > Imagine a user makes
> >>  >>  >
> >>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
> >>  >>  >
> >>  >>  >
> >>  >>  > msg.addError().userNotAllowed(loggedInUser);
> >>  >>  >
> >>  >>  > which would automatically use the property without as
> > fallback and
> >>  the
> >>  >>  > categories 'summary' and 'detail' for
> > creating the
> >>  > FacesMessage.
> >>  >>  > Those 2 categories are of course a contract of the
> > JsfMessage
> >>  >>  > implementation.
> >>  >>  >
> >>  >>  >
> >>  >>  > But even for non JSF messages it would make sense.
> >>  >>  >
> >>  >>  > @Inject MyCheckMessages msg;
> >>  >>  >
> >>  >>  >
> > msg.userNotAllowed(loggedInUser).getCategory('shortText');
> >>  >>  >
> >>  >>  > The category String should be a well documented final static
> > String
> >>  >>  > somewhere of course.
> >>  >>  >
> >>  >>  > LieGrue,
> >>  >>  > strub
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  >
> >>  >>  > >________________________________
> >>  >>  > > From: Bernard Łabno <s4...@pjwstk.edu.pl>
> >>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark Struberg
> > <
> >>  >>  struberg@yahoo.de
> >>  >>  > >
> >>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
> >>  >>  > >Subject: Re: proposal for JSF Messages
> >>  >>  > >
> >>  >>  > >
> >>  >>  > >Mark,
> >>  >>  > >
> >>  >>  > >Most of ideas are great, but I think that following will
> > be
> >>  > considered
> >>  >>  as
> >>  >>  > "magic" (too magic) by users.
> >>  >>  > >
> >>  >>  > >
> >>  >>  > >for a "{hello_you}" you can have entries in
> > your
> >>  > properties file
> >>  >>  > >>
> >>  >>  > >>hello_you = Hello You
> >>  >>  > >>hello_you.detail = Good evening Ladies and
> > Gentlemen!
> >>  >>  > >>
> >>  >>  > >
> >>  >>  > >
> >>  >>  > >2012/10/5 Mark Struberg <st...@yahoo.de>
> >>  >>  > >
> >>  >>  > >Yes, that was the final idea.
> >>  >>  > >>
> >>  >>  > >>I originally thought about extending the
> > @MessageBundle and
> >>  > let the
> >>  >>  > interface optionally return a String[]. But I think this is
> > too
> >>  > complex
> >>  >>  to
> >>  >>  > get right
> >>  >>  > >>
> >>  >>  > >>Instead I'd rather introduce a
> >>  >>  > >>Message#toString(String category); and
> >>  >>  > >>
> >>  >>  > >>Message#toString(MessageContext context, String
> > category);
> >>  >>  > >>
> >>  >>  > >>for a "{hello_you}" you can have entries
> > in your
> >>  > properties file
> >>  >>  > >>
> >>  >>  > >>hello_you = Hello You
> >>  >>  > >>hello_you.detail = Good evening Ladies and
> > Gentlemen!
> >>  >>  > >>
> >>  >>  > >>
> >>  >>  > >>If a user just returns a String in his interface,
> > then both
> >>  > detail and
> >>  >>  > summary will be set with the same text
> >>  >>  > >>If a user returns a Message, then we can look
> > deeper.
> >>  >>  > >>
> >>  >>  > >>LieGrue,
> >>  >>  > >>strub
> >>  >>  > >>
> >>  >>  > >>
> >>  >>  > >>
> >>  >>  > >>
> >>  >>  > >>----- Original Message -----
> >>  >>  > >>> From: Gerhard Petracek
> > <ge...@gmail.com>
> >>  >>  > >>> To: deltaspike-dev@incubator.apache.org
> >>  >>  > >>> Cc:
> >>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
> >>  >>  > >>> Subject: Re: proposal for JSF Messages
> >>  >>  > >>>
> >>  >>  > >>>t he example provided by mark could add a global
> > message
> >>  > with the same
> >>  >>  > >>
> >>  >>  > >>> summary- and detail-message.
> >>  >>  > >>> -> we just need those methods with
> > additional
> >>  > parameters.
> >>  >>  > >>>
> >>  >>  > >>> regards,
> >>  >>  > >>> gerhard
> >>  >>  > >>>
> >>  >>  > >>>
> >>  >>  > >>>
> >>  >>  > >>> 2012/10/5 Ken Finnigan
> > <ke...@kenfinnigan.me>
> >>  >>  > >>>
> >>  >>  > >>>>  Some additional plans for messages that
> > may be
> >>  > relevant to JSF have
> >>  >>  > been
> >>  >>  > >>>>  documented in [1].
> >>  >>  > >>>>
> >>  >>  > >>>>  In Seam 3 International we had some ideas
> > around
> >>  > targeting a
> >>  >>  message
> >>  >>  > at a
> >>  >>  > >>>>  specific component which are noted here
> > [2].
> >>  >>  > >>>>
> >>  >>  > >>>>  Ken
> >>  >>  > >>>>
> >>  >>  > >>>>  [1]
> >>  >>  > >>>>
> >>  >>  > >>>>
> >>  >>  > >>>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>  >>  > >>>>  [2]
> >>  >>  > >>>>
> >>  >>  > >>>>
> >>  >>  > >>>
> >>  >>  >
> >>  >>
> >>  >
> >>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>  >>  > >>>>
> >>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard
> > Petracek
> >>  > <
> >>  >>  > >>>>  gerhard.petracek@gmail.com
> >>  >>  > >>>>  > wrote:
> >>  >>  > >>>>
> >>  >>  > >>>>  > hi jason,
> >>  >>  > >>>>  >
> >>  >>  > >>>>  > that's for sure just a first
> > idea.
> >>  >>  > >>>>  > e.g. we also need the possibility to
> > add
> >>  > messages for a specific
> >>  >>  > >>>>  component.
> >>  >>  > >>>>  >
> >>  >>  > >>>>  > regards,
> >>  >>  > >>>>  > gerhard
> >>  >>  > >>>>  >
> >>  >>  > >>>>  >
> >>  >>  > >>>>  >
> >>  >>  > >>>>  > 2012/10/5 Jason Porter
> >>  > <li...@gmail.com>
> >>  >>  > >>>>  >
> >>  >>  > >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM,
> > Mark
> >>  > Struberg
> >>  >>  > >>> <st...@yahoo.de>
> >>  >>  > >>>>  > 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
> >>  >>  > >>>>  > >
> >>  >>  > >>>>  >
> >>  >>  > >>>>
> >>  >>  > >>>
> >>  >>  > >>
> >>  >>  > >
> >>  >>  > >
> >>  >>  > >
> >>  >>  >
> >>  >>
> >>  >
> >>  >
> >>  >
> >>  > --
> >>  > Christian Kaltepoth
> >>  > Blog: http://chkal.blogspot.com/
> >>  > Twitter: http://twitter.com/chkal
> >>  >
> >>
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
Hi Gerhard!

We already found an easy solution.

I removed the restriction that @MessageBundles are only allowed to return a Message if they have a MessageContext parameter. I found no reason to restrict that.

If a user returns a Message intead of a String then we will use the categories 'summary' and 'detail' for creating the FacesMessage. Both fall back to the default value in their property files if they don't have a .summary or .detail entry in that language. If a String is being returned we use it for both summary and detail Strings.

This part is already implemented. I'm currently working on the Proxy for creating the JsfMessage<YourMessage> part.

LieGrue,
strub




----- Original Message -----
> From: Gerhard Petracek <ge...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Sunday, October 7, 2012 12:37 PM
> Subject: Re: proposal for JSF Messages
> 
> i would skip the #getCategory part for now. it's very similar to the
> type-safe message-payload used in codi and those parts are quite special
> already.
> 
> regards,
> gerhard
> 
> 
> 
> 2012/10/6 Mark Struberg <st...@yahoo.de>
> 
>>  I agree with Christian. From a developer perspective you will just use
>>  some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the 
> parameters. The
>>  developer usually doesn't care about the exact wording anyway ;)
>> 
>>  For the 3.) I think you should just use 2 different message template
>>  identifiers.
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>> 
>>  ----- Original Message -----
>>  > From: Christian Kaltepoth <ch...@kaltepoth.de>
>>  > To: deltaspike-dev@incubator.apache.org
>>  > Cc: Mark Struberg <st...@yahoo.de>
>>  > Sent: Saturday, October 6, 2012 11:42 AM
>>  > Subject: Re: proposal for JSF Messages
>>  >
>>  > Hey Bernard,
>>  >
>>  > I think the user shouldn't actually care about 1) and 2). IMHO the 
> main
>>  > point is to hide these details from the actual business code. In your
>>  code
>>  > you just say "send message X to the user". If summary and 
> details are
>>  > the
>>  > same or not shouldn't be relevant at this point.
>>  >
>>  > Just my feelings regarding this. :)
>>  >
>>  > Christian
>>  >
>>  >
>>  > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
>>  >
>>  >>  Mark,
>>  >>
>>  >>  As I've cited
>>  >>  hello_you = Hello You
>>  >>  hello_you.detail = Good evening Ladies and Gentlemen!
>>  >>
>>  >>  Imagine i'm user. Now i have such questions:
>>  >>  1) Does msg.addError().userNotAllowed(loggedInUser) set summary 
> or
>>  details?
>>  >>  2) Hm i've set summary, how do I set details? The API 
> doesn't tell
>>  > me this,
>>  >>  I have to reference some manuals to learn how to set details.
>>  >>  3) What if (in one case in entire app) I want to set summary with 
> key
>>  >>  {hello_you} and details from {goodbye_you}? In the rest of app I 
> could
>>  use
>>  >>  approach as you've proposed, but this once i want to do 
> custom?
>>  >>
>>  >>  Please, do not take this as criticism, it's just my gut 
> feeling.
>>  >>
>>  >>  2012/10/6 Mark Struberg <st...@yahoo.de>
>>  >>
>>  >>  > Hi Bernard!
>>  >>  >
>>  >>  > which part of it do you consider as magic?
>>  >>  >
>>  >>  > I think the Message.getCategory(String) is fine (feel free 
> to suggest
>>  > a
>>  >>  > better name for the method)
>>  >>  > A category is just a different resource pattern for the same
>>  > parameters.
>>  >>  > Like short text and long text of the same message.
>>  >>  >
>>  >>  > Imagine a user makes
>>  >>  >
>>  >>  > @Inject JsfMessage<MyCheckMessages> msg;
>>  >>  >
>>  >>  >
>>  >>  > msg.addError().userNotAllowed(loggedInUser);
>>  >>  >
>>  >>  > which would automatically use the property without as 
> fallback and
>>  the
>>  >>  > categories 'summary' and 'detail' for 
> creating the
>>  > FacesMessage.
>>  >>  > Those 2 categories are of course a contract of the 
> JsfMessage
>>  >>  > implementation.
>>  >>  >
>>  >>  >
>>  >>  > But even for non JSF messages it would make sense.
>>  >>  >
>>  >>  > @Inject MyCheckMessages msg;
>>  >>  >
>>  >>  > 
> msg.userNotAllowed(loggedInUser).getCategory('shortText');
>>  >>  >
>>  >>  > The category String should be a well documented final static 
> String
>>  >>  > somewhere of course.
>>  >>  >
>>  >>  > LieGrue,
>>  >>  > strub
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > >________________________________
>>  >>  > > From: Bernard Łabno <s4...@pjwstk.edu.pl>
>>  >>  > >To: deltaspike-dev@incubator.apache.org; Mark Struberg 
> <
>>  >>  struberg@yahoo.de
>>  >>  > >
>>  >>  > >Sent: Saturday, October 6, 2012 8:49 AM
>>  >>  > >Subject: Re: proposal for JSF Messages
>>  >>  > >
>>  >>  > >
>>  >>  > >Mark,
>>  >>  > >
>>  >>  > >Most of ideas are great, but I think that following will 
> be
>>  > considered
>>  >>  as
>>  >>  > "magic" (too magic) by users.
>>  >>  > >
>>  >>  > >
>>  >>  > >for a "{hello_you}" you can have entries in 
> your
>>  > properties file
>>  >>  > >>
>>  >>  > >>hello_you = Hello You
>>  >>  > >>hello_you.detail = Good evening Ladies and 
> Gentlemen!
>>  >>  > >>
>>  >>  > >
>>  >>  > >
>>  >>  > >2012/10/5 Mark Struberg <st...@yahoo.de>
>>  >>  > >
>>  >>  > >Yes, that was the final idea.
>>  >>  > >>
>>  >>  > >>I originally thought about extending the 
> @MessageBundle and
>>  > let the
>>  >>  > interface optionally return a String[]. But I think this is 
> too
>>  > complex
>>  >>  to
>>  >>  > get right
>>  >>  > >>
>>  >>  > >>Instead I'd rather introduce a
>>  >>  > >>Message#toString(String category); and
>>  >>  > >>
>>  >>  > >>Message#toString(MessageContext context, String 
> category);
>>  >>  > >>
>>  >>  > >>for a "{hello_you}" you can have entries 
> in your
>>  > properties file
>>  >>  > >>
>>  >>  > >>hello_you = Hello You
>>  >>  > >>hello_you.detail = Good evening Ladies and 
> Gentlemen!
>>  >>  > >>
>>  >>  > >>
>>  >>  > >>If a user just returns a String in his interface, 
> then both
>>  > detail and
>>  >>  > summary will be set with the same text
>>  >>  > >>If a user returns a Message, then we can look 
> deeper.
>>  >>  > >>
>>  >>  > >>LieGrue,
>>  >>  > >>strub
>>  >>  > >>
>>  >>  > >>
>>  >>  > >>
>>  >>  > >>
>>  >>  > >>----- Original Message -----
>>  >>  > >>> From: Gerhard Petracek 
> <ge...@gmail.com>
>>  >>  > >>> To: deltaspike-dev@incubator.apache.org
>>  >>  > >>> Cc:
>>  >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
>>  >>  > >>> Subject: Re: proposal for JSF Messages
>>  >>  > >>>
>>  >>  > >>>t he example provided by mark could add a global 
> message
>>  > with the same
>>  >>  > >>
>>  >>  > >>> summary- and detail-message.
>>  >>  > >>> -> we just need those methods with 
> additional
>>  > parameters.
>>  >>  > >>>
>>  >>  > >>> regards,
>>  >>  > >>> gerhard
>>  >>  > >>>
>>  >>  > >>>
>>  >>  > >>>
>>  >>  > >>> 2012/10/5 Ken Finnigan 
> <ke...@kenfinnigan.me>
>>  >>  > >>>
>>  >>  > >>>>  Some additional plans for messages that 
> may be
>>  > relevant to JSF have
>>  >>  > been
>>  >>  > >>>>  documented in [1].
>>  >>  > >>>>
>>  >>  > >>>>  In Seam 3 International we had some ideas 
> around
>>  > targeting a
>>  >>  message
>>  >>  > at a
>>  >>  > >>>>  specific component which are noted here 
> [2].
>>  >>  > >>>>
>>  >>  > >>>>  Ken
>>  >>  > >>>>
>>  >>  > >>>>  [1]
>>  >>  > >>>>
>>  >>  > >>>>
>>  >>  > >>>
>>  >>  >
>>  >>
>>  >
>> 
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>  >>  > >>>>  [2]
>>  >>  > >>>>
>>  >>  > >>>>
>>  >>  > >>>
>>  >>  >
>>  >>
>>  >
>> 
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>>  >>  > >>>>
>>  >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard 
> Petracek
>>  > <
>>  >>  > >>>>  gerhard.petracek@gmail.com
>>  >>  > >>>>  > wrote:
>>  >>  > >>>>
>>  >>  > >>>>  > hi jason,
>>  >>  > >>>>  >
>>  >>  > >>>>  > that's for sure just a first 
> idea.
>>  >>  > >>>>  > e.g. we also need the possibility to 
> add
>>  > messages for a specific
>>  >>  > >>>>  component.
>>  >>  > >>>>  >
>>  >>  > >>>>  > regards,
>>  >>  > >>>>  > gerhard
>>  >>  > >>>>  >
>>  >>  > >>>>  >
>>  >>  > >>>>  >
>>  >>  > >>>>  > 2012/10/5 Jason Porter
>>  > <li...@gmail.com>
>>  >>  > >>>>  >
>>  >>  > >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, 
> Mark
>>  > Struberg
>>  >>  > >>> <st...@yahoo.de>
>>  >>  > >>>>  > 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
>>  >>  > >>>>  > >
>>  >>  > >>>>  >
>>  >>  > >>>>
>>  >>  > >>>
>>  >>  > >>
>>  >>  > >
>>  >>  > >
>>  >>  > >
>>  >>  >
>>  >>
>>  >
>>  >
>>  >
>>  > --
>>  > Christian Kaltepoth
>>  > Blog: http://chkal.blogspot.com/
>>  > Twitter: http://twitter.com/chkal
>>  >
>> 
> 

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
i would skip the #getCategory part for now. it's very similar to the
type-safe message-payload used in codi and those parts are quite special
already.

regards,
gerhard



2012/10/6 Mark Struberg <st...@yahoo.de>

> I agree with Christian. From a developer perspective you will just use
> some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the parameters. The
> developer usually doesn't care about the exact wording anyway ;)
>
> For the 3.) I think you should just use 2 different message template
> identifiers.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Christian Kaltepoth <ch...@kaltepoth.de>
> > To: deltaspike-dev@incubator.apache.org
> > Cc: Mark Struberg <st...@yahoo.de>
> > Sent: Saturday, October 6, 2012 11:42 AM
> > Subject: Re: proposal for JSF Messages
> >
> > Hey Bernard,
> >
> > I think the user shouldn't actually care about 1) and 2). IMHO the main
> > point is to hide these details from the actual business code. In your
> code
> > you just say "send message X to the user". If summary and details are
> > the
> > same or not shouldn't be relevant at this point.
> >
> > Just my feelings regarding this. :)
> >
> > Christian
> >
> >
> > 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
> >
> >>  Mark,
> >>
> >>  As I've cited
> >>  hello_you = Hello You
> >>  hello_you.detail = Good evening Ladies and Gentlemen!
> >>
> >>  Imagine i'm user. Now i have such questions:
> >>  1) Does msg.addError().userNotAllowed(loggedInUser) set summary or
> details?
> >>  2) Hm i've set summary, how do I set details? The API doesn't tell
> > me this,
> >>  I have to reference some manuals to learn how to set details.
> >>  3) What if (in one case in entire app) I want to set summary with key
> >>  {hello_you} and details from {goodbye_you}? In the rest of app I could
> use
> >>  approach as you've proposed, but this once i want to do custom?
> >>
> >>  Please, do not take this as criticism, it's just my gut feeling.
> >>
> >>  2012/10/6 Mark Struberg <st...@yahoo.de>
> >>
> >>  > Hi Bernard!
> >>  >
> >>  > which part of it do you consider as magic?
> >>  >
> >>  > I think the Message.getCategory(String) is fine (feel free to suggest
> > a
> >>  > better name for the method)
> >>  > A category is just a different resource pattern for the same
> > parameters.
> >>  > Like short text and long text of the same message.
> >>  >
> >>  > Imagine a user makes
> >>  >
> >>  > @Inject JsfMessage<MyCheckMessages> msg;
> >>  >
> >>  >
> >>  > msg.addError().userNotAllowed(loggedInUser);
> >>  >
> >>  > which would automatically use the property without as fallback and
> the
> >>  > categories 'summary' and 'detail' for creating the
> > FacesMessage.
> >>  > Those 2 categories are of course a contract of the JsfMessage
> >>  > implementation.
> >>  >
> >>  >
> >>  > But even for non JSF messages it would make sense.
> >>  >
> >>  > @Inject MyCheckMessages msg;
> >>  >
> >>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
> >>  >
> >>  > The category String should be a well documented final static String
> >>  > somewhere of course.
> >>  >
> >>  > LieGrue,
> >>  > strub
> >>  >
> >>  >
> >>  >
> >>  >
> >>  >
> >>  >
> >>  > >________________________________
> >>  > > From: Bernard Łabno <s4...@pjwstk.edu.pl>
> >>  > >To: deltaspike-dev@incubator.apache.org; Mark Struberg <
> >>  struberg@yahoo.de
> >>  > >
> >>  > >Sent: Saturday, October 6, 2012 8:49 AM
> >>  > >Subject: Re: proposal for JSF Messages
> >>  > >
> >>  > >
> >>  > >Mark,
> >>  > >
> >>  > >Most of ideas are great, but I think that following will be
> > considered
> >>  as
> >>  > "magic" (too magic) by users.
> >>  > >
> >>  > >
> >>  > >for a "{hello_you}" you can have entries in your
> > properties file
> >>  > >>
> >>  > >>hello_you = Hello You
> >>  > >>hello_you.detail = Good evening Ladies and Gentlemen!
> >>  > >>
> >>  > >
> >>  > >
> >>  > >2012/10/5 Mark Struberg <st...@yahoo.de>
> >>  > >
> >>  > >Yes, that was the final idea.
> >>  > >>
> >>  > >>I originally thought about extending the @MessageBundle and
> > let the
> >>  > interface optionally return a String[]. But I think this is too
> > complex
> >>  to
> >>  > get right
> >>  > >>
> >>  > >>Instead I'd rather introduce a
> >>  > >>Message#toString(String category); and
> >>  > >>
> >>  > >>Message#toString(MessageContext context, String category);
> >>  > >>
> >>  > >>for a "{hello_you}" you can have entries in your
> > properties file
> >>  > >>
> >>  > >>hello_you = Hello You
> >>  > >>hello_you.detail = Good evening Ladies and Gentlemen!
> >>  > >>
> >>  > >>
> >>  > >>If a user just returns a String in his interface, then both
> > detail and
> >>  > summary will be set with the same text
> >>  > >>If a user returns a Message, then we can look deeper.
> >>  > >>
> >>  > >>LieGrue,
> >>  > >>strub
> >>  > >>
> >>  > >>
> >>  > >>
> >>  > >>
> >>  > >>----- Original Message -----
> >>  > >>> From: Gerhard Petracek <ge...@gmail.com>
> >>  > >>> To: deltaspike-dev@incubator.apache.org
> >>  > >>> Cc:
> >>  > >>> Sent: Friday, October 5, 2012 9:57 PM
> >>  > >>> Subject: Re: proposal for JSF Messages
> >>  > >>>
> >>  > >>>t he example provided by mark could add a global message
> > with the same
> >>  > >>
> >>  > >>> summary- and detail-message.
> >>  > >>> -> we just need those methods with additional
> > parameters.
> >>  > >>>
> >>  > >>> regards,
> >>  > >>> gerhard
> >>  > >>>
> >>  > >>>
> >>  > >>>
> >>  > >>> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
> >>  > >>>
> >>  > >>>>  Some additional plans for messages that may be
> > relevant to JSF have
> >>  > been
> >>  > >>>>  documented in [1].
> >>  > >>>>
> >>  > >>>>  In Seam 3 International we had some ideas around
> > targeting a
> >>  message
> >>  > at a
> >>  > >>>>  specific component which are noted here [2].
> >>  > >>>>
> >>  > >>>>  Ken
> >>  > >>>>
> >>  > >>>>  [1]
> >>  > >>>>
> >>  > >>>>
> >>  > >>>
> >>  >
> >>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>  > >>>>  [2]
> >>  > >>>>
> >>  > >>>>
> >>  > >>>
> >>  >
> >>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>  > >>>>
> >>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek
> > <
> >>  > >>>>  gerhard.petracek@gmail.com
> >>  > >>>>  > wrote:
> >>  > >>>>
> >>  > >>>>  > hi jason,
> >>  > >>>>  >
> >>  > >>>>  > that's for sure just a first idea.
> >>  > >>>>  > e.g. we also need the possibility to add
> > messages for a specific
> >>  > >>>>  component.
> >>  > >>>>  >
> >>  > >>>>  > regards,
> >>  > >>>>  > gerhard
> >>  > >>>>  >
> >>  > >>>>  >
> >>  > >>>>  >
> >>  > >>>>  > 2012/10/5 Jason Porter
> > <li...@gmail.com>
> >>  > >>>>  >
> >>  > >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark
> > Struberg
> >>  > >>> <st...@yahoo.de>
> >>  > >>>>  > 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
> >>  > >>>>  > >
> >>  > >>>>  >
> >>  > >>>>
> >>  > >>>
> >>  > >>
> >>  > >
> >>  > >
> >>  > >
> >>  >
> >>
> >
> >
> >
> > --
> > Christian Kaltepoth
> > Blog: http://chkal.blogspot.com/
> > Twitter: http://twitter.com/chkal
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
I agree with Christian. From a developer perspective you will just use some abstract "{PAGEX_USER_NOT_ALLOWED}" and define the parameters. The developer usually doesn't care about the exact wording anyway ;)

For the 3.) I think you should just use 2 different message template identifiers.

LieGrue,
strub




----- Original Message -----
> From: Christian Kaltepoth <ch...@kaltepoth.de>
> To: deltaspike-dev@incubator.apache.org
> Cc: Mark Struberg <st...@yahoo.de>
> Sent: Saturday, October 6, 2012 11:42 AM
> Subject: Re: proposal for JSF Messages
> 
> Hey Bernard,
> 
> I think the user shouldn't actually care about 1) and 2). IMHO the main
> point is to hide these details from the actual business code. In your code
> you just say "send message X to the user". If summary and details are 
> the
> same or not shouldn't be relevant at this point.
> 
> Just my feelings regarding this. :)
> 
> Christian
> 
> 
> 2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>
> 
>>  Mark,
>> 
>>  As I've cited
>>  hello_you = Hello You
>>  hello_you.detail = Good evening Ladies and Gentlemen!
>> 
>>  Imagine i'm user. Now i have such questions:
>>  1) Does msg.addError().userNotAllowed(loggedInUser) set summary or details?
>>  2) Hm i've set summary, how do I set details? The API doesn't tell 
> me this,
>>  I have to reference some manuals to learn how to set details.
>>  3) What if (in one case in entire app) I want to set summary with key
>>  {hello_you} and details from {goodbye_you}? In the rest of app I could use
>>  approach as you've proposed, but this once i want to do custom?
>> 
>>  Please, do not take this as criticism, it's just my gut feeling.
>> 
>>  2012/10/6 Mark Struberg <st...@yahoo.de>
>> 
>>  > Hi Bernard!
>>  >
>>  > which part of it do you consider as magic?
>>  >
>>  > I think the Message.getCategory(String) is fine (feel free to suggest 
> a
>>  > better name for the method)
>>  > A category is just a different resource pattern for the same 
> parameters.
>>  > Like short text and long text of the same message.
>>  >
>>  > Imagine a user makes
>>  >
>>  > @Inject JsfMessage<MyCheckMessages> msg;
>>  >
>>  >
>>  > msg.addError().userNotAllowed(loggedInUser);
>>  >
>>  > which would automatically use the property without as fallback and the
>>  > categories 'summary' and 'detail' for creating the 
> FacesMessage.
>>  > Those 2 categories are of course a contract of the JsfMessage
>>  > implementation.
>>  >
>>  >
>>  > But even for non JSF messages it would make sense.
>>  >
>>  > @Inject MyCheckMessages msg;
>>  >
>>  > msg.userNotAllowed(loggedInUser).getCategory('shortText');
>>  >
>>  > The category String should be a well documented final static String
>>  > somewhere of course.
>>  >
>>  > LieGrue,
>>  > strub
>>  >
>>  >
>>  >
>>  >
>>  >
>>  >
>>  > >________________________________
>>  > > From: Bernard Łabno <s4...@pjwstk.edu.pl>
>>  > >To: deltaspike-dev@incubator.apache.org; Mark Struberg <
>>  struberg@yahoo.de
>>  > >
>>  > >Sent: Saturday, October 6, 2012 8:49 AM
>>  > >Subject: Re: proposal for JSF Messages
>>  > >
>>  > >
>>  > >Mark,
>>  > >
>>  > >Most of ideas are great, but I think that following will be 
> considered
>>  as
>>  > "magic" (too magic) by users.
>>  > >
>>  > >
>>  > >for a "{hello_you}" you can have entries in your 
> properties file
>>  > >>
>>  > >>hello_you = Hello You
>>  > >>hello_you.detail = Good evening Ladies and Gentlemen!
>>  > >>
>>  > >
>>  > >
>>  > >2012/10/5 Mark Struberg <st...@yahoo.de>
>>  > >
>>  > >Yes, that was the final idea.
>>  > >>
>>  > >>I originally thought about extending the @MessageBundle and 
> let the
>>  > interface optionally return a String[]. But I think this is too 
> complex
>>  to
>>  > get right
>>  > >>
>>  > >>Instead I'd rather introduce a
>>  > >>Message#toString(String category); and
>>  > >>
>>  > >>Message#toString(MessageContext context, String category);
>>  > >>
>>  > >>for a "{hello_you}" you can have entries in your 
> properties file
>>  > >>
>>  > >>hello_you = Hello You
>>  > >>hello_you.detail = Good evening Ladies and Gentlemen!
>>  > >>
>>  > >>
>>  > >>If a user just returns a String in his interface, then both 
> detail and
>>  > summary will be set with the same text
>>  > >>If a user returns a Message, then we can look deeper.
>>  > >>
>>  > >>LieGrue,
>>  > >>strub
>>  > >>
>>  > >>
>>  > >>
>>  > >>
>>  > >>----- Original Message -----
>>  > >>> From: Gerhard Petracek <ge...@gmail.com>
>>  > >>> To: deltaspike-dev@incubator.apache.org
>>  > >>> Cc:
>>  > >>> Sent: Friday, October 5, 2012 9:57 PM
>>  > >>> Subject: Re: proposal for JSF Messages
>>  > >>>
>>  > >>>t he example provided by mark could add a global message 
> with the same
>>  > >>
>>  > >>> summary- and detail-message.
>>  > >>> -> we just need those methods with additional 
> parameters.
>>  > >>>
>>  > >>> regards,
>>  > >>> gerhard
>>  > >>>
>>  > >>>
>>  > >>>
>>  > >>> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
>>  > >>>
>>  > >>>>  Some additional plans for messages that may be 
> relevant to JSF have
>>  > been
>>  > >>>>  documented in [1].
>>  > >>>>
>>  > >>>>  In Seam 3 International we had some ideas around 
> targeting a
>>  message
>>  > at a
>>  > >>>>  specific component which are noted here [2].
>>  > >>>>
>>  > >>>>  Ken
>>  > >>>>
>>  > >>>>  [1]
>>  > >>>>
>>  > >>>>
>>  > >>>
>>  >
>> 
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>  > >>>>  [2]
>>  > >>>>
>>  > >>>>
>>  > >>>
>>  >
>> 
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>>  > >>>>
>>  > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek 
> <
>>  > >>>>  gerhard.petracek@gmail.com
>>  > >>>>  > wrote:
>>  > >>>>
>>  > >>>>  > hi jason,
>>  > >>>>  >
>>  > >>>>  > that's for sure just a first idea.
>>  > >>>>  > e.g. we also need the possibility to add 
> messages for a specific
>>  > >>>>  component.
>>  > >>>>  >
>>  > >>>>  > regards,
>>  > >>>>  > gerhard
>>  > >>>>  >
>>  > >>>>  >
>>  > >>>>  >
>>  > >>>>  > 2012/10/5 Jason Porter 
> <li...@gmail.com>
>>  > >>>>  >
>>  > >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark 
> Struberg
>>  > >>> <st...@yahoo.de>
>>  > >>>>  > 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
>>  > >>>>  > >
>>  > >>>>  >
>>  > >>>>
>>  > >>>
>>  > >>
>>  > >
>>  > >
>>  > >
>>  >
>> 
> 
> 
> 
> -- 
> Christian Kaltepoth
> Blog: http://chkal.blogspot.com/
> Twitter: http://twitter.com/chkal
> 

Re: proposal for JSF Messages

Posted by Christian Kaltepoth <ch...@kaltepoth.de>.
Hey Bernard,

I think the user shouldn't actually care about 1) and 2). IMHO the main
point is to hide these details from the actual business code. In your code
you just say "send message X to the user". If summary and details are the
same or not shouldn't be relevant at this point.

Just my feelings regarding this. :)

Christian


2012/10/6 Bernard Łabno <s4...@pjwstk.edu.pl>

> Mark,
>
> As I've cited
> hello_you = Hello You
> hello_you.detail = Good evening Ladies and Gentlemen!
>
> Imagine i'm user. Now i have such questions:
> 1) Does msg.addError().userNotAllowed(loggedInUser) set summary or details?
> 2) Hm i've set summary, how do I set details? The API doesn't tell me this,
> I have to reference some manuals to learn how to set details.
> 3) What if (in one case in entire app) I want to set summary with key
> {hello_you} and details from {goodbye_you}? In the rest of app I could use
> approach as you've proposed, but this once i want to do custom?
>
> Please, do not take this as criticism, it's just my gut feeling.
>
> 2012/10/6 Mark Struberg <st...@yahoo.de>
>
> > Hi Bernard!
> >
> > which part of it do you consider as magic?
> >
> > I think the Message.getCategory(String) is fine (feel free to suggest a
> > better name for the method)
> > A category is just a different resource pattern for the same parameters.
> > Like short text and long text of the same message.
> >
> > Imagine a user makes
> >
> > @Inject JsfMessage<MyCheckMessages> msg;
> >
> >
> > msg.addError().userNotAllowed(loggedInUser);
> >
> > which would automatically use the property without as fallback and the
> > categories 'summary' and 'detail' for creating the FacesMessage.
> > Those 2 categories are of course a contract of the JsfMessage
> > implementation.
> >
> >
> > But even for non JSF messages it would make sense.
> >
> > @Inject MyCheckMessages msg;
> >
> > msg.userNotAllowed(loggedInUser).getCategory('shortText');
> >
> > The category String should be a well documented final static String
> > somewhere of course.
> >
> > LieGrue,
> > strub
> >
> >
> >
> >
> >
> >
> > >________________________________
> > > From: Bernard Łabno <s4...@pjwstk.edu.pl>
> > >To: deltaspike-dev@incubator.apache.org; Mark Struberg <
> struberg@yahoo.de
> > >
> > >Sent: Saturday, October 6, 2012 8:49 AM
> > >Subject: Re: proposal for JSF Messages
> > >
> > >
> > >Mark,
> > >
> > >Most of ideas are great, but I think that following will be considered
> as
> > "magic" (too magic) by users.
> > >
> > >
> > >for a "{hello_you}" you can have entries in your properties file
> > >>
> > >>hello_you = Hello You
> > >>hello_you.detail = Good evening Ladies and Gentlemen!
> > >>
> > >
> > >
> > >2012/10/5 Mark Struberg <st...@yahoo.de>
> > >
> > >Yes, that was the final idea.
> > >>
> > >>I originally thought about extending the @MessageBundle and let the
> > interface optionally return a String[]. But I think this is too complex
> to
> > get right
> > >>
> > >>Instead I'd rather introduce a
> > >>Message#toString(String category); and
> > >>
> > >>Message#toString(MessageContext context, String category);
> > >>
> > >>for a "{hello_you}" you can have entries in your properties file
> > >>
> > >>hello_you = Hello You
> > >>hello_you.detail = Good evening Ladies and Gentlemen!
> > >>
> > >>
> > >>If a user just returns a String in his interface, then both detail and
> > summary will be set with the same text
> > >>If a user returns a Message, then we can look deeper.
> > >>
> > >>LieGrue,
> > >>strub
> > >>
> > >>
> > >>
> > >>
> > >>----- Original Message -----
> > >>> From: Gerhard Petracek <ge...@gmail.com>
> > >>> To: deltaspike-dev@incubator.apache.org
> > >>> Cc:
> > >>> Sent: Friday, October 5, 2012 9:57 PM
> > >>> Subject: Re: proposal for JSF Messages
> > >>>
> > >>>t he example provided by mark could add a global message with the same
> > >>
> > >>> summary- and detail-message.
> > >>> -> we just need those methods with additional parameters.
> > >>>
> > >>> regards,
> > >>> gerhard
> > >>>
> > >>>
> > >>>
> > >>> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
> > >>>
> > >>>>  Some additional plans for messages that may be relevant to JSF have
> > been
> > >>>>  documented in [1].
> > >>>>
> > >>>>  In Seam 3 International we had some ideas around targeting a
> message
> > at a
> > >>>>  specific component which are noted here [2].
> > >>>>
> > >>>>  Ken
> > >>>>
> > >>>>  [1]
> > >>>>
> > >>>>
> > >>>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> > >>>>  [2]
> > >>>>
> > >>>>
> > >>>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> > >>>>
> > >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
> > >>>>  gerhard.petracek@gmail.com
> > >>>>  > wrote:
> > >>>>
> > >>>>  > hi jason,
> > >>>>  >
> > >>>>  > that's for sure just a first idea.
> > >>>>  > e.g. we also need the possibility to add messages for a specific
> > >>>>  component.
> > >>>>  >
> > >>>>  > regards,
> > >>>>  > gerhard
> > >>>>  >
> > >>>>  >
> > >>>>  >
> > >>>>  > 2012/10/5 Jason Porter <li...@gmail.com>
> > >>>>  >
> > >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg
> > >>> <st...@yahoo.de>
> > >>>>  > 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
> > >>>>  > >
> > >>>>  >
> > >>>>
> > >>>
> > >>
> > >
> > >
> > >
> >
>



-- 
Christian Kaltepoth
Blog: http://chkal.blogspot.com/
Twitter: http://twitter.com/chkal

Re: proposal for JSF Messages

Posted by Bernard Łabno <s4...@pjwstk.edu.pl>.
Mark,

As I've cited
hello_you = Hello You
hello_you.detail = Good evening Ladies and Gentlemen!

Imagine i'm user. Now i have such questions:
1) Does msg.addError().userNotAllowed(loggedInUser) set summary or details?
2) Hm i've set summary, how do I set details? The API doesn't tell me this,
I have to reference some manuals to learn how to set details.
3) What if (in one case in entire app) I want to set summary with key
{hello_you} and details from {goodbye_you}? In the rest of app I could use
approach as you've proposed, but this once i want to do custom?

Please, do not take this as criticism, it's just my gut feeling.

2012/10/6 Mark Struberg <st...@yahoo.de>

> Hi Bernard!
>
> which part of it do you consider as magic?
>
> I think the Message.getCategory(String) is fine (feel free to suggest a
> better name for the method)
> A category is just a different resource pattern for the same parameters.
> Like short text and long text of the same message.
>
> Imagine a user makes
>
> @Inject JsfMessage<MyCheckMessages> msg;
>
>
> msg.addError().userNotAllowed(loggedInUser);
>
> which would automatically use the property without as fallback and the
> categories 'summary' and 'detail' for creating the FacesMessage.
> Those 2 categories are of course a contract of the JsfMessage
> implementation.
>
>
> But even for non JSF messages it would make sense.
>
> @Inject MyCheckMessages msg;
>
> msg.userNotAllowed(loggedInUser).getCategory('shortText');
>
> The category String should be a well documented final static String
> somewhere of course.
>
> LieGrue,
> strub
>
>
>
>
>
>
> >________________________________
> > From: Bernard Łabno <s4...@pjwstk.edu.pl>
> >To: deltaspike-dev@incubator.apache.org; Mark Struberg <struberg@yahoo.de
> >
> >Sent: Saturday, October 6, 2012 8:49 AM
> >Subject: Re: proposal for JSF Messages
> >
> >
> >Mark,
> >
> >Most of ideas are great, but I think that following will be considered as
> "magic" (too magic) by users.
> >
> >
> >for a "{hello_you}" you can have entries in your properties file
> >>
> >>hello_you = Hello You
> >>hello_you.detail = Good evening Ladies and Gentlemen!
> >>
> >
> >
> >2012/10/5 Mark Struberg <st...@yahoo.de>
> >
> >Yes, that was the final idea.
> >>
> >>I originally thought about extending the @MessageBundle and let the
> interface optionally return a String[]. But I think this is too complex to
> get right
> >>
> >>Instead I'd rather introduce a
> >>Message#toString(String category); and
> >>
> >>Message#toString(MessageContext context, String category);
> >>
> >>for a "{hello_you}" you can have entries in your properties file
> >>
> >>hello_you = Hello You
> >>hello_you.detail = Good evening Ladies and Gentlemen!
> >>
> >>
> >>If a user just returns a String in his interface, then both detail and
> summary will be set with the same text
> >>If a user returns a Message, then we can look deeper.
> >>
> >>LieGrue,
> >>strub
> >>
> >>
> >>
> >>
> >>----- Original Message -----
> >>> From: Gerhard Petracek <ge...@gmail.com>
> >>> To: deltaspike-dev@incubator.apache.org
> >>> Cc:
> >>> Sent: Friday, October 5, 2012 9:57 PM
> >>> Subject: Re: proposal for JSF Messages
> >>>
> >>>t he example provided by mark could add a global message with the same
> >>
> >>> summary- and detail-message.
> >>> -> we just need those methods with additional parameters.
> >>>
> >>> regards,
> >>> gerhard
> >>>
> >>>
> >>>
> >>> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
> >>>
> >>>>  Some additional plans for messages that may be relevant to JSF have
> been
> >>>>  documented in [1].
> >>>>
> >>>>  In Seam 3 International we had some ideas around targeting a message
> at a
> >>>>  specific component which are noted here [2].
> >>>>
> >>>>  Ken
> >>>>
> >>>>  [1]
> >>>>
> >>>>
> >>>
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>>>  [2]
> >>>>
> >>>>
> >>>
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>>>
> >>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
> >>>>  gerhard.petracek@gmail.com
> >>>>  > wrote:
> >>>>
> >>>>  > hi jason,
> >>>>  >
> >>>>  > that's for sure just a first idea.
> >>>>  > e.g. we also need the possibility to add messages for a specific
> >>>>  component.
> >>>>  >
> >>>>  > regards,
> >>>>  > gerhard
> >>>>  >
> >>>>  >
> >>>>  >
> >>>>  > 2012/10/5 Jason Porter <li...@gmail.com>
> >>>>  >
> >>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg
> >>> <st...@yahoo.de>
> >>>>  > 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
> >>>>  > >
> >>>>  >
> >>>>
> >>>
> >>
> >
> >
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
Hi Bernard!

which part of it do you consider as magic?

I think the Message.getCategory(String) is fine (feel free to suggest a better name for the method)
A category is just a different resource pattern for the same parameters. Like short text and long text of the same message.

Imagine a user makes

@Inject JsfMessage<MyCheckMessages> msg;


msg.addError().userNotAllowed(loggedInUser);

which would automatically use the property without as fallback and the categories 'summary' and 'detail' for creating the FacesMessage.
Those 2 categories are of course a contract of the JsfMessage implementation.


But even for non JSF messages it would make sense.

@Inject MyCheckMessages msg;

msg.userNotAllowed(loggedInUser).getCategory('shortText');

The category String should be a well documented final static String somewhere of course.

LieGrue,
strub






>________________________________
> From: Bernard Łabno <s4...@pjwstk.edu.pl>
>To: deltaspike-dev@incubator.apache.org; Mark Struberg <st...@yahoo.de> 
>Sent: Saturday, October 6, 2012 8:49 AM
>Subject: Re: proposal for JSF Messages
> 
>
>Mark,
>
>Most of ideas are great, but I think that following will be considered as "magic" (too magic) by users.
>
>
>for a “{hello_you}" you can have entries in your properties file
>>
>>hello_you = Hello You
>>hello_you.detail = Good evening Ladies and Gentlemen!
>>
>
>
>2012/10/5 Mark Struberg <st...@yahoo.de>
>
>Yes, that was the final idea.
>>
>>I originally thought about extending the @MessageBundle and let the interface optionally return a String[]. But I think this is too complex to get right
>>
>>Instead I'd rather introduce a
>>Message#toString(String category); and
>>
>>Message#toString(MessageContext context, String category);
>>
>>for a “{hello_you}" you can have entries in your properties file
>>
>>hello_you = Hello You
>>hello_you.detail = Good evening Ladies and Gentlemen!
>>
>>
>>If a user just returns a String in his interface, then both detail and summary will be set with the same text
>>If a user returns a Message, then we can look deeper.
>>
>>LieGrue,
>>strub
>>
>>
>>
>>
>>----- Original Message -----
>>> From: Gerhard Petracek <ge...@gmail.com>
>>> To: deltaspike-dev@incubator.apache.org
>>> Cc:
>>> Sent: Friday, October 5, 2012 9:57 PM
>>> Subject: Re: proposal for JSF Messages
>>>
>>>t he example provided by mark could add a global message with the same
>>
>>> summary- and detail-message.
>>> -> we just need those methods with additional parameters.
>>>
>>> regards,
>>> gerhard
>>>
>>>
>>>
>>> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
>>>
>>>>  Some additional plans for messages that may be relevant to JSF have been
>>>>  documented in [1].
>>>>
>>>>  In Seam 3 International we had some ideas around targeting a message at a
>>>>  specific component which are noted here [2].
>>>>
>>>>  Ken
>>>>
>>>>  [1]
>>>>
>>>>
>>> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>>>  [2]
>>>>
>>>>
>>> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>>>>
>>>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
>>>>  gerhard.petracek@gmail.com
>>>>  > wrote:
>>>>
>>>>  > hi jason,
>>>>  >
>>>>  > that's for sure just a first idea.
>>>>  > e.g. we also need the possibility to add messages for a specific
>>>>  component.
>>>>  >
>>>>  > regards,
>>>>  > gerhard
>>>>  >
>>>>  >
>>>>  >
>>>>  > 2012/10/5 Jason Porter <li...@gmail.com>
>>>>  >
>>>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg
>>> <st...@yahoo.de>
>>>>  > 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
>>>>  > >
>>>>  >
>>>>
>>>
>>
>
>
>

Re: proposal for JSF Messages

Posted by Bernard Łabno <s4...@pjwstk.edu.pl>.
Mark,

Most of ideas are great, but I think that following will be considered as
"magic" (too magic) by users.

for a “{hello_you}" you can have entries in your properties file
>
> hello_you = Hello You
> hello_you.detail = Good evening Ladies and Gentlemen!
>


2012/10/5 Mark Struberg <st...@yahoo.de>

> Yes, that was the final idea.
>
> I originally thought about extending the @MessageBundle and let the
> interface optionally return a String[]. But I think this is too complex to
> get right
>
> Instead I'd rather introduce a
> Message#toString(String category); and
>
> Message#toString(MessageContext context, String category);
>
> for a “{hello_you}" you can have entries in your properties file
>
> hello_you = Hello You
> hello_you.detail = Good evening Ladies and Gentlemen!
>
>
> If a user just returns a String in his interface, then both detail and
> summary will be set with the same text
> If a user returns a Message, then we can look deeper.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Gerhard Petracek <ge...@gmail.com>
> > To: deltaspike-dev@incubator.apache.org
> > Cc:
> > Sent: Friday, October 5, 2012 9:57 PM
> > Subject: Re: proposal for JSF Messages
> >
> >t he example provided by mark could add a global message with the same
> > summary- and detail-message.
> > -> we just need those methods with additional parameters.
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
> >
> >>  Some additional plans for messages that may be relevant to JSF have
> been
> >>  documented in [1].
> >>
> >>  In Seam 3 International we had some ideas around targeting a message
> at a
> >>  specific component which are noted here [2].
> >>
> >>  Ken
> >>
> >>  [1]
> >>
> >>
> >
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> >>  [2]
> >>
> >>
> >
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
> >>
> >>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
> >>  gerhard.petracek@gmail.com
> >>  > wrote:
> >>
> >>  > hi jason,
> >>  >
> >>  > that's for sure just a first idea.
> >>  > e.g. we also need the possibility to add messages for a specific
> >>  component.
> >>  >
> >>  > regards,
> >>  > gerhard
> >>  >
> >>  >
> >>  >
> >>  > 2012/10/5 Jason Porter <li...@gmail.com>
> >>  >
> >>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg
> > <st...@yahoo.de>
> >>  > 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
> >>  > >
> >>  >
> >>
> >
>

Re: proposal for JSF Messages

Posted by Mark Struberg <st...@yahoo.de>.
Yes, that was the final idea. 

I originally thought about extending the @MessageBundle and let the interface optionally return a String[]. But I think this is too complex to get right

Instead I'd rather introduce a 
Message#toString(String category); and

Message#toString(MessageContext context, String category);

for a “{hello_you}" you can have entries in your properties file

hello_you = Hello You
hello_you.detail = Good evening Ladies and Gentlemen!


If a user just returns a String in his interface, then both detail and summary will be set with the same text
If a user returns a Message, then we can look deeper.

LieGrue,
strub




----- Original Message -----
> From: Gerhard Petracek <ge...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Friday, October 5, 2012 9:57 PM
> Subject: Re: proposal for JSF Messages
> 
>t he example provided by mark could add a global message with the same
> summary- and detail-message.
> -> we just need those methods with additional parameters.
> 
> regards,
> gerhard
> 
> 
> 
> 2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>
> 
>>  Some additional plans for messages that may be relevant to JSF have been
>>  documented in [1].
>> 
>>  In Seam 3 International we had some ideas around targeting a message at a
>>  specific component which are noted here [2].
>> 
>>  Ken
>> 
>>  [1]
>> 
>> 
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
>>  [2]
>> 
>> 
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>> 
>>  On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
>>  gerhard.petracek@gmail.com
>>  > wrote:
>> 
>>  > hi jason,
>>  >
>>  > that's for sure just a first idea.
>>  > e.g. we also need the possibility to add messages for a specific
>>  component.
>>  >
>>  > regards,
>>  > gerhard
>>  >
>>  >
>>  >
>>  > 2012/10/5 Jason Porter <li...@gmail.com>
>>  >
>>  > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg 
> <st...@yahoo.de>
>>  > 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
>>  > >
>>  >
>> 
> 

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
the example provided by mark could add a global message with the same
summary- and detail-message.
-> we just need those methods with additional parameters.

regards,
gerhard



2012/10/5 Ken Finnigan <ke...@kenfinnigan.me>

> Some additional plans for messages that may be relevant to JSF have been
> documented in [1].
>
> In Seam 3 International we had some ideas around targeting a message at a
> specific component which are noted here [2].
>
> Ken
>
> [1]
>
> https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
> [2]
>
> https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378
>
> On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <
> gerhard.petracek@gmail.com
> > wrote:
>
> > hi jason,
> >
> > that's for sure just a first idea.
> > e.g. we also need the possibility to add messages for a specific
> component.
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/10/5 Jason Porter <li...@gmail.com>
> >
> > > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <st...@yahoo.de>
> > 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
> > >
> >
>

Re: proposal for JSF Messages

Posted by Ken Finnigan <ke...@kenfinnigan.me>.
Some additional plans for messages that may be relevant to JSF have been
documented in [1].

In Seam 3 International we had some ideas around targeting a message at a
specific component which are noted here [2].

Ken

[1]
https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts
[2]
https://issues.jboss.org/browse/SEAMINTL-7?focusedCommentId=12562378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12562378

On Fri, Oct 5, 2012 at 3:18 PM, Gerhard Petracek <gerhard.petracek@gmail.com
> wrote:

> hi jason,
>
> that's for sure just a first idea.
> e.g. we also need the possibility to add messages for a specific component.
>
> regards,
> gerhard
>
>
>
> 2012/10/5 Jason Porter <li...@gmail.com>
>
> > On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <st...@yahoo.de>
> 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
> >
>

Re: proposal for JSF Messages

Posted by Gerhard Petracek <ge...@gmail.com>.
hi jason,

that's for sure just a first idea.
e.g. we also need the possibility to add messages for a specific component.

regards,
gerhard



2012/10/5 Jason Porter <li...@gmail.com>

> On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <st...@yahoo.de> 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
>

Re: proposal for JSF Messages

Posted by Jason Porter <li...@gmail.com>.
On Fri, Oct 5, 2012 at 11:24 AM, Mark Struberg <st...@yahoo.de> 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