本文整理汇总了Java中br.com.caelum.vraptor.Result.include方法的典型用法代码示例。如果您正苦于以下问题:Java Result.include方法的具体用法?Java Result.include怎么用?Java Result.include使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类br.com.caelum.vraptor.Result
的用法示例。
在下文中一共展示了Result.include方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterForumListing
import br.com.caelum.vraptor.Result; //导入方法依赖的package包/类
/**
* Filter the property bag for forums/show, based on group interaction
* settings
*
* @param propertyBag the property bag for the "show" method of the {@link ForumController} action
* @param userSession the user session of the current logged user
*/
public void filterForumListing(Result result, UserSession userSession) {
@SuppressWarnings("unchecked")
Collection<UserSession> sessions = (Collection<UserSession>) result.included().get("onlineUsers");
if (sessions == null) {
sessions = new ArrayList<UserSession>();
}
Set<UserSession> newSessions = new HashSet<UserSession>();
User currentUser = userSession.getUser();
for (Group group : currentUser.getGroups()) {
for (UserSession anotherUserSession : sessions) {
User user = anotherUserSession.getUser();
if (user != null && user.getGroups().contains(group)) {
newSessions.add(anotherUserSession);
}
}
}
result.include("totalLoggedUsers", newSessions.size());
result.include("onlineUsers", newSessions);
}
示例2: verify
import br.com.caelum.vraptor.Result; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Post("/asjkdjnjsaknfknsdklglas")
public void verify(Result r){
List<User> users = session.createCriteria(User.class).list();
List<User> invalid = new ArrayList<>();
for (User user : users) {
if (!isValid(user)) {
invalid.add(user);
}
}
r.include("invalid", invalid);
}
示例3: outject
import br.com.caelum.vraptor.Result; //导入方法依赖的package包/类
public void outject(@Observes MethodExecuted event, Result result, MethodInfo methodInfo) {
Type returnType = event.getMethodReturnType();
if (!returnType.equals(Void.TYPE)) {
String name = extractor.nameFor(returnType);
Object value = methodInfo.getResult();
logger.debug("outjecting {}={}", name, value);
result.include(name, value);
}
}