Package org.apache.click.control

Examples of org.apache.click.control.Panel


    // Constructor ------------------------------------------------------------

    public TabbedPanelDemo() {
        addControl(tabbedPanel);

        Panel panel1 = new Panel("panel1", "panel/customersPanel1.htm");
        panel1.setLabel("The First Panel");
        tabbedPanel.add(panel1);

        Panel panel2 = new Panel("panel2", "panel/customersPanel2.htm");
        panel2.setLabel("The Second Panel");
        tabbedPanel.add(panel2);

        Panel panel3 = new Panel("panel3", "panel/customersPanel3.htm");
        panel3.setLabel("The Third Panel");
        tabbedPanel.add(panel3);

        // Register a listener that is notified when a different panel is selected.
        tabbedPanel.setTabListener(this, "onTabClick");
    }
View Full Code Here


    public void onInit() {
        super.onInit();

        addControl(tabbedPanel);

        Panel panel1 = new Panel("panel1", "panel/tabbed/panel1.htm");
        tabbedPanel.add(panel1);

        Panel panel2 = new Panel("panel2", "panel/tabbed/form-panel2.htm");
        Form form = new Form("form");
        panel2.add(form);

        // PLEASE NOTE: Form is addedd to the second Panel(at index 1), so when it
        // posts to the server it needs to send the index of it's own Panel so that the
        // TabbedPanel activates that Panel actives Panel at index 1. If we don't
        // cater for this, the form post will be handled by the Panel at index 0

        // When TabbedPanel detects the request Parameter 'tabPanelIndex', it
        // switches to the Panel at the given index.
        // we add a HiddenField called 'tabPanelIndex' set to index 1.
        //
        int tabIndex = 1;
        form.add(new HiddenField("tabPanelIndex", tabIndex));

        final TextField field = new TextField("name", "Enter your name");
        form.add(field);
        Submit submit = new Submit("go");
        submit.setActionListener(new ActionListener() {

            public boolean onAction(Control source) {
                addModel("msg", "Hi " + field.getValue() + ". Your form has been saved!");
                return true;
            }
        });
        form.add(submit);
        panel2.setLabel("The Second Panel");
        tabbedPanel.add(panel2);

        Panel panel3 = new Panel("panel3", "panel/tabbed/table-panel3.htm");
        Table table = new Table("table");
        table = new Table("table");

        // PLEASE NOTE: Table is addedd to the third Panel (at index 2), so when
        // the table is sorted or paged, it needs to send the index of it's Panel
        // so that the TabbedPanel activates Panel at index 2. If we don't cater
        // for this, the table sorting/paging request will be handled by the Panel
        // with index 0
        // When TabbedPanel detects the request Parameter 'tabPanelIndex', it
        // switches to the Panel at the given index.
        // we add a parameter called 'tabPanelIndex' to the table link
        tabIndex = 2;
        table.getControlLink().setParameter("tabPanelIndex", tabIndex);

        table.setClass(Table.CLASS_ITS);

        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));
        table.addColumn(new Column("email"));
        table.addColumn(new Column("investments"));
        table.setPageSize(5);
        table.setSortable(true);

        List list = customerService.getCustomersSortedByName(100);
        table.setRowList(list);

        panel3.add(table);

        tabbedPanel.add(panel3);
    }
View Full Code Here

    public void onInit() {
        super.onInit();

        addControl(tabbedPanel);

        Panel panel1 = new Panel("panel1", "panel/tabbed/panel1.htm");
        tabbedPanel.add(panel1);

        Panel panel2 = new Panel("panel2", "panel/tabbed/form-panel2.htm");
        Form form = new Form("form");
        panel2.add(form);

        final TextField field = new TextField("name", "Enter your name");
        form.add(field);
        Submit submit = new Submit("go");
        submit.setActionListener(new ActionListener() {

            public boolean onAction(Control source) {
                addModel("msg", "Hi " + field.getValue() + ". Your form has been saved!");
                return true;
            }
        });

        form.add(submit);
       
        panel2.setLabel("The Second Panel");
        tabbedPanel.add(panel2);

        Panel panel3 = new Panel("panel3", "panel/tabbed/table-panel3.htm");
        Table table = new Table("table");
        table = new Table("table");

        table.setClass(Table.CLASS_ITS);

        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));
        table.addColumn(new Column("email"));
        table.addColumn(new Column("investments"));
        table.setPageSize(5);
        table.setSortable(true);

        List list = customerService.getCustomersSortedByName(100);
        table.setRowList(list);

        panel3.add(table);

        tabbedPanel.add(panel3);

        // NOTE: Save the TabbedPanel state when a new panel is activated.
        // Register a listener that is notified when a different panel is selected.
View Full Code Here

    public void testDefaultActivePanel() {
        MockContext.initContext();

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
        String activePanelName = tabbedPanel.getActivePanel().getName();

        // By default panel1 should be the active panel
        assertEquals("panel1", activePanelName);
View Full Code Here

        // Since tabbedPanel is zero index based, setting tabPanelIndex to 1
        // should set the active panel to panel2
        context.getMockRequest().setParameter("tabPanelIndex", "1");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
        String activePanelName = tabbedPanel.getActivePanel().getName();

        // By default panel2 should be the active panel
        assertEquals("panel2", activePanelName);
View Full Code Here

        // Simulate user selecting panel2
        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
        context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
        String activePanelName = tabbedPanel.getActivePanel().getName();

        // By default panel2 should be the active panel
        assertEquals("panel2", activePanelName);
View Full Code Here

        // Simulate user selecting panel2
        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
        context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));

        tabbedPanel.setTabListener(new ActionListener() {
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
View Full Code Here

        Page page = new Page();
        TabbedPanel panel = new TabbedPanel("panel");
        page.addControl(panel);

        // Add two panels named child1 and child2
        Panel child1 = new Panel("child1");
        Panel child2 = new Panel("child2");
        panel.add(child1);
        panel.add(child2);

        // Execute onInit event
        panel.onInit();

        assertEquals(3, panel.getControlMap().size());
        assertEquals(3, panel.getControls().size());
        assertSame(child1, panel.getControls().get(1));
        assertSame(child2, panel.getControls().get(2));
        assertSame(child1, panel.getPanels().get(0));
        assertSame(child2, panel.getPanels().get(1));
        assertTrue(child1.isActive());
        assertFalse(child2.isActive());

        // Add another two panels named child1 and child2 and test that these
        // panels replaces the previous panels
        child1 = new Panel("child1");
        child2 = new Panel("child2");
        panel.add(child1);
        panel.add(child2);
        assertEquals(3, panel.getControlMap().size());
        assertEquals(3, panel.getControls().size());
        assertSame(child1, panel.getControls().get(1));
        assertSame(child2, panel.getControls().get(2));
        assertSame(child1, panel.getPanels().get(0));
        assertSame(child2, panel.getPanels().get(1));
        assertTrue(child1.isActive());
        assertFalse(child2.isActive());
    }
View Full Code Here

    public void testGetState() {
        // Setup Panel
        TabbedPanel panel = new TabbedPanel("panel");

        // Add two panels named child1 and child2
        Panel child1 = new Panel("child1");
        Panel child2 = new Panel("child2");
        panel.add(child1);
        panel.add(child2);

        Map expectedTabLinkState = new HashMap();
        expectedTabLinkState.put("id", "1");
View Full Code Here

    public void testSetState() {
        // Setup Panel
        TabbedPanel panel = new TabbedPanel("panel");

        // Add two panels named child1 and child2
        Panel child1 = new Panel("child1");
        Panel child2 = new Panel("child2");
        panel.add(child1);
        panel.add(child2);

        Map expectedTabLinkState = new HashMap();
        expectedTabLinkState.put("id", "1");
View Full Code Here

TOP

Related Classes of org.apache.click.control.Panel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.