List of usage examples for javax.servlet.jsp PageContext getRequest
abstract public ServletRequest getRequest();
From source file:org.vulpe.view.tags.Functions.java
/** * * @param button/* ww w . j a v a 2 s. c o m*/ * @param controllerType * @return */ public static String buttonConfig(final PageContext pageContext, final String button, final String controllerType) { final VulpeHashMap<String, Object> now = (VulpeHashMap<String, Object>) pageContext.getRequest() .getAttribute(Request.NOW); final StringBuilder config = new StringBuilder(); if (now != null) { final VulpeHashMap<String, ButtonConfig> buttons = now.getAuto(Now.BUTTONS); if (button != null && buttons.containsKey(button)) { final ButtonConfig buttonInfo = buttons.get(button); if (buttonInfo.getDisabled() != null && buttonInfo.getDisabled()) { config.append("[disabled]"); } else { config.append("[enabled]"); } if (buttonInfo.getRender() != null && buttonInfo.getRender()) { config.append("[render]"); } else { config.append("[notRender]"); } if (buttonInfo.getShow() != null && buttonInfo.getShow()) { config.append("[show]"); } else { config.append("[hide]"); } } else { config.append("[notRender]"); } } return config.toString(); }
From source file:org.vulpe.view.tags.Functions.java
/** * * @param button/*from w w w . ja v a 2s. co m*/ * @param controllerType * @return */ public static Boolean isButtonRender(final PageContext pageContext, final String button, final String controllerType) { final VulpeHashMap<String, Object> now = (VulpeHashMap<String, Object>) pageContext.getRequest() .getAttribute(Request.NOW); boolean render = false; if (now != null) { final VulpeHashMap<String, ButtonConfig> buttons = now.getAuto(Now.BUTTONS); if (button != null && buttons.containsKey(button)) { final ButtonConfig buttonInfo = buttons.get(button); render = buttonInfo.getRender() != null && buttonInfo.getRender(); } } return render; }
From source file:org.vulpe.view.tags.Functions.java
/** * * @param button/*from w w w. j a v a2 s . c o m*/ * @param controllerType * @return */ public static Boolean isButtonShow(final PageContext pageContext, final String button, final String controllerType) { final VulpeHashMap<String, Object> now = (VulpeHashMap<String, Object>) pageContext.getRequest() .getAttribute(Request.NOW); boolean show = false; if (now != null) { final VulpeHashMap<String, ButtonConfig> buttons = now.getAuto(Now.BUTTONS); if (button != null && buttons.containsKey(button)) { final ButtonConfig buttonInfo = buttons.get(button); show = buttonInfo.getShow() != null && buttonInfo.getShow(); } } return show; }
From source file:org.vulpe.view.tags.Functions.java
/** * * @param button//from ww w. java 2 s . c o m * @param controllerType * @return */ public static Boolean isButtonDisabled(final PageContext pageContext, final String button, final String controllerType) { final VulpeHashMap<String, Object> now = (VulpeHashMap<String, Object>) pageContext.getRequest() .getAttribute(Request.NOW); boolean disabled = false; if (now != null) { final VulpeHashMap<String, ButtonConfig> buttons = now.getAuto(Now.BUTTONS); if (button != null && buttons.containsKey(button)) { final ButtonConfig buttonInfo = buttons.get(button); disabled = buttonInfo.getDisabled() != null && buttonInfo.getDisabled(); } } return disabled; }
From source file:org.vulpe.view.tags.Functions.java
/** * * @return// w w w . j a va 2s. com */ public static Boolean isAuthenticated(final PageContext pageContext) { final Object springSecurity = pageContext.getSession().getAttribute(Security.SPRING_SECURITY_CONTEXT); if (springSecurity == null) { return false; } final Object springSecurityAutentication = VulpeReflectUtil.getFieldValue(springSecurity, "authentication"); final Boolean authenticated = VulpeReflectUtil.getFieldValue(springSecurityAutentication, "authenticated"); if (authenticated != null && authenticated.booleanValue()) { return true; } return ((HttpServletRequest) pageContext.getRequest()).getUserPrincipal() != null; }
From source file:org.wso2.carbon.ui.taglibs.JSi18n.java
public static Locale getLocaleFromPageContext(PageContext pageContext) { if (pageContext.getSession().getAttribute(CarbonUIUtil.SESSION_PARAM_LOCALE) != null) { return CarbonUIUtil .toLocale(pageContext.getSession().getAttribute(CarbonUIUtil.SESSION_PARAM_LOCALE).toString()); } else {// w ww. j a v a2 s. c o m return pageContext.getRequest().getLocale(); } }
From source file:ru.runa.common.web.ActionExceptionHelper.java
public static String getErrorMessage(Throwable e, PageContext pageContext) { ActionMessage actionMessage = getActionMessage(e, pageContext.getRequest().getLocale()); return Commons.getMessage(actionMessage.getKey(), pageContext, actionMessage.getValues()); }
From source file:ru.runa.wf.web.FormPresentationUtils.java
public static String adjustForm(PageContext pageContext, Long definitionId, String formHtml, VariableProvider variableProvider, List<String> requiredVarNames) { try {/*from w w w . j av a2 s . c o m*/ Map<String, String> userErrors = FormSubmissionUtils.getUserInputErrors(pageContext.getRequest()); Document document = HTMLUtils.readHtml(formHtml.getBytes(Charsets.UTF_8)); adjustUrls(pageContext, document, definitionId, "form.ftl"); NodeList htmlTagElements = document.getElementsByTagName("input"); for (int i = 0; i < htmlTagElements.getLength(); i++) { Element node = (Element) htmlTagElements.item(i); String typeName = node.getAttribute(TYPE_ATTR); String inputName = node.getAttribute(NAME_ATTR); if (WebResources.isHighlightRequiredFields() && requiredVarNames.contains(inputName)) { Element requiredNode = node; if ("file".equalsIgnoreCase(typeName) && WebResources.isAjaxFileInputEnabled()) { requiredNode = (Element) node.getParentNode(); } addRequiredClassAttribute(requiredNode); } handleErrors(userErrors, inputName, pageContext, document, node); } NodeList textareaElements = document.getElementsByTagName("textarea"); for (int i = 0; i < textareaElements.getLength(); i++) { Element node = (Element) textareaElements.item(i); String inputName = node.getAttribute(NAME_ATTR); if (WebResources.isHighlightRequiredFields() && requiredVarNames.contains(inputName)) { addRequiredClassAttribute(node); } handleErrors(userErrors, inputName, pageContext, document, node); } NodeList selectElements = document.getElementsByTagName("select"); for (int i = 0; i < selectElements.getLength(); i++) { Element node = (Element) selectElements.item(i); String inputName = node.getAttribute(NAME_ATTR); if (WebResources.isHighlightRequiredFields() && requiredVarNames.contains(inputName)) { wrapSelectToErrorContainer(document, node, inputName, true); } handleErrors(userErrors, inputName, pageContext, document, node); } if (!userErrors.isEmpty()) { Set<String> messages = Sets.newHashSet(); for (String variableName : userErrors.keySet()) { messages.add(variableName + ": " + getErrorText(pageContext, userErrors, variableName)); } log.debug("Not for all errors inputs found, appending errors to the end of the form: " + messages); document.getLastChild().appendChild(document.createElement("hr")); Element font = document.createElement("font"); for (String message : messages) { font.appendChild(document.createElement("br")); font.setAttribute(CSS_CLASS_ATTR, "error"); Element b = document.createElement("b"); b.appendChild(document.createTextNode(message)); font.appendChild(b); } document.getLastChild().appendChild(font); } return HTMLUtils.writeHtml(document); } catch (Exception e) { throw Throwables.propagate(e); } }