Regarding the discussion of the design for StatusMessages...
On Tue, May 5, 2009 at 7:59 AM, Clint Popetz
<cpopetz@gmail.com> wrote:
I want to
point out that using a deployment type and @Specializes would seem to
place us in the same situation as Seam 2.x with respect to the view
layers co-existing in the same deployment, which
https://jira.jboss.org/jira/browse/JBSEAM-3645 was meant to address.
In other words, I'd rather that the choice of the StatusMessages bean
that will be activated isn't based on deployment type, but rather is
chosen at runtime based on the type of request, using the pattern in
the patch for the above jira issue. Deployment types would of course
still be used to choose which implementations of things like
StatusMessages are available.
I have taken a first stab at solving this problem. I'm open to other approaches, but first let me explain what I've done. As Clint points out, from one request to the next, you may be dealing with different frameworks (Wicket vs JSF for instance). But within the request, you want to be able to take specific actions relating to the current framework. Clearly, this is not the appropriate scenario for a deployment type since that is design for a setting/environment that is fixed. So I did some brainstorming.
What I realized is that StatusMessages are really a generic repository that should be updated and consumed by the framework-specific activity. Therefore, it seems to me like there should be one and only one conversation-scoped StatusMessages. Then, if you want to have some extra methods for convenience (for instance in JSF to add a StatusMessage from an existing FacesMessage) you create a class which extends and wraps the StatusMessages component (StatusMessages would be injected into it and all overrides delegating to it). You could also override the onBeforeRender() method where you might put the logic for converting and transfering to the native message type and storage. The executor of that conversion would be implemented in the framework-specific listener.
For instance, 9 out of 10 times you simply inject the StatusMessages to use in your application:
@Current StatusMessages statusMessages;
For JSF, there is a FacesMessages bean which inherits from StatusMessages (to keep the API the same) and delegates calls to the StatusMessages instance. It also adds the logic to create FacesMessage objects in the onBeforeRender() method
public void onBeforeRender() {
super.onBeforeRender();
// create FacesMessage objects and register them here
}