List of usage examples for javax.servlet.jsp PageContext getRequest
abstract public ServletRequest getRequest();
From source file:org.displaytag.tags.DataGridCustomiztionUtil.java
public static CustomTableData readCustomizations(PageContext pageContext, TableTag tableTag) { String tableTagId = tableTag.getUid(); customGridQueryService = pageContext.getRequest().getAttribute("customGridQueryService"); if (customGridQueryService != null && (customFieldGetterMethod == null || linkedTableGetterMethod == null)) findGetterMethods(customGridQueryService.getClass()); if (pageContext != null) { JsonObject customizations = (JsonObject) pageContext.getRequest() .getAttribute(custom_config_attribute_key); if (customizations != null) { for (Map.Entry<String, JsonElement> entry : customizations.entrySet()) { // key is tableIdAttribute-customGridRecnum, set in CustomGridQueryServiceImpl->findCustomGridConfigurations String[] ids = entry.getKey().split("-"); if (ids.length == 2 && ids[0] != null && ids[1] != null && StringUtils.equals(tableTagId, ids[0]) && NumberUtils.toLong(ids[1]) != -1) { if (entry.getValue() != null) { return new CustomTableData(NumberUtils.toLong(ids[1]), entry.getValue().getAsJsonObject()); }//from w w w . ja v a2s. com } } } } return null; }
From source file:org.eclipse.sw360.portal.tags.TagUtils.java
public static void addDownloadLink(PageContext pageContext, JspWriter jspWriter, String name, Collection<String> ids, String contextType, String contextId) throws IOException, JspException { name = name != null ? escapeAttributeValue(name) : NO_FILENAME; jspWriter.write("<a href='"); UrlWriter urlWriter = resourceUrl(pageContext) .withParam(PortalConstants.ACTION, PortalConstants.ATTACHMENT_DOWNLOAD) .withParam(PortalConstants.CONTEXT_TYPE, contextType) .withParam(PortalConstants.CONTEXT_ID, contextId); for (String id : ids) { urlWriter.withParam(PortalConstants.ATTACHMENT_ID, id); }// ww w . j a va 2 s. c o m urlWriter.writeUrlToJspWriter(); jspWriter .write(format("'><img src='%s/images/download_enabled.jpg' alt='Download %s' title='Download %s'/>", ((HttpServletRequest) pageContext.getRequest()).getContextPath(), name, name)); jspWriter.write("</a>"); }
From source file:org.esco.portlets.news.web.support.CheckboxTableDecorator.java
/** * @param pageContext /*from w w w .ja v a 2 s.c om*/ * @param decorated * @param tableModel */ @Override public void init(final PageContext pageContext, final Object decorated, @SuppressWarnings("hiding") final TableModel tableModel) { super.init(pageContext, decorated, tableModel); String[] params = pageContext.getRequest().getParameterValues(fieldName); List<String> checked = null; if (params != null) { checked = new ArrayList<String>(Arrays.asList(params)); } else { params = ((SubForm) pageContext.getRequest().getAttribute("subForm")).getSubKey(); if (params != null) { checked = new ArrayList<String>(Arrays.asList(params)); SubForm form = (SubForm) pageContext.getRequest().getAttribute("subForm"); pageContext.getRequest().removeAttribute("subForm"); form.setSubKey(null); pageContext.getRequest().setAttribute("subForm", form); } } if (checked != null) { checkedIds = checked; } else { checkedIds = new ArrayList<String>(0); } }
From source file:org.hifivault.geo.location.taglib.BaseGeoTargetTag.java
@Override public void doTag() throws JspException, IOException { PageContext ctx = (PageContext) getJspContext(); HttpServletRequest req = (HttpServletRequest) ctx.getRequest(); HttpSession session = ctx.getSession(); String mappedCode = defaultId(); GeoInfo geo = (GeoInfo) session.getAttribute(GeoLocationManager.getGeoInfoAttribute()); if (geo != null) { String source = geo.getCountryCode(); String code = geo.getTargetCode(); mappedCode = mapId(code);/*from ww w .j a v a 2 s .c o m*/ if (log.isDebugEnabled()) { log.debug("====>GeoLocate: '" + source + "/" + code + "' to '" + mappedCode + "'"); } } // handle result if (var != null) { // put in variable if (mappedCode.length() > 0) { req.setAttribute(var, mappedCode); } else { req.removeAttribute(var); } } else { // write ctx.getOut().print(mappedCode); } }
From source file:org.jahia.taglibs.template.include.OptionTag.java
public static void renderNodeWithViewAndTypes(JCRNodeWrapper node, String view, String commaConcatenatedNodeTypes, PageContext pageContext, Map<String, String> parameters) throws RepositoryException, IOException, RenderException { String charset = pageContext.getResponse().getCharacterEncoding(); // Todo test if module is active RenderContext renderContext = (RenderContext) pageContext.getAttribute("renderContext", PageContext.REQUEST_SCOPE);// w w w .ja va 2 s.c o m Resource currentResource = (Resource) pageContext.getAttribute("currentResource", PageContext.REQUEST_SCOPE); String[] nodeTypes = StringUtils.split(commaConcatenatedNodeTypes, ","); if (nodeTypes.length > 0) { final String primaryNodeType = nodeTypes[0]; if (node.isNodeType(primaryNodeType)) { ExtendedNodeType mixinNodeType = NodeTypeRegistry.getInstance().getNodeType(primaryNodeType); // create a resource to render the current node with the specified view Resource wrappedResource = new Resource(node, currentResource.getTemplateType(), view, Resource.CONFIGURATION_INCLUDE); wrappedResource.setResourceNodeType(mixinNodeType); // set parameters for (Map.Entry<String, String> param : parameters.entrySet()) { wrappedResource.getModuleParams().put(URLDecoder.decode(param.getKey(), charset), URLDecoder.decode(param.getValue(), charset)); } // attempt to resolve script for the newly created resource Script script = null; try { script = RenderService.getInstance().resolveScript(wrappedResource, renderContext); } catch (RepositoryException e) { logger.error(e.getMessage(), e); } catch (TemplateNotFoundException e) { // if we didn't find a script, attempt to locate one based on secondary node type if one was specified if (nodeTypes.length > 1) { mixinNodeType = NodeTypeRegistry.getInstance().getNodeType(nodeTypes[1]); wrappedResource.setResourceNodeType(mixinNodeType); script = RenderService.getInstance().resolveScript(wrappedResource, renderContext); } } // if we have found a script, render it if (script != null) { final ServletRequest request = pageContext.getRequest(); //save environment Object currentNode = request.getAttribute("currentNode"); Resource currentOption = (Resource) request.getAttribute("optionResource"); // set attributes to render the newly created resource request.setAttribute("optionResource", currentResource); request.setAttribute("currentNode", node); request.setAttribute("currentResource", wrappedResource); try { pageContext.getOut().write(script.execute(wrappedResource, renderContext)); } finally { // restore environment as it previously was request.setAttribute("optionResource", currentOption); request.setAttribute("currentNode", currentNode); request.setAttribute("currentResource", currentResource); } } } } }
From source file:org.jboss.dashboard.ui.components.FactoryUniqueIdEncoderImpl.java
public String encodeFromContext(PageContext pageContext, String name) { Panel panel = (Panel) pageContext.getRequest().getAttribute(Parameters.RENDER_PANEL); UIComponentHandlerFactoryElement factoryComponent = (UIComponentHandlerFactoryElement) pageContext .getRequest().getAttribute(UseComponentTag.COMPONENT_ATTR_NAME); return encode(panel, factoryComponent, name); }
From source file:org.jboss.dashboard.ui.formatters.FactoryUniqueIdEncoder.java
public String encodeFromContext(PageContext pageContext, String name) { Panel panel = RequestContext.lookup().getActivePanel(); UIBeanHandler uiBean = UIBeanLocator.lookup().getCurrentBean(pageContext.getRequest()); return encode(panel, uiBean, name); }
From source file:org.kuali.kfs.kns.util.WebUtils.java
public static ActionForm getKualiForm(PageContext pageContext) { return getKualiForm((HttpServletRequest) pageContext.getRequest()); }
From source file:org.kuali.kfs.sys.document.service.impl.AccountingLineRenderingServiceImpl.java
/** * @see org.kuali.kfs.sys.document.service.AccountingLineRenderingService#findForm(javax.servlet.jsp.PageContext) *//*from w ww .j a v a 2s . c o m*/ public KualiAccountingDocumentFormBase findForm(PageContext pageContext) { if (pageContext.getRequest().getAttribute(KUALI_FORM_NAME) != null) return (KualiAccountingDocumentFormBase) pageContext.getRequest().getAttribute(KUALI_FORM_NAME); if (pageContext.getSession().getAttribute(KUALI_FORM_NAME) != null) return (KualiAccountingDocumentFormBase) pageContext.getSession().getAttribute(KUALI_FORM_NAME); return (KualiAccountingDocumentFormBase) KNSGlobalVariables.getKualiForm(); }
From source file:org.kuali.kfs.sys.document.web.renderers.FieldRendererBase.java
@Override public void renderExplodableLink(PageContext context) throws JspException { String textAreaLabel = "Description"; String docFormKey = "88888888"; String readonly = "false"; String maxLength = Integer.toString(field.getMaxLength()); String actionName = ((String) context.getRequest() .getAttribute("org.apache.struts.globals.ORIGINAL_URI_KEY")); /* Here we get the action url without decoration turning * /arCustomerInvoiceDocument.do into arCustomerInvoiceDocument *///from w w w . j a v a 2 s . co m actionName = actionName.substring(1, actionName.length() - 3); String title = "Description"; String imageUrl = String.format("%s%s", getRiceImageBase(), "pencil_add.png"); try { context.getOut().write(String.format( "<input type=\"image\" name=\"methodToCall.updateTextArea.((`%s`))\" src=\"%s\" " + "onclick=\"javascript: textAreaPop('%s', '%s', '%s', '%s', '%s', '%s'); return false\" class=\"tinybutton\" title=\"%s\" alt=\"Expand Text Area\">", getFieldName(), imageUrl, getFieldName(), actionName, textAreaLabel, docFormKey, readonly, maxLength, title)); } catch (IOException ex) { throw new JspException("Could not render Explodable Link", ex); } }