use of org.webpieces.router.api.controller.actions.Render in project webpieces by deanhiller.
the class CrudTestController method multiSelect.
public Render multiSelect(Integer id) {
if (id == null) {
return Actions.renderThis("entity", new UserTestDbo(), "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", new ArrayList<>());
}
UserTestDbo user = UserTestDbo.findWithJoin(Em.get(), id);
List<UserRoleDbo> roles = user.getRoles();
List<Role> selectedRoles = roles.stream().map(r -> r.getRole()).collect(Collectors.toList());
return Actions.renderThis("entity", user, "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", selectedRoles, "password", null);
}
use of org.webpieces.router.api.controller.actions.Render in project webpieces by deanhiller.
the class ControllerLoader method preconditionCheckForErrorRoute.
private void preconditionCheckForErrorRoute(LoadedController loadedController) {
Method controllerMethod = loadedController.getControllerMethod();
Class<?> clazz = controllerMethod.getReturnType();
if (CompletableFuture.class.isAssignableFrom(clazz)) {
Type genericReturnType = controllerMethod.getGenericReturnType();
ParameterizedType t = (ParameterizedType) genericReturnType;
Type type2 = t.getActualTypeArguments()[0];
if (!(type2 instanceof Class))
throw new IllegalArgumentException("This error route has a method that MUST return a type 'Render' or 'XFuture<Render>' " + "for this method(and did not)=" + controllerMethod);
@SuppressWarnings("rawtypes") Class<?> type = (Class) type2;
if (!Render.class.isAssignableFrom(type))
throw new IllegalArgumentException("This error route has a method that MUST return a type 'Render' or 'XFuture<Render>' not 'XFuture<" + type.getSimpleName() + ">'for this method=" + controllerMethod);
} else if (!Render.class.isAssignableFrom(clazz))
throw new IllegalArgumentException("This error route has a method that MUST return a type 'Render' or 'XFuture<Render>' not '" + clazz.getSimpleName() + "' for this method=" + controllerMethod);
}
Aggregations