|
| |
"A Brief History of Tags"
Vol. 8, Issue 6, p. 22
Listing 1
1 <jsp:useBean name="myBean" scope="session" class="mypackage.MyBean"/>
2 <B>The value of the type property of myBean
3 is <jsp:getProperty name="myBean" property="type"/>.</B>
4 <%
5 if (myBean.isMultiple()) {
6 Collection coll = myBean.getCollection() ;
7 session.setAttribute("collection", coll) ;
8 Iterator i = coll.iterator() ;
9 while (i.hasNext()) {
10 NestedBean nb = i.next() ;
11 %>
12 <B><%= nb.getName() %></B>
13 <%
14 }
15 }
16 %>
17 <P><IMG SRC="<jsp:getProperty name="myBean"
property="imageUrl"/>">
Listing 2
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<bean:define id='myBean' scope='page'
value='<% session.getAttribute("myBean") %>' />
<logic:equal parameter="myBean.multiple" value="true">
<logic:iterate id="nb" items="myBean.collection">
<B><bean:write name="nb" property="name" /></B>
</logic:iterate>
</logic:equal>
Listing 3
1 <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
2 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
3 <B>The value of the type property of myBean
4 is <c:out value="${sessionScope.myBean.type}" />.</B>
5 <c:if test="${sessionScope.myBean.multiple}">
6 <c:forEach var="nb" items="${sessionScope.myBean.collection}">
7 <B><c:out value="${nb.name}" /></B>
8 </c:forEach>
9 </c:if>
10 <P><html:img src="${sessionScope.myBean.imageUrl}" />
Listing 4
1 <%@ taglib uri="http://java.sun.com/jsf/html/"
2 prefix="h" %>
3 <%@ taglib uri="http://java.sun.com/jsf/core/"
4 prefix="f" %>
5 <jsp:useBean id="myBean"
6 class="mypackage.MyBean"
7 scope="session" />
8 <HTML>
9 <HEAD>
10 <TITLE>Sample JSF Page</TITLE>
11 <SCRIPT SRC="..."></SCRIPT>
12 </HEAD>
13 <BODY BGCOLOR="#ffffff">
14 <f:use_faces>
15 <h:form id="form1" formName="simpleForm">
16 <BR>Text Field: <h:input_text id="field1"
17 modelReference="myBean.attrib1" />
18 <BR>Numeric: <h:input_number id="field2"
19 numberStyle="INTEGER"
20 modelReference="myBean.attrib2" />
21 <BR>Password: <h:input_secret id="field3"
22 modelReference="myBean.attrib3" />
23 <BR><h:command_button id="submit" label="submit"
24 commandName="submit" />
25 </h:form>
26 </f:use_faces>
27 </BODY>
28 </HTML>
Listing 5
1 <!-- struts-bean tags (with EL support) -->
2 <taglib>
3 <taglib-uri>/WEB-INF/struts-bean-el.tld</taglib-uri>
4 <taglib-location>/WEB-INF/struts-bean-el.tld</taglib-location>
5 </taglib>
6
7 <!-- struts-html tags (with EL support) -->
8 <taglib>
9 <taglib-uri>/WEB-INF/struts-html-el.tld</taglib-uri>
10 <taglib-location>/WEB-INF/struts-html-el.tld</taglib-location>
11 </taglib>
12
13 <!-- struts-logic tags (with EL support) -->
14 <taglib>
15 <taglib-uri>/WEB-INF/struts-logic-el.tld</taglib-uri>
16 <taglib-location>/WEB-INF/struts-logic-el.tld</taglib-location>
17 </taglib>
18
19 <!-- JSTL core tags with EL support -->
20 <taglib>
21 <taglib-uri>/WEB-INF/c.tld</taglib-uri>
22 <taglib-location>/WEB-INF/c.tld</taglib-location>
23 </taglib>
24
25 <!-- JSTL formatting tags with EL support -->
26 <taglib>
27 <taglib-uri>/WEB-INF/fmt.tld</taglib-uri>
28 <taglib-location>/WEB-INF/fmt.tld</taglib-location>
29 </taglib>
30
31 <!-- JSTL SQL tags with EL support -->
32 <taglib>
33 <taglib-uri>/WEB-INF/sql.tld</taglib-uri>
34 <taglib-location>/WEB-INF/sql.tld</taglib-location>
35 </taglib>
36
37 <!-- JSTL XML tags with EL support -->
38 <taglib>
39 <taglib-uri>/WEB-INF/x.tld</taglib-uri>
40 <taglib-location>/WEB-INF/x.tld</taglib-location>
41 </taglib>
Listing 6
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
|
|
All Rights Reserved
Copyright © 2004 SYS-CON Media, Inc.
E-mail: info@sys-con.com
Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.
|