-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support new messages grouped by severity #736
Conversation
public List<Message> getErrors() { | ||
return get(Severity.ERROR); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if pluralization of info
and warn
are right, so I wrote in singular. Suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, info
can be used in singular and plural...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pluralize all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use errorList, warnList, infoList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave info
because as @renanigt said, already in plural. But warn
can be renamed to warnings
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer warnings
too.
Cool ! 👍 |
This is a good feature! On Thu, Aug 7, 2014 at 10:41 PM, Renan Montenegro notifications@github.com
Rafael Ponte |
@RequestScoped | ||
public class Messages { | ||
|
||
private Map<Severity, List<Message>> messages = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use a guava Multimap here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer using core Java libraries. But you right, because it's too uggly signature Map<X, List<Y>>
. I'll change it soon. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not able to use ListMultimap
because this class creates an ArrayList
, but we need to create a MessageList(ArrayList)
as you can see here: https://github.com/caelum/vraptor4/pull/736/files#diff-3c30e5f5d8b7bd61d2561087bc62a05fR41
Suggestions?
A method to get all messages can be useful? public List<Message> getAll() {
List<Message> all = new ArrayList<>();
all.addAll(getErrors());
all.addAll(getInfo());
all.addAll(getWarnings());
return all;
} |
I think can be useful, may be someone wants to get all errors without by Severity. |
Since now we have So, with this we can treat each messages differently... |
Or we can also create something like:
|
Or something like |
@garcia-jj this feature should come in RC2?
totally note: this is a really nice PR! Thanks for remember about it :) |
I'm not sure. By this feature can wait if necessary. |
If I'm not wrong, this pull request blocks #725 |
@garcia-jj, in conversation with @lucascs, he asked to wait your merge, because we need this PR to fix the bug. So, you can merge it for we can fix #725. |
The comment is here. |
Regarding method |
the order: |
Hoje about using the same order of Log4j? Errors, warnings and info? On Monday, August 11, 2014, Rodrigo Turini notifications@github.com wrote:
Rafael Ponte |
I agree with @rponte. 👍 |
for me, the bullet point is |
Method added with 398c620 |
The |
I think isn't too important, but a plus. |
@Turini we merge this pull request before new release, or wait for more comments and ideas? |
lets wait for more comments :) before the release we can merge |
Initial support new messages grouped by severity
thanks! As discussed on mail list, it will be available at RC2 version :) |
*/ | ||
@Named | ||
@RequestScoped | ||
public class Messages { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guys, "messages" is a really generic name, it is causing some problems
at our internal projects (there is a lot of "messages" vars included to JSP)
What about change it to "VRaptorMessages" or something? It'll help a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense. :+1
On Friday, August 15, 2014, Rodrigo Turini notifications@github.com wrote:
In
vraptor-core/src/main/java/br/com/caelum/vraptor/validator/Messages.java:+/**
- * Managed class that stores all application messages like errors, warnings and info. This
- * class is useful to display messages categorized by severity in your view. To choose a severity
- * you can construct your message like this:
- *
- * Message message = new SimpleMessage("name", "An info message", Severity.INFO);
- * validation.add(message); // will stored as INFO severity
*
- * @SInCE 4.1
- * @author Otávio S Garcia
- */
+@nAmed
+@RequestScoped
+public class Messages {guys, "messages" is a really generic name, it is causing some problems
at our internal projects (there is a lot of "messages" vars included to
JSP)
What about change it to "VRaptorMessages" or something? It'll help a lot—
Reply to this email directly or view it on GitHub
https://github.com/caelum/vraptor4/pull/736/files#r16295214.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It also kind of breaks compatibility (other apps could have a named component with the same name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors
is generic too, and we use since 3.0 version. I vote to leave as messages
. Or if more people vote to rename, instead of messages
we can export warnings
and info
, or a better name than vraptorMessages
, that is too ugly and we need to use upper/lower case, because is too boring to type in JSP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should also rename warnings and info, too.
In https://github.com/caelum/mamute, for example, we had were including an attribute named "messages" in our views and we broke our app when updated vraptor :-(
I think that this will happen for other users, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to solve this question before the next release... more people think we should
keep as it is? (only messages
). If not, which better name instead of vraptorMessages
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer VRaptorMessages
, but I was out theses days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@renanigt we won't rename the class, but only export to view with another name to avoid conflicts.
@Turini I really dislike using upper/lower in EL. And using framework name in variable is too uggly (my point, of course). May we can use vmessages
that sounds something like validation messages
and vraptor messages
. Or we can improve this case with idea from JSF, that allow devs to configure the name of variable exported. What you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vmessages
looks good to me :) anyone disagree with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see the point @garcia-jj. 😃
I agree with @Turini, vmessages
looks nice. 👍
vmessages nice 👍 |
nice, thank for the opinions guys! |
* @since 4.1 | ||
* @author Otávio S Garcia | ||
*/ | ||
@Named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be changed to @Named("vmessages")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was made in another PR: #749
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops
awesome!!!!! 👍 👍 👍 |
As discussed in dev mailing list many months ago.
At this time we have only errors. These errors is a
List
ofMessage
s. But some applications needs to messages like warning and info. We have aSeverity
enum with properties likeINFO
andWARN
, but this messages is not used by VRaptor.With this pull request we can simple add a
Message
intoMessages
managed bean. So in the view we can use someting like this:Categorized messages are available too:
${messages.warn.from('client.name')}
, and more.This change has backward compatibility because
messages.errors
is exported to view with aliaserrors
, that is the same object.This is an initial suggestion, and we can improve it. After, javadocs and site docs will write.
Thank you.