Dave Newton wrote:
--- [EMAIL PROTECTED] wrote:
public class MyAction {
  public String deleteUser() {
    // Here I can inject errors for display on the JSP by writing:
FacesContext.getCurrentInstance().addMessage("userNameField", "Sorry, that username is unknown");
    return "input";
  }
}

Notice MyAction inherits no JSF-specific interfaces and extends no JSF-specific classes, which is I find very desirable.

Well... Obviously code-coupling is bad. You're still coupled to the
FacesContext, though, and in some ways I like being coupled to static methods
even less because it's not injectable.


Agreed. Using a static method call is NOT a form of decoupling from the framework. In fact, it's less desirable than an interface because its harder to test and override.

Just wondering if struts2 has a way to decouple actions in this manner.

Either:
Implementing ValidationAware and delegating to the ValidationAwareSupport mixin is best;
or if you really desire an equivalent static call:
- add a ValidationAware instance to the ActionContext via a custom Interceptor; and - ((ValidationAware) ActionContext.getActionContext().get("myValidation")).addActionError("");
may work.
ie. the context contains a ValidationAware object rather than your action being the ValidationAware object.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to