You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/11/03 12:04:01 UTC
svn commit: r1030410 - in /click/trunk/click/examples:
src/org/apache/click/examples/page/panel/ webapp/WEB-INF/ webapp/panel/
webapp/panel/tabbed/
Author: sabob
Date: Wed Nov 3 11:04:01 2010
New Revision: 1030410
URL: http://svn.apache.org/viewvc?rev=1030410&view=rev
Log:
added demos on Statelss+Stateful TabbedPanel
Added:
click/trunk/click/examples/src/org/apache/click/examples/page/panel/StatefulTabbedPanelDemo.java
click/trunk/click/examples/src/org/apache/click/examples/page/panel/TabbedPanelWithControls.java
click/trunk/click/examples/webapp/panel/stateful-tabbed-panel-demo.htm
click/trunk/click/examples/webapp/panel/tabbed/
click/trunk/click/examples/webapp/panel/tabbed-panel-with-controls.htm
click/trunk/click/examples/webapp/panel/tabbed/form-panel2.htm
click/trunk/click/examples/webapp/panel/tabbed/panel1.htm
click/trunk/click/examples/webapp/panel/tabbed/table-panel3.htm
Modified:
click/trunk/click/examples/webapp/WEB-INF/menu.xml
Added: click/trunk/click/examples/src/org/apache/click/examples/page/panel/StatefulTabbedPanelDemo.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/panel/StatefulTabbedPanelDemo.java?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/panel/StatefulTabbedPanelDemo.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/panel/StatefulTabbedPanelDemo.java Wed Nov 3 11:04:01 2010
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.examples.page.panel;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+import org.apache.click.ActionListener;
+import org.apache.click.Control;
+import org.apache.click.control.Column;
+import org.apache.click.control.Form;
+
+import org.apache.click.control.Panel;
+import org.apache.click.control.Submit;
+import org.apache.click.control.Table;
+import org.apache.click.control.TextField;
+import org.apache.click.examples.domain.Customer;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.service.CustomerService;
+import org.apache.click.extras.panel.TabbedPanel;
+import org.springframework.stereotype.Component;
+
+/**
+ * Provides a stateful TabbedPanel demo. The selected Tab will be
+ * preserved between requests.
+ */
+@Component
+public class StatefulTabbedPanelDemo extends BorderPage {
+
+ private static final long serialVersionUID = 1L;
+
+ private TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
+ private List<Customer> customers;
+
+ @Resource(name="customerService")
+ private CustomerService customerService;
+
+ // Constructor ------------------------------------------------------------
+
+ @Override
+ 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.
+ tabbedPanel.setTabListener(new ActionListener() {
+ public boolean onAction(Control source) {
+ // Save the TabbedPanel state to the session
+ tabbedPanel.saveState(getContext());
+ return true;
+ }
+ });
+
+ // NOTE: Restore the TabbedPanel state. This will set the active panel from the
+ // state that was saved from the TaListener above
+ tabbedPanel.restoreState(getContext());
+ }
+
+ // Event Handlers ---------------------------------------------------------
+
+ /**
+ * @see org.apache.click.Page#onRender()
+ */
+ @Override
+ public void onRender() {
+ customers = customerService.getCustomersSortedByName(12);
+ addModel("customers", customers);
+ }
+}
Added: click/trunk/click/examples/src/org/apache/click/examples/page/panel/TabbedPanelWithControls.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/panel/TabbedPanelWithControls.java?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/panel/TabbedPanelWithControls.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/panel/TabbedPanelWithControls.java Wed Nov 3 11:04:01 2010
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.examples.page.panel;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+import org.apache.click.ActionListener;
+import org.apache.click.Control;
+import org.apache.click.control.Column;
+import org.apache.click.control.Form;
+import org.apache.click.control.HiddenField;
+
+import org.apache.click.control.Panel;
+import org.apache.click.control.Submit;
+import org.apache.click.control.Table;
+import org.apache.click.control.TextField;
+import org.apache.click.examples.domain.Customer;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.service.CustomerService;
+import org.apache.click.extras.panel.TabbedPanel;
+import org.springframework.stereotype.Component;
+
+/**
+ * Provides a TabbedPanel demonstration, integrating a Form and Table.
+ */
+@Component
+public class TabbedPanelWithControls extends BorderPage {
+
+ private static final long serialVersionUID = 1L;
+
+ private TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
+ private List<Customer> customers;
+
+ @Resource(name="customerService")
+ private CustomerService customerService;
+
+ // Constructor ------------------------------------------------------------
+
+ @Override
+ 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);
+ }
+
+ // Event Handlers ---------------------------------------------------------
+
+ /**
+ * @see org.apache.click.Page#onRender()
+ */
+ @Override
+ public void onRender() {
+ customers = customerService.getCustomersSortedByName(12);
+ addModel("customers", customers);
+ }
+
+}
Modified: click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=1030410&r1=1030409&r2=1030410&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ click/trunk/click/examples/webapp/WEB-INF/menu.xml Wed Nov 3 11:04:01 2010
@@ -130,6 +130,8 @@
<menu label="Simple Panel" path="panel/simple-panel-demo.htm"/>
<menu label="List Panel" path="panel/list-panel-demo.htm"/>
<menu label="Tabbed Panel" path="panel/tabbed-panel-demo.htm"/>
+ <menu label="Tabbed Panel with Controls" path="panel/tabbed-panel-with-controls.htm"/>
+ <menu label="Stateful Tabbed Panel" path="panel/stateful-tabbed-panel-demo.htm"/>
<menu label="Filter Panel" path="panel/filter-panel-demo.htm"/>
<menu label="Column Panel" path="panel/panel-column-demo.htm"/>
<menu label="Reusable Panel" path="panel/reusable-panel-demo.htm"/>
Added: click/trunk/click/examples/webapp/panel/stateful-tabbed-panel-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/panel/stateful-tabbed-panel-demo.htm?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/panel/stateful-tabbed-panel-demo.htm (added)
+++ click/trunk/click/examples/webapp/panel/stateful-tabbed-panel-demo.htm Wed Nov 3 11:04:01 2010
@@ -0,0 +1,24 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.*#
+-->
+
+$tabbedPanel
+
+<h4>
+ $!msg
+</h4>
Added: click/trunk/click/examples/webapp/panel/tabbed-panel-with-controls.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/panel/tabbed-panel-with-controls.htm?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/panel/tabbed-panel-with-controls.htm (added)
+++ click/trunk/click/examples/webapp/panel/tabbed-panel-with-controls.htm Wed Nov 3 11:04:01 2010
@@ -0,0 +1,24 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.*#
+-->
+
+$tabbedPanel
+
+<h4>
+ $!msg
+</h4>
Added: click/trunk/click/examples/webapp/panel/tabbed/form-panel2.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/panel/tabbed/form-panel2.htm?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/panel/tabbed/form-panel2.htm (added)
+++ click/trunk/click/examples/webapp/panel/tabbed/form-panel2.htm Wed Nov 3 11:04:01 2010
@@ -0,0 +1,22 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.*#
+-->
+
+<h2>Form</h2>
+
+$form
\ No newline at end of file
Added: click/trunk/click/examples/webapp/panel/tabbed/panel1.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/panel/tabbed/panel1.htm?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/panel/tabbed/panel1.htm (added)
+++ click/trunk/click/examples/webapp/panel/tabbed/panel1.htm Wed Nov 3 11:04:01 2010
@@ -0,0 +1,22 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.*#
+-->
+
+<h2>Start</h2>
+
+This example demonstrates how to integrate a Form and Table with a TabbedPanel.
\ No newline at end of file
Added: click/trunk/click/examples/webapp/panel/tabbed/table-panel3.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/panel/tabbed/table-panel3.htm?rev=1030410&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/panel/tabbed/table-panel3.htm (added)
+++ click/trunk/click/examples/webapp/panel/tabbed/table-panel3.htm Wed Nov 3 11:04:01 2010
@@ -0,0 +1,23 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitationsx
+ under the License.*#
+-->
+
+
+<h2>Table</h2>
+
+$table
\ No newline at end of file