📄 code5.html
字号:
<PRE>
private void searchItems(ServletOutputStream out,
HttpServletRequest request)
throws IOException {
//Retrieve search string
String searchString=request.getParameter(
"searchString");
//Create HTML page
String text = "Click Item number for description
and to place bid.";
setTitle(out, "Search Results");
try {
addLine("<BR>"+text, out);
//Look up home interface for BidderBean
BidderHome bhome=(BidderHome) ctx.lookup(
"bidder");
//Create remote interface for BidderBean
Bidder bid=bhome.create();
//Pass search string to BidderBean method
Enumeration enum=(Enumeration)
bid.getMatchingItemsList(searchString);
if(enum != null) {
displayitems(enum, out);
addLine("", out);
}
} catch (Exception e) {
addLine("AuctionServlet Search Items error",
out);
System.out.println("AuctionServlet <newlist>:
"+e);
}
out.flush();
}
</PRE>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<A NAME="gmi"></A>
<H3>BidderBean.getMatchingItemsList</H3>
<P>
The <CODE>BidderBean.getMatchingItemsList</CODE>
method calls the <CODE>AuctionItemHome.findAllMatchingItems</CODE>
method and passes it the search string.
<CODE>AuctionItemBean</CODE> is an entity Bean that handles
auction item updates and retrievals.
<P>
The search results are returned to this method
in an <CODE>Enumeration</CODE> variable.
</FONT>
<PRE>
public Enumeration getMatchingItemsList(
String searchString)
throws RemoteException {
Enumeration enum=null;
try{
//Create Home interface for AuctionItemBean
AuctionItemHome home = (AuctionItemHome)
ctx.lookup("auctionitems");
//Pass search string to Home interface method
enum=(Enumeration)home.findAllMatchingItems(
searchString);
}catch (Exception e) {
System.out.println("getMatchingItemList: "+e);
return null;
}
return enum;
}
</PRE>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<A NAME="fmi"></A>
<H3>AuctionItemHome.findAllMatchingItems</H3>
<P>
The <CODE>AuctionItemHome.findAllMatchingItems</CODE>
method is not implemented in <CODE>AuctionItemBean</CODE>.
The <CODE>AuctionItemBean finder</CODE> method implementations
are defined in the <CODE>AuctionItemBean</CODE> deployment descriptor
when <A HREF="http://weblogic.beasys.com/index.htm">BEA Weblogic</A>
containers are used.
<P>
When using these containers, even if the
Bean has <CODE>finder</CODE> method implementations, they are
ignored and the deployment descriptor settings are consulted instead.
</FONT>
<PRE>
//Declare method in Home interface
public Enumeration findAllMatchingItems(
String searchString)
throws FinderException, RemoteException;
</PRE>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<A NAME="dd"></A>
<H3>AuctionItemBean Deployment Descriptor</H3>
<P>
When a Bean's <CODE>finder</CODE> method is called, the container
consults the deployment descriptor for that Bean to find out
what data the <CODE>finder</CODE> method needs to retrieve from
the underlying database table. The container passes this information
to the Enterprise JavaBeans server, which does the actual retrieval.
<P>
The deployment descriptor for <CODE>AuctionItemBean</CODE>
provides <CODE>finderDescriptors</CODE> for all <CODE>finder</CODE>
methods declared in the <CODE>AuctionItemHome</CODE> interface.
The <CODE>finderDescriptor</CODE> for the
<CODE>findAllMatchingItems</CODE> method maps the search string
to the <CODE>summary</CODE> field in the underlying
<CODE>AuctionItems</CODE> database table.
This tells the Enterprise JavaBeans server to retrieve the
data for all table rows with a summary field that matches
the text in the search string.
</FONT>
<PRE>
(finderDescriptors
"findAllItems()" "(= 1 1)"
"findAllNewItems(java.sql.Date newtoday)"
"(= startdate $newtoday)"
"findAllClosedItems(java.sql.Date closedtoday)"
"(= enddate $closedtoday)"
"findAllMatchingItems(String searchString)"
"(like summary $searchString)"
); end finderDescriptors
</PRE>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<P ALIGN="RIGHT">
<FONT SIZE="-1">[<A HREF="#top">TOP</A>]</FONT>
</FONT>
</TD>
</TR>
</TABLE>
<!-- ================ -->
<!-- End Main Content -->
<!-- ================ -->
</TD>
</TR>
</TABLE>
<!-- Copyright Insert -->
<BR CLEAR="ALL">
<FORM ACTION="/cgi-bin/search.cgi" METHOD="POST">
<TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="5">
<TR>
<TD VALIGN="TOP">
<P ALIGN=CENTER>
<FONT SIZE="-1" COLOR="#999999" FACE="Verdana, Arial, Helvetica, sans-serif">
[ This page was updated: <!-- new date --> 13-Oct-99 ]</font></P>
</TD>
</TR>
<TR>
<TD BGCOLOR="#CCCCCC">
<IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
</TR>
<TR>
<TD>
<CENTER>
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
<A HREF="http://java.sun.com/products/">Products & APIs</A> |
<A HREF="/developer/index.html">Developer Connection</A> |
<A HREF="/developer/infodocs/index.shtml">Docs & Training</A> |
<A HREF="/developer/support/index.html">Online Support</A><BR>
<A HREF="/developer/community/index.html">Community Discussion</A> |
<A HREF="http://java.sun.com/industry/">Industry News</A> |
<A HREF="http://java.sun.com/solutions">Solutions Marketplace</A> |
<A HREF="http://java.sun.com/casestudies">Case Studies</A>
</FONT>
</CENTER>
</TD>
</TR>
<TR>
<TD BGCOLOR="#CCCCCC">
<IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
<A HREF="http://java.sun.com/docs/glossary.html">Glossary</A> -
<A HREF="http://java.sun.com/applets/">Applets</A> -
<A HREF="http://java.sun.com/docs/books/tutorial/">Tutorial</A> -
<A HREF="http://java.sun.com/jobs/">Employment</A> -
<A HREF="http://java.sun.com/nav/business/">Business & Licensing</A> -
<A HREF="http://java.sun.com/javastore/">Java Store</A> -
<A HREF="http://java.sun.com/casestudies/">Java in the Real World</A>
</FONT>
</TD>
</TR>
<TR>
<TD>
<CENTER>
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
<a href="/siteinfo/faq.html">FAQ</a> |
<a href="/feedback/index.html">Feedback</a> |
<a href="http://www.dynamicdiagrams.net/mapa/cgi-bin/help.tcl?db=javasoft&dest=http://java.sun.com/">Map</a> |
<A HREF="http://java.sun.com/a-z/index.html">A-Z Index</A>
</FONT>
</CENTER>
</TD>
</TR>
<TR>
<TD>
<TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="0">
<TR>
<TD WIDTH="50%">
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
For more information on Java technology<BR>
and other software from Sun Microsystems, call:<BR>
</FONT>
<FONT SIZE="-1" FACE="Verdana, Arial, Helvetica, sans-serif">
(800) 786-7638<BR></FONT>
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
Outside the U.S. and Canada, dial your country's
<A HREF="http://www.att.com/business_traveler/attdirecttollfree/">AT&T Direct Access Number</A> first.<BR>
</FONT>
</TD>
<TD ALIGN="RIGHT" WIDTH="50%">
<A HREF="http://www.sun.com"><IMG SRC="/images/lgsun.gif" width="64" height="30" border="0" ALT="Sun Microsystems, Inc."></A><BR>
<FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
Copyright © 1995-99
<A HREF="http://www.sun.com">Sun Microsystems, Inc.</A><BR>
All Rights Reserved.
<a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>.
<A HREF="http://www.sun.com/privacy/">Privacy Policy</A>.
</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
<!-- End Copyright Insert -->
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -