List of usage examples for javax.servlet.jsp PageContext REQUEST_SCOPE
int REQUEST_SCOPE
To view the source code for javax.servlet.jsp PageContext REQUEST_SCOPE.
Click Source Link
From source file:com.tecapro.inventory.common.tag.MSRadioTag.java
@Override public int doStartTag() throws JspException { try {//from w w w. ja va2 s .com TilesInfoValue tilesValue = (TilesInfoValue) pageContext .getAttribute(TilesInfoValue.class.getSimpleName(), PageContext.REQUEST_SCOPE); BaseForm form = (BaseForm) pageContext.getRequest().getAttribute(BaseForm.class.getSimpleName()); tilesValue.setInfo(form.getValue().getInfo()); if (getDisabled() && getValue().equals(BeanUtils.getProperty(form, getProperty()))) { setDisabled(false); } if (tilesValue.isReadonly()) { setDisabled(true); } area = (area == null || "".equals(area)) ? Constants.COMMON_AREA : area; if (!keyExistTed(getProperty(), form.getValue().getInfo().getItem().getAreaList(area))) { HashMap<String, Boolean> keyMap = new HashMap<String, Boolean>(); keyMap.put(getProperty(), isRequire()); form.getValue().getInfo().getItem().getAreaList(area).add(keyMap); } StringBuffer colorClass = new StringBuffer(); if (isRequire()) { colorClass.append(Constants.StyleClass.REQUIRE); colorClass.append(Constants.SPACE); } List<String> idList = form.getError().getIdList(); for (String id : idList) { if (id.equals(getProperty())) { colorClass.append(Constants.StyleClass.ERROR); colorClass.append(Constants.SPACE); break; } } if (colorClass.length() > 0) { MSTagUtil.addStyleClass(this, colorClass.toString()); } MSTagUtil.setChangeFlag(this); return super.doStartTag(); } catch (Exception e) { throw new JspException(e); } }
From source file:com.tecapro.inventory.common.tag.MSButtonTag.java
@Override public int doStartTag() throws JspException { try {//from w w w . j a v a 2s .c o m String nameSpace = ""; if (this.nameSpace != null) { nameSpace = this.nameSpace; } MessageUtil msgUtil = (MessageUtil) WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()).getBean(BEAN_NAME_MSG_UTIL); StringUtil strUtil = (StringUtil) WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()).getBean(BEAN_NAME_STR_UTIL); TilesInfoValue value = (TilesInfoValue) pageContext .getAttribute(nameSpace + TilesInfoValue.class.getSimpleName(), PageContext.REQUEST_SCOPE); BaseForm form = (BaseForm) pageContext.getRequest().getAttribute(BaseForm.class.getSimpleName()); InfoValue info = form.getValue().getInfo(); value.setInfo(info); List<ButtonInfoValue> list = value.getButtonList(); ButtonInfoValue buttonInfo = list.get(index); if (buttonInfo == null || buttonInfo.getButtonName() == null) { this.setStyleClass("display_none"); MSTagUtil.addStyleClass(this, "disabled"); return super.doStartTag(); } if (buttonInfo.getInvisible() != null) { String flag = BeanUtils.getProperty(form, buttonInfo.getInvisible()); if (Constants.ONE.equals(flag)) { this.setStyleClass("display_hidden"); return super.doStartTag(); } } if (buttonInfo.getDisable() != null) { String flag = BeanUtils.getProperty(form, buttonInfo.getDisable()); if (Constants.ONE.equals(flag)) { this.setDisabled(true); MSTagUtil.addStyleClass(this, "disabled"); } } if (this.getDisabled()) { MSTagUtil.addStyleClass(this, "disabled"); } StringBuffer onclick = new StringBuffer(); if (getOnclick() != null && !"".equals(getOnclick())) { onclick.append(getOnclick() + ";"); } if (buttonInfo.getMessageId() != null) { String[] params = null; if (buttonInfo.getMessageParam() != null) { StringTokenizer token = new StringTokenizer(buttonInfo.getMessageParam(), ","); List<String> tokenList = new ArrayList<String>(); while (token.hasMoreTokens()) { tokenList.add(token.nextToken()); } params = tokenList.toArray(new String[tokenList.size()]); } onclick.append("if (!windowConfirm('").append(msgUtil.getMessage(buttonInfo.getMessageId(), params)) .append("')){return;};"); } // dirty check msg default String msgId = "MSG078C"; if (buttonInfo.isDirtyCheck() || Constants.BACK.equals(buttonInfo.getButtonName()) || Constants.MENU_MODORU.equals(buttonInfo.getButtonName())) { if (!strUtil.isNull(buttonInfo.getDirtyMsgId()) && !"".equals(buttonInfo.getDirtyMsgId())) { msgId = buttonInfo.getDirtyMsgId(); } onclick.append("if (!lossMessage('").append(msgUtil.getMessage(msgId, null)) .append("')){return;};"); } if (buttonInfo.getOnClick() != null && !"".equals(buttonInfo.getOnClick())) { onclick.append(buttonInfo.getOnClick() + ";"); } if (buttonInfo.getAction() != null && !"".equals(buttonInfo.getAction())) { onclick.append("send('").append(buttonInfo.getAction()).append("');"); } if (!"".equals(onclick.toString())) { this.setOnclick(onclick.toString()); } this.setValue(buttonInfo.getButtonName()); return super.doStartTag(); } catch (Exception e) { throw new JspException(e); } catch (Throwable e) { throw new JspException(e); } }
From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java
/** * INTERNAL: Gets user object out of session scope. *///from ww w .jav a 2s. c o m public static UserIF getUser(PageContext pageContext, boolean create) { try { Object obj = pageContext.getAttribute(NavigatorApplicationIF.USER_KEY, PageContext.SESSION_SCOPE); if (obj != null && obj instanceof UserIF) return (UserIF) obj; else // if no user object exists just create a new one return (create ? createUserSession(pageContext) : null); } catch (java.lang.IllegalStateException e) { // sessions not allowed in page, so get the user from the request scope instead Object obj = pageContext.getAttribute(NavigatorApplicationIF.USER_KEY, PageContext.REQUEST_SCOPE); if (obj != null && obj instanceof UserIF) return (UserIF) obj; else // if no user object exists just create a new one return (create ? createUserSession(pageContext, PageContext.REQUEST_SCOPE) : null); } }
From source file:org.openmrs.web.taglib.FormatDateTag.java
public int doStartTag() { RequestContext requestContext = (RequestContext) this.pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (date == null && getPath() != null) { try {//from w ww . j av a 2 s . com // get the "path" object from the pageContext String resolvedPath = getPath(); String nestedPath = (String) pageContext.getAttribute(NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE); if (nestedPath != null) { resolvedPath = nestedPath + resolvedPath; } BindStatus status = new BindStatus(requestContext, resolvedPath, false); log.debug("status: " + status); if (status.getValue() != null) { log.debug("status.value: " + status.getValue()); if (status.getValue().getClass() == Date.class) { // if no editor was registered all will go well here date = (Date) status.getValue(); } else { // if a "Date" property editor was registerd for the form, the status.getValue() // object will be a java.lang.String. This is useless. Try getting the original // value from the troublesome editor log.debug("status.valueType: " + status.getValueType()); Timestamp timestamp = (Timestamp) status.getEditor().getValue(); date = new Date(timestamp.getTime()); } } } catch (Exception e) { log.warn("Unable to get a date object from path: " + getPath(), e); return SKIP_BODY; } } if (!dateWasSet && date == null) { log.warn("Both 'date' and 'path' cannot be null. Page: " + pageContext.getPage() + " localname:" + pageContext.getRequest().getLocalName() + " rd:" + pageContext.getRequest().getRequestDispatcher("")); return SKIP_BODY; } if (type == null) { type = ""; } DateFormat dateFormat = null; if (format != null && format.length() > 0) { dateFormat = new SimpleDateFormat(format, Context.getLocale()); } else if (type.equals("xml")) { dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Context.getLocale()); } else { log.debug("context locale: " + Context.getLocale()); if (type.equals("long")) { dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Context.getLocale()); } else if (type.equals("medium")) { dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Context.getLocale()); } else { dateFormat = Context.getDateFormat(); } } if (dateFormat == null) { dateFormat = new SimpleDateFormat("MM-dd-yyyy"); } String datestr = ""; try { if (date != null) { if (type.equals("milliseconds")) { datestr = "" + date.getTime(); } else { if (showTodayOrYesterday && (DateUtils.isSameDay(Calendar.getInstance().getTime(), date) || OpenmrsUtil.isYesterday(date))) { //print only time of day but maintaining the format(24 Vs 12) if any was specified String timeFormatString = (format != null && !format.contains("a")) ? "HH:mm" : "h:mm a"; dateFormat = new SimpleDateFormat(timeFormatString); if (DateUtils.isSameDay(Calendar.getInstance().getTime(), date)) { datestr = Context.getMessageSourceService().getMessage("general.today") + " " + dateFormat.format(date); } else { datestr = Context.getMessageSourceService().getMessage("general.yesterday") + " " + dateFormat.format(date); } } else { datestr = dateFormat.format(date); } } } } catch (IllegalArgumentException e) { //format or date is invalid log.error("date: " + date); log.error("format: " + format); log.error(e); datestr = date.toString(); } try { pageContext.getOut().write(datestr); } catch (IOException e) { log.error(e); } // reset the objects to null because taglibs are reused release(); return SKIP_BODY; }
From source file:net.ontopia.topicmaps.nav.taglibs.template.InsertTag.java
public Stack getStack() { Stack s = (Stack) pageContext.getAttribute(TEMPL_STACK_KEY, PageContext.REQUEST_SCOPE); if (s == null) { s = new Stack(); pageContext.setAttribute(TEMPL_STACK_KEY, s, PageContext.REQUEST_SCOPE); }/*from w ww . ja v a2 s .c om*/ return s; }
From source file:info.magnolia.cms.taglibs.Out.java
/** * Setter for <code>scope</code>. * @param scope The scope to set.//from w ww . ja v a 2 s .com */ public void setScope(String scope) { if ("request".equalsIgnoreCase(scope)) { //$NON-NLS-1$ this.scope = PageContext.REQUEST_SCOPE; } else if ("session".equalsIgnoreCase(scope)) { //$NON-NLS-1$ this.scope = PageContext.SESSION_SCOPE; } else if ("application".equalsIgnoreCase(scope)) { //$NON-NLS-1$ this.scope = PageContext.APPLICATION_SCOPE; } else { // default this.scope = PageContext.PAGE_SCOPE; } }
From source file:org.shredzone.cilla.web.fragment.manager.FragmentContext.java
/** * Sets an attribute in the Request scope. Can be used to pass values to the * {@link #include(String)} template.// w w w. j a v a2 s.co m * * @param name * Attribute name * @param value * Attribute value, or {@code null} to remove this attribute */ public void setAttribute(String name, Object value) { pageContext.setAttribute(name, value, PageContext.REQUEST_SCOPE); }
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
/** * Gets the name of the action group as an attribute value (residing * in the page scope)./*w w w . jav a 2 s .c o m*/ */ public static String getActionGroup(PageContext pageContext) { return (String) pageContext.getAttribute(Constants.RA_ACTIONGROUP, PageContext.REQUEST_SCOPE); }
From source file:jp.troter.tags.capture.ContentForTag.java
@Override public int doEndTag() throws JspException { String name = CaptureUtil.captureName(this.name); @SuppressWarnings("unchecked") LinkedList<String> rawCurrent = (LinkedList<String>) pageContext.getAttribute(name, PageContext.REQUEST_SCOPE); LinkedList<String> current = CaptureUtil.nullToEmptyList(rawCurrent); concatToContextValue(name, current); return EVAL_PAGE; }
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
/** * Sets the name of the action group (an attribute is set in the * page scope).//from w w w .j a v a2 s. co m */ public static void setActionGroup(PageContext pageContext, String actionGroup) { pageContext.setAttribute(Constants.RA_ACTIONGROUP, actionGroup, PageContext.REQUEST_SCOPE); }