1 24 package org.riotfamily.riot.list.command.core; 25 26 import org.riotfamily.common.beans.PropertyUtils; 27 import org.riotfamily.common.web.util.ServletUtils; 28 import org.riotfamily.riot.list.command.CommandContext; 29 30 34 public class LinkCommand extends PopupCommand { 35 36 public static final String STYLE_CLASS = "link"; 37 38 private String link; 39 40 private boolean contextRelative = true; 41 42 public void setLink(String link) { 43 this.link = link.replace('@', '$'); 44 } 45 46 public void setContextRelative(boolean contextRelative) { 47 this.contextRelative = contextRelative; 48 } 49 50 protected String getUrl(CommandContext context) { 51 String url = PropertyUtils.evaluate(link, context.getBean()); 52 if (contextRelative && !ServletUtils.isAbsoluteUrl(url)) { 53 url = context.getRequest().getContextPath() + url; 54 } 55 return url; 56 } 57 58 protected String getStyleClass(CommandContext context, String action) { 59 return STYLE_CLASS; 60 } 61 62 } 63 | Popular Tags |