@Override public void execute(final ActionEvent event) { window4.display(); } });
@Override public String getNamingContextId() { // Build Id StringBuffer id = new StringBuffer(); id.append(WWindow.this.getId()); id.append(ID_CONTEXT_SEPERATOR); id.append(getIdName()); return id.toString(); } };
/** * Sets the current step counter. This method should only ever be used by internal code. * * @param step the step to set. */ public void setStep(final int step) { if (step != getStep()) { getOrCreateComponentModel().step = step; } }
/** * Sets whether the window is resizable. * * @param resizable true if the window should be resizable, false if not. */ public void setResizable(final boolean resizable) { if (resizable != isResizable()) { getOrCreateComponentModel().resizable = resizable; } }
/** * Sets whether the window should have a scroll bar. * * @param scrollable true if the window should have a scroll bar, false if not. */ public void setScrollable(final boolean scrollable) { if (scrollable != isScrollable()) { getOrCreateComponentModel().scrollbars = scrollable; } }
int window = getStep(); setStep(window + current); writer.print(" url=\"" + WebUtilities.encode(getUrl()) + '"'); writer.print(" width=\"" + getWidth() + '"'); writer.print(" height=\"" + getHeight() + '"'); if (isResizable()) { writer.print(" resizable=\"true\""); if (isScrollable()) { writer.print(" showScrollbars=\"true\""); if (isShowMenuBar()) { writer.print(" showMenubar=\"true\""); if (isShowToolbar()) { writer.print(" showToolbar=\"true\""); if (isShowLocation()) { writer.print(" showLocation=\"true\""); if (isShowStatus()) { writer.print(" showStatus=\"true\""); if (getTop() >= 0) { writer.print(" top=\"" + getTop() + '\'');
WWindow window = new WWindow(); window.setContent(content); window.setWidth(width); window.setHeight(height); window.setScrollable(true); window.setLocked(true); window.handleRequest(request); window.paint(new WebXmlRenderContext(new PrintWriter(writer))); Assert.assertEquals("Window should be hidden by default", "", writer.toString()); Assert.assertEquals("Content should not have been painted", 0, content.getPaintCount()); window.handleRequest(request); window.display(); window.paint(new WebXmlRenderContext(new PrintWriter(writer))); String xhtml = writer.toString(); Assert.assertTrue("Window should have emitted tag", xhtml.indexOf("<ui:popup") != -1); request.setParameter(WWindow.WWINDOW_REQUEST_PARAM_KEY, window.getId()); window.handleRequest(request); window.paint(new WebXmlRenderContext(new PrintWriter(writer))); Assert.assertEquals("Content should have been painted", 1, content.getPaintCount());
WWindow window = new WWindow(); window.setContent(new MockLabel("dummy")); app.add(window); WContent content = new WContent(); uic.setEnvironment(servletEnvironment); setActiveContext(uic); window.setStep(initialWindowStep); window.display(); initialServletStep + 1, servletEnvironment.getStep()); Assert.assertEquals("Window step should not have changed", initialWindowStep, window. getStep()); initialServletStep + 2, servletEnvironment.getStep()); Assert.assertEquals("Window step should not have changed", initialWindowStep, window. getStep()); servletEnvironment.getStep()); Assert.assertEquals("Window step should not have changed", initialWindowStep, window. getStep()); request.setParameter(WWindow.WWINDOW_REQUEST_PARAM_KEY, window.getId()); initialWindowStep + 1, window.getStep()); Assert.assertEquals("Servlet step should not have changed", initialServletStep, servletEnvironment.getStep()); initialWindowStep + 2, window.getStep());
final WWindow window1 = new WWindow(new TreeTableExample()); window1.setTitle("Functional content, round-trip"); window1.setScrollable(true); ajaxExamples.add(new AjaxWButtonExample()); ajaxExamples.add(new WButton("submit")); final WWindow window2 = new WWindow(ajaxExamples); window2.setTitle("Functional content, AJAX-enabled"); window2.setScrollable(true); add(window2); final WWindow window3 = new WWindow(new WContentExample()); window3.setTitle("Nested targetable content"); window3.setHeight(200); window3.setWidth(400); window3.setResizable(false); add(window3); final WWindow window4 = new WWindow(new WApplicationExample()); window4.setTitle("Window that uses change flag"); window4.setHeight(200); window4.setWidth(400); window4.setResizable(false);
@Test public void testSetResizable() { WWindow window = new WWindow(); Assert.assertTrue("Window should be resizable by default", window.isResizable()); window.setResizable(false); Assert.assertFalse("Window should not be resizable after setResizable(false)", window. isResizable()); window.setResizable(true); Assert.assertTrue("Window should be resizable after setResizable(true)", window. isResizable()); }
@Test public void testSetScrollbar() { WWindow window = new WWindow(); Assert.assertFalse("Window should not have scrollbar by default", window.isScrollable()); window.setScrollable(true); Assert.assertTrue("Window should have scrollbar after setScrollable(true)", window. isScrollable()); window.setScrollable(false); Assert.assertFalse("Window should not have scrollbar after setScrollable(false)", window. isScrollable()); }
/** * Returns a dynamic URL that this wwindow component can be accessed from. * * @return the URL to access this wwindow component. */ public String getUrl() { Environment env = getEnvironment(); Map<String, String> parameters = env.getHiddenParameters(); parameters.put(WWINDOW_REQUEST_PARAM_KEY, getId()); // Override the step count with WWindow step parameters.put(Environment.STEP_VARIABLE, String.valueOf(getStep())); String url = env.getWServletPath(); return WebUtilities.getPath(url, parameters, true); }
@Test public void testSetContent() { final WComponent content1 = new WTextField(); final WComponent content2 = new WTextField(); WWindow window = new WWindow(); window.setContent(content1); Assert.assertSame("Incorrect content returned", content1, window.getContent()); WComponent parentWindow = WebUtilities.getAncestorOfClass(WWindow.class, content1); Assert.assertSame("Content's parent window is incorrect", window, parentWindow); window.setContent(new WLabel()); window = new WWindow(content1); Assert.assertSame("Incorrect content returned", content1, window.getContent()); parentWindow = WebUtilities.getAncestorOfClass(WWindow.class, content1); Assert.assertSame("Content's parent window is incorrect", window, parentWindow); window.setContent(content2); Assert.assertSame("Incorrect content returned", content2, window.getContent()); Assert.assertNull("Old content's parent should be null", content1.getParent()); parentWindow = WebUtilities.getAncestorOfClass(WWindow.class, content2); Assert.assertSame("Content's parent window is incorrect", window, parentWindow); }
@Test public void testSetHeight() { assertAccessorsCorrect(new WWindow(), "height", 600, 123, 456); }
/** * Creates a new Window containing the specified content. * * @param content the window content. */ public WWindow(final WComponent content) { this(); setContent(content); }
/** * Override getStep to retrieve the step from a WWindow if the targeted component is a WWindow or a descendant * of one. * * @return the step count. */ @Override public int getStep() { // WWindows require a special case, as they keep track of their own separate step. // We must check if the request is an AJAX or content target inside a WWindow, // and if so return that WWindow's step. Otherwise, we return the step on the // environment. UIContextHolder.pushContext(window.getContext()); try { WWindow targetWindow = (WWindow) window.getComponent(); return targetWindow.getStep(); } finally { UIContextHolder.popContext(); } }
@Test public void testSetWidth() { assertAccessorsCorrect(new WWindow(), "width", 800, 123, 456); }
/** * Creates a MyApp. */ private MyApp() { add(appContent); add(window); window.setContent(new WLabel("test")); } }
@Override public void execute(final ActionEvent event) { window2.display(); } });
@Test public void testDuplicateComponentModels() { WWindow window = new WWindow(); assertNoDuplicateComponentModels(window, "title", "testTitle"); assertNoDuplicateComponentModels(window, "height", 223); assertNoDuplicateComponentModels(window, "width", 223); assertNoDuplicateComponentModels(window, "top",2); assertNoDuplicateComponentModels(window, "left",3); assertNoDuplicateComponentModels(window, "showMenuBar", true); assertNoDuplicateComponentModels(window, "showToolbar", true); assertNoDuplicateComponentModels(window, "showLocation", true); assertNoDuplicateComponentModels(window, "showStatus", true); assertNoDuplicateComponentModels(window, "resizable", false); assertNoDuplicateComponentModels(window, "scrollable", true); // TODO: See issue #1574 https://github.com/BorderTech/wcomponents/issues/1574 // assertNoDuplicateComponentModels(window, "state", 3); // No such method exception - protected modifier // assertNoDuplicateComponentModels(window, "targeted", true); // No such method exception - protected modifier assertNoDuplicateComponentModels(window, "step", 5); } }