/** * {@inheritDoc} */ @Override public void clearScratchMap() { backing.clearScratchMap(); }
/** * {@inheritDoc} */ @Override public void clearScratchMap(final WComponent component) { backing.clearScratchMap(component); }
/** * Override serviceRequest to clear out the targetable index from the last request. And clear out the scratch map * after the request has been processed (and before painting occurs). * * @param request the request being responded to. */ @Override public void serviceRequest(final Request request) { LOG.debug("Before Service Request - Clearing targetable index."); UIContext uic = UIContextHolder.getCurrent(); super.serviceRequest(request); // Clear phase scope scratch map LOG.debug("After Service Request - Clearing scratch map with phase scope."); uic.clearScratchMap(); }
/** * Clears the scratch map with phase scope for the given component. * * @param component the component to clear the scratch map for. */ @Override public void clearScratchMap(final WComponent component) { if (isInContext(component)) { Map sharedScratchMap = getParentContext().getScratchMap(component); sharedScratchMap.remove(this); } else { getParentContext().clearScratchMap(component); } }
/** * Override paint to clear out the scratch map and component models which are no longer necessary. * * @param renderContext the renderContext to send the output to. */ @Override public void paint(final RenderContext renderContext) { super.paint(renderContext); UIContext uic = UIContextHolder.getCurrent(); if (LOG.isDebugEnabled()) { UIContextDebugWrapper debugWrapper = new UIContextDebugWrapper(uic); LOG.debug("Session usage after paint:\n" + debugWrapper); } LOG.debug("Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up."); getUI().tidyUpUIContextForTree(); LOG.debug("After paint - Clearing scratch maps."); uic.clearScratchMap(); uic.clearRequestScratchMap(); } }
@Test public void testScratchMapAccessors() { UIContext uic = createUIContext(); WComponent component = new DefaultWComponent(); Assert.assertNotNull("Scratch Map should not be null", uic.getScratchMap(component)); Assert.assertTrue("Scratch Map should be empty", uic.getScratchMap(component).isEmpty()); // Add item to scratch map String key = "key"; String value = "value"; uic.getScratchMap(component).put(key, value); Assert.assertEquals("Incorrect number of scratch map entries", 1, uic.getScratchMap( component).size()); Assert.assertTrue("The test key is not in the scratch map", uic.getScratchMap(component). containsKey(key)); // Clear Scratch Map uic.clearScratchMap(component); Assert.assertTrue("Scratch map should be empty after being cleared", uic.getScratchMap( component).isEmpty()); // Add item to scratch map uic.getScratchMap(component).put(key, value); // Clear ALL Scratch Maps uic.clearScratchMap(); Assert.assertTrue("Scratch map should be empty after all scratch maps cleared", uic. getScratchMap(component).isEmpty()); }
uic.clearScratchMap(node); uic.clearScratchMap(node); } else if (node instanceof Container) { Container container = (Container) node;
uic.clearScratchMap(); uic.clearRequestScratchMap();
uic.clearScratchMap(this); uic.clearRequestScratchMap(this);
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WDataTable table = new WDataTable(); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.setNoDataMessage(getMaliciousAttribute("ui:table")); UIContext uic = createUIContext(); assertSafeContent(table); WButton button = new WButton("dummy"); table.addAction(button); table.addActionConstraint(button, new ActionConstraint(0, 1, false, getMaliciousAttribute( "ui:action"))); assertSafeContent(table); TableDataModel tableModel = createTableModel(); table.setDataModel(tableModel); uic.clearScratchMap(); // clear out cached data from previous renders assertSafeContent(table); table.setCaption(getMaliciousAttribute("ui:table")); assertSafeContent(table); table.setSummary(getMaliciousAttribute("ui:table")); assertSafeContent(table); table.setSelectGroup(getMaliciousAttribute("ui:rowselection")); assertSafeContent(table); table.setActiveFilters(Arrays.asList(new String[]{getMaliciousAttribute("ui:table")})); }
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WTable table = new WTable(); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.addColumn(new WTableColumn(getMaliciousContent(), WText.class)); table.setNoDataMessage(getMaliciousAttribute("ui:table")); UIContext uic = createUIContext(); assertSafeContent(table); WButton button = new WButton("dummy"); table.addAction(button); table.addActionConstraint(button, new ActionConstraint(0, 1, false, getMaliciousAttribute( "ui:action"))); assertSafeContent(table); TableModel tableModel = createTableModel(); table.setTableModel(tableModel); uic.clearScratchMap(); // clear out cached data from previous renders assertSafeContent(table); table.setCaption(getMaliciousAttribute("ui:table")); assertSafeContent(table); }