List of usage examples for org.springframework.web.servlet.tags NestedPathTag NESTED_PATH_VARIABLE_NAME
String NESTED_PATH_VARIABLE_NAME
To view the source code for org.springframework.web.servlet.tags NestedPathTag NESTED_PATH_VARIABLE_NAME.
Click Source Link
From source file:com.technologicaloddity.saha.util.AjaxPageRendererImpl.java
public String renderWithNestedModel(ModelAndView modelAndView, HttpServletRequest request, HttpServletResponse response, String nestedModelAttributeName) { request.setAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, nestedModelAttributeName); request.setAttribute(NestedPathTag.NESTED_PATH_VARIABLE_NAME, nestedModelAttributeName + PropertyAccessor.NESTED_PROPERTY_SEPARATOR); return render(modelAndView, request, response); }
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 {//w ww. ja va 2 s .c o m // 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:com.trenako.web.tags.LocalizedTextAreaTags.java
protected BindStatus getBindStatus() throws JspException { String resolvedPath = ExpressionEvaluationUtils.evaluateString("path", getPath(), pageContext); String nestedPath = (String) pageContext.getAttribute(NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);/* www . j a v a 2 s .co m*/ if (nestedPath != null && !resolvedPath.startsWith(nestedPath) && !resolvedPath.equals(nestedPath.substring(0, nestedPath.length() - 1))) { resolvedPath = nestedPath + resolvedPath; } return new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape()); }