1 avoid load resource when get not expired content 2 multi resource in one request
47484950515253
entityQuery.limit(getPageLimit()).orderBy(get("orderBy")); return entityQuery; } protected PropertyExtractor getPropertyExtractor() { return new GroupPropertyExtractor(new ActionTextResource(this)); }
104105106107108109110
userQuery.orderBy(get(Order.ORDER_STR)).limit(getPageLimit()); return userQuery; } protected PropertyExtractor getPropertyExtractor() { return new UserPropertyExtractor(new ActionTextResource(this)); }
192021222324252627
private static final long serialVersionUID = 8451445989084058881L; @Override public String intercept(ActionInvocation invocation) throws Exception { String result = invocation.invoke(); Flash flash = (Flash) invocation.getInvocationContext().getSession().get("flash"); if (null != flash) flash.nextToNow(); return result; }
115116117118119120121122123124125126
protected void addFlashErrorNow(String msgKey, Object... args) { getFlash().addErrorNow(getTextInternal(msgKey, args)); } protected Flash getFlash() { Flash flash = (Flash) ActionContext.getContext().getSession().get("flash"); if (null == flash) { flash = new Flash(); ActionContext.getContext().getSession().put("flash", flash); } return flash; }
128129130131132133134135136137138139140
/** * 将flash中的消息转移到actionmessage<br> * 不要将flash和message混合使用。 */ public Collection<String> getActionMessages() { Flash flash = getFlash(); @SuppressWarnings("unchecked") List<String> messages = (List<String>) flash.get(Flash.MESSAGES); if (null != messages) { for (String msg : messages) { addActionMessage(msg); } messages.clear();
145146147148149150151152153154155156157
/** * 将flash中的错误转移到actionerror<br> * 不要将flash和error混合使用。 */ public Collection<String> getActionErrors() { Flash flash = getFlash(); @SuppressWarnings("unchecked") List<String> errors = (List<String>) flash.get(Flash.ERRORS); if (null != errors) { for (String msg : errors) { addActionError(msg); } errors.clear();
858687888990919293949596
protected void addFlashMessage(String msgKey) { getFlash().addMessage(getText(msgKey)); } protected Flash getFlash() { Flash flash = (Flash) ActionContext.getContext().getSession().get("flash"); if (null == flash) { flash = new Flash(); ActionContext.getContext().getSession().put("flash", flash); } return flash; }
9899100101102103104105106107108109110
115116117118119120121122123124125126127
1718192021222324252627
public class FlashInterceptor extends AbstractInterceptor { @Override public String intercept(ActionInvocation invocation) throws Exception { String result = invocation.invoke(); Flash flash = (Flash) invocation.getInvocationContext().getSession().get("flash"); if (null != flash) { flash.nextToNow(); } return result; }