1 package com.opensymphony.webwork.components; 2 3 import com.opensymphony.util.TextUtils; 4 import com.opensymphony.webwork.config.Configuration; 5 import com.opensymphony.webwork.portlet.context.PortletContext; 6 import com.opensymphony.xwork.util.OgnlValueStack; 7 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 11 16 public class Href extends ClosingUIBean { 17 final public static String OPEN_TEMPLATE = "a"; 18 final public static String TEMPLATE = "a-close"; 19 final public static String COMPONENT_NAME = Href.class.getName(); 20 21 protected String href; 22 protected String errorText; 23 protected String showErrorTransportText; 24 protected String notifyTopics; 25 protected String afterLoading; 26 27 public Href(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) { 28 super(stack, request, response); 29 } 30 31 public String getDefaultOpenTemplate() { 32 return OPEN_TEMPLATE; 33 } 34 35 protected String getDefaultTemplate() { 36 return TEMPLATE; 37 } 38 39 protected void evaluateExtraParams() { 40 super.evaluateExtraParams(); 41 42 if (href != null) { 44 String hrefValue = findString(href); 45 String contextPath = request.getContextPath(); 46 StringBuffer sb = new StringBuffer (); 47 String actionUrl = PortletContext.getContext().getActionURL(); 48 49 if (!TextUtils.stringSet(actionUrl)) { 50 if (hrefValue.startsWith("/") && hrefValue.startsWith(contextPath)) { 51 contextPath = ""; 52 } 53 sb.append(contextPath).append(hrefValue); 54 } else { 55 String actionExtension = (String ) Configuration.get("webwork.action.extension"); 56 57 if (actionExtension == null || "".equals(actionExtension)) { 58 actionExtension = ".action"; 59 } else { 60 actionExtension = "." + actionExtension; 61 } 62 63 boolean isWebWorkAction = hrefValue.indexOf(actionExtension) >= 0; 64 65 if (isWebWorkAction) { 66 sb.append(actionUrl).append("?wwXAction=.").append(hrefValue); 67 } else { 68 sb.append(actionUrl).append("?wwLink=").append(hrefValue); 69 } 70 } 71 72 addParameter("href", sb.toString()); 73 } 74 75 if (showErrorTransportText != null) { 76 addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean .class)); 77 } 78 79 if (errorText != null) { 80 addParameter("errorText", findString(errorText)); 81 } 82 83 if (notifyTopics != null) { 84 addParameter("notifyTopics", findString(notifyTopics)); 85 } 86 87 if (afterLoading != null) { 88 addParameter("afterLoading", findString(afterLoading)); 89 } 90 } 91 92 public void setHref(String href) { 93 this.href = href; 94 } 95 96 public void setErrorText(String errorText) { 97 this.errorText = errorText; 98 } 99 100 public void setShowErrorTransportText(String showErrorTransportText) { 101 this.showErrorTransportText = showErrorTransportText; 102 } 103 104 public void setNotifyTopics(String notifyTopics) { 105 this.notifyTopics = notifyTopics; 106 } 107 108 public void setAfterLoading(String afterLoading) { 109 this.afterLoading = afterLoading; 110 } 111 } 112 | Popular Tags |