/** * @param arguments * Thymeleaf arguments * @return web context of arguments */ public static WebContext getWebContext(Arguments arguments) { return (WebContext) arguments.getContext(); } }
/** * @param arguments * Thymeleaf arguments * @return web context of arguments */ public static WebContext getWebContext(Arguments arguments) { return (WebContext) arguments.getContext(); } }
public static HtmlTable getTable(Arguments arguments) { return (HtmlTable) ((IWebContext) arguments.getContext()).getHttpServletRequest() .getAttribute("htmlTable"); }
public static HtmlTable getTable(Arguments arguments){ return (HtmlTable)((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute("htmlTable"); }
/** {@inheritDoc} */ public MessageResolution resolveMessage(Arguments args, String key, Object[] msgParams) { final Locale locale = args.getContext().getLocale(); String targetMsg = resolveProperties(locale).getProperty(key); if (targetMsg == null) { targetMsg = "<span style=\"color:red\">" + key + " not found</span>"; } else if (msgParams != null && msgParams.length > 0) { targetMsg = new MessageFormat(targetMsg, args.getContext().getLocale()).format(msgParams); } return new MessageResolution(targetMsg); }
/** {@inheritDoc} */ public MessageResolution resolveMessage(Arguments args, String key, Object[] msgParams) { final Locale locale = args.getContext().getLocale(); String targetMsg = resolveProperties(locale).getProperty(key); if (targetMsg == null) { targetMsg = key; } else if (msgParams != null && msgParams.length > 0) { targetMsg = new MessageFormat(targetMsg, args.getContext().getLocale()).format(msgParams); } return new MessageResolution(targetMsg); }
@Override protected boolean isVisible(Arguments arguments, Element element, String attributeName) { final String providerId = element.getAttributeValue(attributeName); if (providerId == null || providerId.trim().equals("")) { return false; } ConnectionRepository connectionRepository = getConnectionRepository(arguments.getContext()); return connectionRepository.findConnections(providerId).size() == 0; }
@Override protected boolean isVisible(Arguments arguments, Element element, String attributeName) { final String providerId = element.getAttributeValue(attributeName); if (providerId == null || providerId.trim().equals("")) { return false; } ConnectionRepository connectionRepository = getConnectionRepository(arguments.getContext()); return connectionRepository.findConnections(providerId).size() > 0; }
@Override protected ProcessorResult processElement(Arguments arguments, Element element) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse(); HtmlTable htmlTable = (HtmlTable) RequestUtils.getFromRequest(DataTablesDialect.INTERNAL_BEAN_TABLE, request); ProcessorResult processorResult = doProcessElement(arguments, element, request, response, htmlTable); return processorResult; }
@Override @SuppressWarnings("unchecked") protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); Map<Option<?>, Object> stagingOptions = (Map<Option<?>, Object>) request .getAttribute(DataTablesDialect.INTERNAL_BEAN_TABLE_STAGING_OPTIONS); // Make the actual attribute processing doProcessAttribute(arguments, element, attributeName, stagingOptions); // Housekeeping element.removeAttribute(attributeName); return ProcessorResult.ok(); }
@Override protected void doProcessAttribute(Arguments arguments, Element element, String attributeName, Map<Option<?>, Object> stagingOptions) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); String attrValue = AttributeUtils.parseStringAttribute(arguments, element, attributeName); RequestUtils.storeInRequest(DataTablesDialect.INTERNAL_CONF_GROUP, attrValue, request); } }
@Override protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) { logger.debug("{} attribute found", attributeName); // Get the request HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); // Get HtmlTable POJO from the HttpServletRequest HtmlTable htmlTable = Utils.getTable(arguments); // Get attribute value String attrValue = element.getAttributeValue(attributeName); logger.debug("Extracted value : {}", attrValue); // HtmlTable update if (htmlTable != null && StringUtils.isNotBlank(attrValue)) { htmlTable.setLabels(Utils.getBaseUrl(request) + attrValue); } return nonLenientOK(element, attributeName); } }
protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest();
private static Properties loadMessagesForTemplate( final Arguments arguments, final Properties defaultMessages) { Validate.notNull(arguments, "Arguments cannot be null"); Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null"); final String resourceName = arguments.getTemplateResolution().getResourceName(); final IResourceResolver resourceResolver = arguments.getTemplateResolution().getResourceResolver(); final Locale locale = arguments.getContext().getLocale(); final String templateBaseName = getTemplateFileNameBase(resourceName); return MessageResolutionUtils.loadCombinedMessagesFilesFromBaseName( arguments, resourceResolver, templateBaseName, locale, defaultMessages); }
/** * Sets up the export properties, before the filter intercepts the response. * * @param arguments * The Thymeleaf arguments. * @param htmlTable * The {@link HtmlTable} to export. */ private void setupExport(Arguments arguments, HtmlTable htmlTable) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse(); String currentExportType = ExportUtils.getCurrentExportType(request); htmlTable.getTableConfiguration().setExporting(true); htmlTable.getTableConfiguration().setCurrentExportFormat(currentExportType); // Call the export delegate ExportDelegate exportDelegate = new ExportDelegate(htmlTable, request); exportDelegate.prepareExport(); response.reset(); }
@Override protected void adaptFooter(HtmlTable table) { Element tfoot = new Element("tfoot"); Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute( DataTablesDialect.INTERNAL_NODE_TABLE); for (HtmlColumn column : table.getLastHeaderRow().getColumns()) { Element th = new Element("th"); th.addChild(new Text(column.getContent().toString())); tfoot.addChild(th); } ((Element) tableNode).addChild(tfoot); } }
Validate.notNull(arguments.getContext(), "Context cannot be null"); Validate.notNull(messageKey, "Message key cannot be null"); return getAbsentMessageRepresentation(messageKey, arguments.getContext().getLocale());
/** * TODO * * @param element */ private void generateFooter(Element element, Arguments arguments) { Element tfoot = new Element("tfoot"); Node tableNode = (Node)((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute("tableNode"); for(HtmlColumn column : htmlTable.getLastHeaderRow().getColumns()){ Element th = new Element("th"); th.addChild(new Text(column.getContent())); tfoot.addChild(th); } ((Element) tableNode).addChild(tfoot); } }
@Override protected void adaptHeader(HtmlTable table) { Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute( DataTablesDialect.INTERNAL_NODE_TABLE); Element thead = DomUtils.findElement((Element) tableNode, "thead"); Element tr = new Element("tr"); for (HtmlColumn column : table.getLastHeaderRow().getColumns()) { Element th = new Element("th"); th.addChild(new Text(column.getContent().toString())); tr.addChild(th); } if (thead != null) { thead.addChild(tr); } else { thead = new Element("thead"); thead.addChild(tr); ((Element) tableNode).addChild(thead); } }
@Override protected ProcessorResult processElement(Arguments arguments, Element element) { // Get the HTTP request HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); // HtmlTable htmlTable = (HtmlTable) // arguments.getLocalVariable("htmlTable"); HtmlTable htmlTable = Utils.getTable(arguments); this.htmlTable = htmlTable; if (this.htmlTable != null) { // The table is being exported if (RequestHelper.isTableBeingExported(request, this.htmlTable)) { setupExport(arguments); } // The table must be generated and displayed else { setupHtmlGeneration(arguments, element, request); } } // The "finalizing div" can now be removed element.getParent().removeChild(element); return ProcessorResult.OK; }