You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/05/25 22:03:06 UTC
svn commit: r178526 - in /incubator/beehive/trunk/samples/netui-samples:
index.jsp ui/select/ ui/select/Controller.java ui/select/index.jsp
ui/select/repeatingSelect.jsp ui/select/repeatingSelectWithOptionBody.jsp
ui/select/simpleSelect.jsp ui/select/simpleSelectWithIntKeys.jsp
Author: ekoneil
Date: Wed May 25 13:03:05 2005
New Revision: 178526
URL: http://svn.apache.org/viewcvs?rev=178526&view=rev
Log:
Add a netui-samples sample for the select tag.
This sample includes four parts:
- simple select box rendering a Map<String, String>
- simple select box rendering a Map<int, String>
- repeating select box where the select option's key / value are the same
- repeating select box where the select option's key / value are different
BB: self
DRT: netui-samples builds / runs
Added:
incubator/beehive/trunk/samples/netui-samples/ui/select/
incubator/beehive/trunk/samples/netui-samples/ui/select/Controller.java
incubator/beehive/trunk/samples/netui-samples/ui/select/index.jsp
incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelect.jsp
incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelectWithOptionBody.jsp
incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelect.jsp
incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelectWithIntKeys.jsp
Modified:
incubator/beehive/trunk/samples/netui-samples/index.jsp
Modified: incubator/beehive/trunk/samples/netui-samples/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/index.jsp?rev=178526&r1=178525&r2=178526&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/index.jsp (original)
+++ incubator/beehive/trunk/samples/netui-samples/index.jsp Wed May 25 13:03:05 2005
@@ -97,6 +97,10 @@
original page flow.</dd>
</dl>
<dl>
+ <dt><netui:anchor href="ui/select/Controller.jpf" value="The Select tag"/></dt>
+ <dd>Demonstrates how to use the select tag</dd>
+ </dl>
+ <dl>
<dt><netui:anchor href="ui/formintagfile/Controller.jpf" value="JSP Tag File as a Form"/></dt>
<dd>Demonstrates how to use a JSP 2.0 .tag file to contain a NetUI form</dd>
</dl>
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/Controller.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/Controller.java?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/Controller.java (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/Controller.java Wed May 25 13:03:05 2005
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package ui.select;
+
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.samples.controls.pets.Pets;
+import org.apache.beehive.samples.netui.beans.PetType;
+import org.apache.beehive.controls.api.bean.Control;
+
+@Jpf.Controller(
+ simpleActions=@Jpf.SimpleAction(name="begin",path="index.jsp")
+ )
+public class Controller
+ extends PageFlowController {
+
+ @Control
+ private Pets _petControl;
+
+ private Map _colorOptions = null;
+ private Map _colorOptionsIntKeys = null;
+
+ private PetType[] _pets = null;
+
+ protected void onCreate()
+ throws Exception {
+ _colorOptions = new LinkedHashMap();
+ _colorOptions.put("blue", "Blue");
+ _colorOptions.put("orange", "Orange");
+ _colorOptions.put("white", "White");
+ _colorOptions.put("black", "Black");
+
+ _colorOptionsIntKeys = new LinkedHashMap();
+ _colorOptionsIntKeys.put(1, "Blue");
+ _colorOptionsIntKeys.put(2, "Orange");
+ _colorOptionsIntKeys.put(3, "White");
+ _colorOptionsIntKeys.put(4, "Black");
+
+ _pets = _petControl.getPetList();
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success",
+ path="simpleSelect.jsp",
+ actionOutputs={
+ @Jpf.ActionOutput(name="colorMap", type=Map.class)
+ }
+ ))
+ public Forward showSimple() {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("colorMap", _colorOptions);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success", path="simpleSelect.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name="colorMap", type=Map.class)
+ }
+ )
+ )
+ public Forward updateSimple(ColorForm form) {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("colorMap", _colorOptions);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success",
+ path="simpleSelectWithIntKeys.jsp",
+ actionOutputs={
+ @Jpf.ActionOutput(name="colorMapWithIntKeys", type=Map.class)
+ }
+ ))
+ public Forward showSimpleWithIntKeys() {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("colorMapWithIntKeys", _colorOptionsIntKeys);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success", path="simpleSelectWithIntKeys.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name="colorMapWithIntKeys", type=Map.class)
+ }
+ )
+ )
+ public Forward updateSimpleWithIntKeys(ColorIndexForm form) {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("colorMapWithIntKeys", _colorOptionsIntKeys);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success",
+ path="repeatingSelect.jsp",
+ actionOutputs={
+ @Jpf.ActionOutput(name="petList", type=PetType.class)
+ }
+ ))
+ public Forward showRepeating() {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("petList", _pets);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success", path="repeatingSelect.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name="petList", type=PetType.class)
+ }
+ )
+ )
+ public Forward updateRepeating(PetForm form) {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("petList", _pets);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success",
+ path="repeatingSelectWithOptionBody.jsp",
+ actionOutputs={
+ @Jpf.ActionOutput(name="petList", type=PetType.class)
+ }
+ ))
+ public Forward showRepeatingWithOptionBody() {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("petList", _pets);
+ return forward;
+ }
+
+ @Jpf.Action(forwards=
+ @Jpf.Forward(
+ name="success", path="repeatingSelectWithOptionBody.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name="petList", type=PetType.class)
+ }
+ )
+ )
+ public Forward updateRepeatingWithOptionBody(PetForm form) {
+ Forward forward = new Forward("success");
+ forward.addActionOutput("petList", _pets);
+ return forward;
+ }
+
+ public static class ColorForm {
+ private String _color = null;
+
+ public String getColor() {
+ return _color;
+ }
+
+ public void setColor(String color) {
+ _color = color;
+ }
+ }
+
+ public static class ColorIndexForm {
+ private Integer _colorIndex = null;
+
+ public Integer getColorIndex() {
+ return _colorIndex;
+ }
+
+ public void setColorIndex(Integer color) {
+ _colorIndex = color;
+ }
+ }
+
+ public static class PetForm {
+ private String _name = null;
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/index.jsp?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/index.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/index.jsp Wed May 25 13:03:05 2005
@@ -0,0 +1,43 @@
+<%--
+ Copyright 2004-2005 The Apache Software Foundation.
+
+ Licensed 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.
+
+ $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+ <netui-template:setAttribute name="sampleTitle" value="Select"/>
+ <netui-template:section name="main">
+ <dl>
+ <dt><netui:anchor action="showSimple" value="Simple Select with String Keys"/></dt>
+ <dd>Demonstrates a simple select box</dd>
+ </dl>
+ <dl>
+ <dt><netui:anchor action="showSimpleWithIntKeys" value="Simple Select with Integer Keys"/></dt>
+ <dd>Demonstrates a simple select box using integer keys</dd>
+ </dl>
+ <dl>
+ <dt><netui:anchor action="showRepeating" value="Repeating Select with String Keys"/></dt>
+ <dd>Demonstrates a select box rendering options from a data set</dd>
+ </dl>
+ <dl>
+ <dt><netui:anchor action="showRepeatingWithOptionBody" value="Repeating Select with Select Option Body Content and Integer Keys"/></dt>
+ <dd>Demonstrates a select box rendering options from a data set and expliicitly specifying the text of each select option.</dd>
+ </dl>
+ </netui-template:section>
+</netui-template:template>
\ No newline at end of file
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelect.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelect.jsp?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelect.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelect.jsp Wed May 25 13:03:05 2005
@@ -0,0 +1,43 @@
+<%--
+ Copyright 2004-2005 The Apache Software Foundation.
+
+ Licensed 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.
+
+ $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
+
+<netui-data:declarePageInput name="petList" type="org.apache.beehive.samples.netui.beans.PetType"/>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+ <netui-template:setAttribute name="sampleTitle" value="Repeating Select Tag"/>
+ <netui-template:section name="main">
+ <br/>
+ <netui:form action="updateRepeating">
+ <br/>
+ Selected value: ${actionForm.name}
+ <br/>
+ <br/>
+ <netui:select dataSource="actionForm.name" optionsDataSource="${pageInput.petList}" repeater="true">
+ <netui:selectOption value="${container.item.name}" repeatingType="option"/>
+ </netui:select>
+ <br/>
+ <br/>
+ <netui:button value="Submit"/>
+ </netui:form>
+ <br/>
+ </netui-template:section>
+</netui-template:template>
\ No newline at end of file
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelectWithOptionBody.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelectWithOptionBody.jsp?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelectWithOptionBody.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/repeatingSelectWithOptionBody.jsp Wed May 25 13:03:05 2005
@@ -0,0 +1,45 @@
+<%--
+ Copyright 2004-2005 The Apache Software Foundation.
+
+ Licensed 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.
+
+ $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
+
+<netui-data:declarePageInput name="petList" type="org.apache.beehive.samples.netui.beans.PetType"/>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+ <netui-template:setAttribute name="sampleTitle" value="Repeating Select Tag using a Select Option Body"/>
+ <netui-template:section name="main">
+ <br/>
+ <netui:form action="updateRepeatingWithOptionBody">
+ <br/>
+ Selected value: ${actionForm.name}
+ <br/>
+ <br/>
+ <netui:select dataSource="actionForm.name" optionsDataSource="${pageInput.petList}" repeater="true">
+ <netui:selectOption value="${container.item.petID}" repeatingType="option">
+ <netui:content value="${container.item.name}"/>
+ </netui:selectOption>
+ </netui:select>
+ <br/>
+ <br/>
+ <netui:button value="Submit"/>
+ </netui:form>
+ <br/>
+ </netui-template:section>
+</netui-template:template>
\ No newline at end of file
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelect.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelect.jsp?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelect.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelect.jsp Wed May 25 13:03:05 2005
@@ -0,0 +1,41 @@
+<%--
+ Copyright 2004-2005 The Apache Software Foundation.
+
+ Licensed 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.
+
+ $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
+
+<netui-data:declarePageInput name="colorMap" type="java.util.Map"/>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+ <netui-template:setAttribute name="sampleTitle" value="Simple Select Tag"/>
+ <netui-template:section name="main">
+ <br/>
+ <netui:form action="updateSimple">
+ <br/>
+ Selected value: ${actionForm.color}
+ <br/>
+ <br/>
+ <netui:select dataSource="actionForm.color" optionsDataSource="${pageInput.colorMap}"/>
+ <br/>
+ <br/>
+ <netui:button value="Submit"/>
+ </netui:form>
+ <br/>
+ </netui-template:section>
+</netui-template:template>
\ No newline at end of file
Added: incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelectWithIntKeys.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelectWithIntKeys.jsp?rev=178526&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelectWithIntKeys.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/ui/select/simpleSelectWithIntKeys.jsp Wed May 25 13:03:05 2005
@@ -0,0 +1,41 @@
+<%--
+ Copyright 2004-2005 The Apache Software Foundation.
+
+ Licensed 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.
+
+ $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
+
+<netui-data:declarePageInput name="colorMapWithIntKeys" type="java.util.Map"/>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+ <netui-template:setAttribute name="sampleTitle" value="Simple Select Tag"/>
+ <netui-template:section name="main">
+ <br/>
+ <netui:form action="updateSimpleWithIntKeys">
+ <br/>
+ Selected value: ${actionForm.colorIndex}
+ <br/>
+ <br/>
+ <netui:select dataSource="actionForm.colorIndex" optionsDataSource="${pageInput.colorMapWithIntKeys}" defaultValue="1"/>
+ <br/>
+ <br/>
+ <netui:button value="Submit"/>
+ </netui:form>
+ <br/>
+ </netui-template:section>
+</netui-template:template>
\ No newline at end of file