~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/struts-el/web/exercise-taglib/html-select.jsp

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<%@ page language="java" import="java.util.*, org.apache.struts.util.*"%>
 
3
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
 
4
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
 
5
<%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %>
 
6
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
 
7
<html-el:html>
 
8
<head>
 
9
<title>Test html-el:select Tag</title>
 
10
<%
 
11
  String multipleValues[] =
 
12
   { "Multiple 0", "Multiple 1", "Multiple 2", "Multiple 3", "Multiple 4",
 
13
     "Multiple 5", "Multiple 6", "Multiple 7", "Multiple 8", "Multiple 9" };
 
14
  pageContext.setAttribute("multipleValues", multipleValues);
 
15
 
 
16
  Vector options = new Vector();
 
17
  options.add(new LabelValueBean("Label 0", "Value 0"));
 
18
  options.add(new LabelValueBean("Label 1", "Value 1"));
 
19
  options.add(new LabelValueBean("Label 2", "Value 2"));
 
20
  options.add(new LabelValueBean("Label 3", "Value 3"));
 
21
  options.add(new LabelValueBean("Label 4", "Value 4"));
 
22
  options.add(new LabelValueBean("Label 5", "Value 5"));
 
23
  options.add(new LabelValueBean("Label 6", "Value 6"));
 
24
  options.add(new LabelValueBean("Label 7", "Value 7"));
 
25
  options.add(new LabelValueBean("Label 8", "Value 8"));
 
26
  options.add(new LabelValueBean("Label 9", "Value 9"));
 
27
  pageContext.setAttribute("options", options);
 
28
 
 
29
  String withNulls[] =
 
30
   { "String 0", null, "String 2" };
 
31
  pageContext.setAttribute("withNulls", withNulls);
 
32
 
 
33
%>
 
34
</head>
 
35
<body bgcolor="white">
 
36
 
 
37
<div align="center">
 
38
<h1>Test struts-html-el Select Tag</h1>
 
39
</div>
 
40
 
 
41
Whatever changes you make to properties should be reflected when the page
 
42
is redisplayed.  Press "Save" to update, or "Cancel" to return to the
 
43
main menu.
 
44
 
 
45
<%--
 
46
     Ensure that the form bean exists before the form tag is processed. This
 
47
     is a simple (if not entirely clean) way of ensuring that the initial
 
48
     values assigned during bean instantiation will be available within the
 
49
     form, since reset() will not be called when the form bean already exists.
 
50
 
 
51
     The right way to fix this is to modify this webapp so that it does not
 
52
     refer directly to JSP pages, but goes through Action classes, and to
 
53
     either modify the TestBean class, adding an initialize() method, or to
 
54
     have an Action class set the initial values.
 
55
--%>
 
56
<jsp:useBean id="testbean" scope="session" class="org.apache.struts.webapp.exercise.TestBean"/>
 
57
 
 
58
<html-el:form action="html-select.do">
 
59
<table border="0" width="100%">
 
60
 
 
61
  <tr>
 
62
    <th align="right">Single Select Allowed:</th>
 
63
    <td align="left">
 
64
      <html-el:select property="singleSelect" size="10">
 
65
        <html-el:option value="Single 0">Single 0</html-el:option>
 
66
        <html-el:option value="Single 1">Single 1</html-el:option>
 
67
        <html-el:option value="Single 2">Single 2</html-el:option>
 
68
        <html-el:option value="Single 3" disabled="${!empty pageScope}">
 
69
         Single 3
 
70
        </html-el:option>
 
71
        <html-el:option value="Single 4">Single 4</html-el:option>
 
72
        <html-el:option value="Single 5">Single 5</html-el:option>
 
73
        <html-el:option value="Single 6">Single 6</html-el:option>
 
74
        <html-el:option value="Single 7">Single 7</html-el:option>
 
75
        <html-el:option value="Single 8">Single 8</html-el:option>
 
76
        <html-el:option value="Single 9" styleId="flork">Single 9</html-el:option>
 
77
      </html-el:select>
 
78
    </td>
 
79
  </tr>
 
80
 
 
81
  <tr>
 
82
    <th align="right">Multiple Select Allowed:</th>
 
83
    <td align="left">
 
84
      <html-el:select property="multipleSelect" size="10" multiple="true">
 
85
        <html-el:options name="multipleValues" labelName="multipleValues"/>
 
86
      </html-el:select>
 
87
    </td>
 
88
  </tr>
 
89
 
 
90
  <tr>
 
91
    <th align="right">Multiple Select From A Collection (Using &lt;html-el:options&gt;):</th>
 
92
    <td align="left">
 
93
      <html-el:select property="collectionSelect" size="10" multiple="true">
 
94
        <html-el:options collection="options" property="value" labelProperty="label"/>
 
95
      </html-el:select>
 
96
    </td>
 
97
  </tr>
 
98
 
 
99
  <tr>
 
100
    <th align="right">Multiple Select From A Collection (Using &lt;html-el:optionsCollection&gt;):</th>
 
101
    <td align="left">
 
102
      <html-el:select property="beanCollectionSelect" size="10" multiple="true">
 
103
        <html-el:optionsCollection name="testbean" property="beanCollection"
 
104
                                   filter="${empty pageScope}"/>
 
105
      </html-el:select>
 
106
    </td>
 
107
  </tr>
 
108
 
 
109
  <tr>
 
110
    <th align="right">
 
111
      Collection with null labels and values:
 
112
    </th>
 
113
    <td align="left">
 
114
      <html-el:select property="withNulls" size="3">
 
115
        <html-el:options name="withNulls" labelName="withNulls"
 
116
                         filter="${empty pageScope}" />
 
117
      </html-el:select>
 
118
    </td>
 
119
  </tr>
 
120
 
 
121
  <tr>
 
122
    <th align="right">
 
123
      Disabled select
 
124
    </th>
 
125
    <td align="left">
 
126
      <html-el:select disabled="${!empty pageScope}"
 
127
                      property="withNulls" size="3">
 
128
        <html-el:options name="withNulls" labelName="withNulls"
 
129
                         filter="${empty pageScope}" />
 
130
      </html-el:select>
 
131
    </td>
 
132
  </tr>
 
133
 
 
134
  <tr>
 
135
    <td align="right">
 
136
      <html-el:submit>Save</html-el:submit>
 
137
    </td>
 
138
    <td align="left">
 
139
      <html-el:reset>Reset</html-el:reset>
 
140
      <html-el:cancel>Cancel</html-el:cancel>
 
141
    </td>
 
142
  </tr>
 
143
 
 
144
</table>
 
145
 
 
146
</html-el:form>
 
147
 
 
148
 
 
149
</html-el:html>