1 19 20 package org.netbeans.modules.web.core; 21 22 import java.io.IOException ; 23 import java.util.List ; 24 import org.netbeans.modules.web.api.webmodule.WebFrameworkSupport; 25 import org.netbeans.modules.web.api.webmodule.WebModule; 26 import org.netbeans.modules.web.core.jsploader.JspCompileUtil; 27 import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider; 28 29 import org.openide.filesystems.*; 30 import org.netbeans.modules.web.spi.webmodule.RequestParametersProvider; 31 32 36 public class WebExecSupport implements RequestParametersProvider { 37 38 public static final String EA_REQPARAMS = "NetBeansAttrReqParams"; 40 44 public static void setQueryString(FileObject fo, String qStr) throws IOException { 45 fo.setAttribute (EA_REQPARAMS, qStr); 46 } 47 48 51 public static String getQueryString(FileObject fo) { 52 try { 53 String qStr = (String )fo.getAttribute (EA_REQPARAMS); 54 if (qStr != null) { 55 if ((qStr.length() > 0) && (!qStr.startsWith("?"))) qStr = "?" + qStr; return qStr; 58 } 59 } catch (Exception ex) { 60 } 62 return ""; } 64 65 public String getFileAndParameters(FileObject f) { 66 67 List <WebFrameworkProvider> frameworkProviders = WebFrameworkSupport.getFrameworkProviders(); 68 String url = null; 69 WebModule wm = WebModule.getWebModule(f); 70 if (wm != null && frameworkProviders.size() > 0){ 71 for ( WebFrameworkProvider frameworkProvider : frameworkProviders) { 72 if (frameworkProvider.isInWebModule(wm)){ 73 url = frameworkProvider.getServletPath(f); 74 if (url != null) 75 break; 76 } 77 } 78 } 79 if (url == null) 80 url = JspCompileUtil.findRelativeContextPath(WebModule.getWebModule (f).getDocumentBase (), f); 81 url = url + getQueryString(f); 82 url = org.openide.util.Utilities.replaceString(url, " ", "%20"); 83 return url; 84 } 85 } 86 87 | Popular Tags |