本文整理汇总了Java中org.apache.tiles.AttributeContext.putAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeContext.putAttribute方法的具体用法?Java AttributeContext.putAttribute怎么用?Java AttributeContext.putAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tiles.AttributeContext
的用法示例。
在下文中一共展示了AttributeContext.putAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.tiles.AttributeContext; //导入方法依赖的package包/类
@Override
public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) {
List<Pair<String, String>> menuMap = new LinkedList<>();
Set<EntityType<?>> entityTypes = entityManager.getMetamodel().getEntities();
for (EntityType entityType : entityTypes) {
Class entityClass = entityType.getJavaType();
String entityClassName = entityClass.getSimpleName();
if (JpaEntity.class.isAssignableFrom(entityClass) && repositories.hasRepositoryFor(entityClass)) {
menuMap.add(new ImmutablePair<>(entityClassName, "/domain/" + entityClassName));
}
int i = 0;
}
attributeContext.putAttribute("menuMap", new ListAttribute(menuMap), true);
}
示例2: render
import org.apache.tiles.AttributeContext; //导入方法依赖的package包/类
/**
*
* @param actionUrl url should be start with "/"
* @param request HttpServletRequest
* @param response HttpServletResponse
* @throws Exception Exception
*/
public static void render(String actionUrl, HttpServletRequest request,
HttpServletResponse response) throws Exception {
TilesContainer container = TilesAccess.getContainer(
request.getSession().getServletContext());
if(log.isDebugEnabled()){
log.debug("Rendering tiles main.layout with page : "+actionUrl+"("+request.getSession().getId()+")");
}
AttributeContext attributeContext = container.startContext(request, response);
Attribute attr = new Attribute(actionUrl);
attributeContext.putAttribute("body", attr);
try {
container.render("main.layout", request, response);
container.endContext(request, response);
} catch (Exception e) {
if (log.isDebugEnabled()) { // Intentionally logged at debug level
log.debug("Error occurred while rendering." +
" We generally see this 'harmless' exception on WebLogic. Hiding it.", e);
}
}
}
示例3: execute
import org.apache.tiles.AttributeContext; //导入方法依赖的package包/类
@Override
public void execute(Request tilesContext, AttributeContext attributeContext) {
DiscordUserDetails details = SecurityUtils.getCurrentUser();
if (details != null) {
attributeContext.putAttribute("userDetails", new Attribute(details));
}
attributeContext.putAttribute("discordConnected", new Attribute(discordService.isConnected()));
}
示例4: execute
import org.apache.tiles.AttributeContext; //导入方法依赖的package包/类
@Override
public void execute(Request arg0, AttributeContext arg1) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (!(auth instanceof AnonymousAuthenticationToken)) {
final UserDetails userDetails = (UserDetails) auth.getPrincipal();
arg1.putAttribute("user", new Attribute("signed in as " + userDetails.getUsername()), true);
} else {
arg1.putAttribute("user", new Attribute("not signed in"), true);
}
}
示例5: execute
import org.apache.tiles.AttributeContext; //导入方法依赖的package包/类
@Override
public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) {
Map<String, Object> requestAttributes = tilesContext.getRequestScope();
String entityListTitle = (String) requestAttributes.get("entityListTitle");
List<JpaEntity> entities = (List<JpaEntity>) requestAttributes.get("entities");
Map<String, Attribute> aditionalAttributes = new HashMap<>();
String entityClassName = (String) requestAttributes.get("entityClassName");
String columnNames = (String) requestAttributes.get("columnNames");
if (entityListTitle == null && entities != null) {
Iterator iterator = entities.iterator();
if (entityClassName != null) {
entityListTitle = entityClassName;
} else if (iterator.hasNext()) {
JpaEntity entity = (JpaEntity) iterator.next();
entityListTitle = entity.getClassDescription();
} else {
entityListTitle = "Entity";
}
entityListTitle += " list";
// aditionalAttributes.put("entityListTitle", new Attribute(entityListTitle));
attributeContext.putAttribute("entityListTitle", new Attribute(entityListTitle), true);
}
if (columnNames == null || !(columnNames instanceof String) || columnNames.isEmpty()) {
attributeContext.putAttribute("columnNames", new Attribute(DEFAULT_COLUMN_NAMES), true);
}
// attributeContext.addMissing(aditionalAttributes);
// List<Pair<String, String>> menuMap = new LinkedList<>();
// Set<EntityType<?>> entityTypes = entityManager.getMetamodel().getEntities();
//
// for (EntityType entityType : entityTypes) {
// String entityClassName = entityType.getJavaType().getSimpleName();
// menuMap.add(new ImmutablePair<>(entityClassName, "/domain/" + entityClassName));
// }
//
//
// attributeContext.putAttribute("menuMap", new ListAttribute(menuMap), true);
}