Monthly Archives: June 2012

Notification Pattern 理解

参考: http://martinfowler.com/eaaDev/Notification.html 在MVC的架构中,我们想从Model层传递一些错误信息到View层,比如用户注册这个功能,用户填写了密码,邮箱,然后提交注册,这时候我们后端需要对前端的数据做校验,同时将校验的结果返回给View层,这时候就能用到Notification模式. 先定义Notification: …… public class Notification { private List _errors; public Notification() { _errors = new ArrayList(); } public void clear() { _errors.clear(); } public boolean hasError() { if (this._errors != null && this.errors().size() > 0) { return true; … Continue reading

Posted in Program | Comments Off on Notification Pattern 理解