List of usage examples for javax.servlet.jsp PageContext getRequest
abstract public ServletRequest getRequest();
From source file:de.micromata.genome.gwiki.web.tags.GWikiTagRenderUtils.java
public static Object readFormValue(PageContext pageContext, String name) { Object bean = pageContext.getRequest().getAttribute(FORM_ATTR_NAME); if (bean == null) { throw new RuntimeException("No form under '" + FORM_ATTR_NAME + "' defined in request attribute"); }/*from ww w. j a v a 2 s .com*/ try { Object o = PropertyUtils.getProperty(bean, name); return o; } catch (Exception ex) { throw new RuntimeException( "Cannot read property '" + FORM_ATTR_NAME + "'." + name + ": " + ex.getMessage(), ex); } }
From source file:cn.guoyukun.spring.web.form.bind.SearchBindStatus.java
public static BindStatus create(PageContext pageContext, String name, RequestContext requestContext, boolean htmlEscape) { pageContext.getRequest().setAttribute(pathToUse, SearchModel.EMPTY); SearchBindStatus bindStatus = new SearchBindStatus(requestContext, pathToUse, htmlEscape); bindStatus.value = getValue(pageContext, name); bindStatus.htmlEscape = htmlEscape;/* w w w . jav a 2s .c o m*/ return bindStatus; }
From source file:com.jsqlboxdemo.dispatcher.Dispatcher.java
public static void dispach(PageContext pageContext) throws Exception { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String uri = StringUtils.substringBefore(request.getRequestURI(), "."); String contextPath = request.getContextPath(); if (!StringUtils.isEmpty(contextPath)) uri = StringUtils.substringAfter(uri, contextPath); if (StringUtils.isEmpty(uri) || "/".equals(uri)) uri = "/home"; String[] paths = StringUtils.split(uri, "/"); String[] pathParams;/*from www. j a va 2s . c om*/ String resource = null; String operation = null; if (paths.length >= 2) {// /team/add/100... resource = paths[0]; operation = paths[1]; pathParams = new String[paths.length - 2]; for (int i = 2; i < paths.length; i++) pathParams[i - 2] = paths[i]; } else { // /home_default resource = paths[0]; pathParams = new String[0]; } if (operation == null) operation = "default"; StringBuilder controller = new StringBuilder("com.jsqlboxdemo.controller.").append(resource).append("$") .append(resource).append("_").append(operation); if ("POST".equals(request.getMethod())) controller.append("_post"); WebBox box; try { Class boxClass = Class.forName(controller.toString()); box = BeanBox.getPrototypeBean(boxClass); } catch (Exception e) { throw new ClassNotFoundException("There is no WebBox classs '" + controller + "' found."); } request.setAttribute("pathParams", pathParams); box.show(pageContext); }
From source file:com.cognifide.slice.api.tag.SliceTagUtils.java
private static SlingScriptHelper getSlingScriptHelper(final PageContext pageContext) { ServletRequest request = pageContext.getRequest(); SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName()); return bindings.getSling(); }
From source file:com.cognifide.slice.api.tag.SliceTagUtils.java
public static SlingHttpServletRequest slingRequestFrom(final PageContext pageContext) { return (SlingHttpServletRequest) pageContext.getRequest(); }
From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiMessageTag.java
@SuppressWarnings("unchecked") public static void addI18NDomMap(PageContext pageContext, String messageKey, String domId) { Map<String, String> m = (Map<String, String>) pageContext.getRequest().getAttribute(GWIKI_MESSAGE_KEYM); if (m == null) { m = new HashMap<String, String>(); pageContext.getRequest().setAttribute(GWIKI_MESSAGE_KEYM, m); }/* w w w . ja v a 2s .com*/ m.put(messageKey, domId); }
From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java
/** * INTERNAL: Gets the context tag from the request scope. */// ww w. j a va2 s .c o m public static ContextTag getContextTag(PageContext pageContext) { return getContextTag(pageContext.getRequest()); }
From source file:cn.guoyukun.spring.web.form.bind.SearchBindStatus.java
public static Object getValue(PageContext pageContext, String name) { if (StringUtils.isEmpty(name)) { return null; }//from w w w . j a v a2 s .c o m Object value = null; String[] parameters = pageContext.getRequest().getParameterValues(name); if (parameters != null && parameters.length == 1) { value = parameters[0]; } else { value = parameters; } //??? // if(value == null || (value instanceof String && StringUtils.isEmpty((String) value))) { // Object attributeValue = pageContext.findAttribute(name); // if(attributeValue != null) { // value = attributeValue; // } // } return value; }
From source file:de.innovationgate.wgpublisher.bi.BiBase.java
public static String getBrowserLanguageKey(javax.servlet.jsp.PageContext pageContext) { Enumeration enumLocales = pageContext.getRequest().getLocales(); Vector vecLocales = new Vector(); vecLocales.clear();//from ww w . j a va 2 s .c o m String language = null; while (enumLocales.hasMoreElements()) vecLocales.add((Locale) enumLocales.nextElement()); for (int i = 0; i < vecLocales.size(); i++) { Locale currentLocale = (Locale) vecLocales.get(i); language = currentLocale.getLanguage().toUpperCase(); if (language.equalsIgnoreCase("DE") || language.equalsIgnoreCase("EN")) break; } if (language == null || language.equals("")) language = "EN"; return language; }
From source file:ar.com.zauber.commons.web.uri.UriJspFunctions.java
/** Construye un uri */ public static String buildVarArgs(final PageContext ctx, final String uriKey, final Object... params) { return buildVarArgs(ctx.getRequest(), uriKey, params); }