﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-小丐的blog</title><link>http://www.blogjava.net/qzb2006e/</link><description>Java</description><language>zh-cn</language><lastBuildDate>Tue, 21 Apr 2026 17:41:48 GMT</lastBuildDate><pubDate>Tue, 21 Apr 2026 17:41:48 GMT</pubDate><ttl>60</ttl><item><title>在页面中直接显示EJB集合</title><link>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69504.html</link><dc:creator>littlegai</dc:creator><author>littlegai</author><pubDate>Wed, 13 Sep 2006 15:33:00 GMT</pubDate><guid>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69504.html</guid><wfw:comment>http://www.blogjava.net/qzb2006e/comments/69504.html</wfw:comment><comments>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69504.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qzb2006e/comments/commentRss/69504.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qzb2006e/services/trackbacks/69504.html</trackback:ping><description><![CDATA[
		<p>建立一个Entity Bean，选择Sqlserver2000中Northwind下Shippers表进行映射。按照向导建立完毕EJB以后，新添一个findAll方法获取所有对象集合。在Web程序中新建一个EJB Control。最后像下面这样为JSP添加标签即可：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000">Generated by WebLogic Workshop</span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ page </span>
				<span style="COLOR: #ff0000">language</span>
				<span style="COLOR: #0000ff">="java"</span>
				<span style="COLOR: #ff0000"> contentType</span>
				<span style="COLOR: #0000ff">="text/html;charset=UTF-8"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-databinding.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui-data"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-html.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-template.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui-template"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:html</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">head</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">title</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">Web Application Page</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">title</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">head</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">body</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">p</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        New Web Application Page<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">p</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:declareControl </span>
				<span style="COLOR: #ff0000">controlId</span>
				<span style="COLOR: #0000ff">="ShipperControl"</span>
				<span style="COLOR: #ff0000"> type</span>
				<span style="COLOR: #0000ff">="Controls.ShippersBeanControl"</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">netui-data:declareControl</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:callControl </span>
				<span style="COLOR: #ff0000">controlId</span>
				<span style="COLOR: #0000ff">="ShipperControl"</span>
				<span style="COLOR: #ff0000"> method</span>
				<span style="COLOR: #0000ff">="findAll"</span>
				<span style="COLOR: #ff0000"> resultId</span>
				<span style="COLOR: #0000ff">="shippers"</span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeater </span>
				<span style="COLOR: #ff0000">dataSource</span>
				<span style="COLOR: #0000ff">="{pageContext.shippers}"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterHeader</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">table</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">th</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">Shippers</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">th</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterHeader</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterItem</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:label </span>
				<span style="COLOR: #ff0000">value</span>
				<span style="COLOR: #0000ff">="{container.item.companyName}"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:label </span>
				<span style="COLOR: #ff0000">value</span>
				<span style="COLOR: #0000ff">="{container.item.phone}"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterItem</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterFooter</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">table</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterFooter</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeater</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">body</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui:html</span>
				<span style="COLOR: #0000ff">&gt;</span>
		</div>
		<p> </p>
		<p>其中：<br />netui-data:declareControl用来申明一个控件。controlId作为后面的标签进行调用的标识。type为所建立的EJB Control的类型。<br />netui-data:callControl用来指明调用控件中的哪一个方法。resultId为返回结果的标识。<br />定义了这两个标签之后，建立netui-data:repeater标签即可。其中DataSouce中的pageContext是指当前页，而shippers就是前面声明的返回值。<br />container.item.companyName对应了EJB Control中的getCompanyName方法。phone对应了EJB Control中的getPhone方法。</p>
<img src ="http://www.blogjava.net/qzb2006e/aggbug/69504.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qzb2006e/" target="_blank">littlegai</a> 2006-09-13 23:33 <a href="http://www.blogjava.net/qzb2006e/archive/2006/09/13/69504.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>EJB调用EJB</title><link>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69500.html</link><dc:creator>littlegai</dc:creator><author>littlegai</author><pubDate>Wed, 13 Sep 2006 15:19:00 GMT</pubDate><guid>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69500.html</guid><wfw:comment>http://www.blogjava.net/qzb2006e/comments/69500.html</wfw:comment><comments>http://www.blogjava.net/qzb2006e/archive/2006/09/13/69500.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qzb2006e/comments/commentRss/69500.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qzb2006e/services/trackbacks/69500.html</trackback:ping><description><![CDATA[
		<p>1.新建一个CMP的Entity Bean。新的Entity Bean被映射到Sql Server 2000的Northwind Databse的Region表。在按照创建向导完成该Entity Bean的建立以后，可以得到如下所示的代码：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> RegionEJB;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.Collection;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.ejb.CreateException;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> weblogic.ejb.GenericEntityBean;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_124_817_Open_Image" onclick="this.style.display='none'; Codehighlighter1_124_817_Open_Text.style.display='none'; Codehighlighter1_124_817_Closed_Image.style.display='inline'; Codehighlighter1_124_817_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_124_817_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_124_817_Closed_Text.style.display='none'; Codehighlighter1_124_817_Open_Image.style.display='inline'; Codehighlighter1_124_817_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_124_817_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
				<span id="Codehighlighter1_124_817_Open_Text">
						<span style="COLOR: #008000">/**</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * @ejbgen:entity<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *   ejb-name = "RegionBean"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *   data-source-name = "NorthwindDataSource"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *   table-name = "Region"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *   prim-key-class = "java.lang.Integer"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * @ejbgen:jndi-name remote="ejb.RegionBeanRemoteHome"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *   local = "ejb.RegionBeanHome"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * @ejbgen:file-generation local-class = "true" local-class-name = "Region" local-home = "true" local-home-name = "RegionHome" remote-class="true" remote-class-name = "RegionRemote" remote-home="true" remote-home-name = "RegionRemoteHome" value-class = "false" value-class-name = "RegionValue" pk-class = "true"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from RegionBean as o" generate-on="Local" signature="Collection findAll()"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> </span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">abstract</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> RegionBean <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">extends</span>
				<span style="COLOR: #000000"> GenericEntityBean<br /><img id="Codehighlighter1_882_1580_Open_Image" onclick="this.style.display='none'; Codehighlighter1_882_1580_Open_Text.style.display='none'; Codehighlighter1_882_1580_Closed_Image.style.display='inline'; Codehighlighter1_882_1580_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_882_1580_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_882_1580_Closed_Text.style.display='none'; Codehighlighter1_882_1580_Open_Image.style.display='inline'; Codehighlighter1_882_1580_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_882_1580_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_882_1580_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> java.lang.Integer ejbCreate(Integer RegionID)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">throws</span>
						<span style="COLOR: #000000"> CreateException<br /><img id="Codehighlighter1_969_1018_Open_Image" onclick="this.style.display='none'; Codehighlighter1_969_1018_Open_Text.style.display='none'; Codehighlighter1_969_1018_Closed_Image.style.display='inline'; Codehighlighter1_969_1018_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_969_1018_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_969_1018_Closed_Text.style.display='none'; Codehighlighter1_969_1018_Open_Image.style.display='inline'; Codehighlighter1_969_1018_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_969_1018_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_969_1018_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    setRegionID(RegionID);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">null</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />  }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> ejbPostCreate(Integer RegionID) <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">throws</span>
						<span style="COLOR: #000000"> CreateException<br /><img id="Codehighlighter1_1099_1100_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1099_1100_Open_Text.style.display='none'; Codehighlighter1_1099_1100_Closed_Image.style.display='inline'; Codehighlighter1_1099_1100_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1099_1100_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1099_1100_Closed_Text.style.display='none'; Codehighlighter1_1099_1100_Open_Image.style.display='inline'; Codehighlighter1_1099_1100_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_1099_1100_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1099_1100_Open_Text">
								<span style="COLOR: #000000">{}</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img id="Codehighlighter1_1106_1210_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1106_1210_Open_Text.style.display='none'; Codehighlighter1_1106_1210_Closed_Image.style.display='inline'; Codehighlighter1_1106_1210_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1106_1210_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1106_1210_Closed_Text.style.display='none'; Codehighlighter1_1106_1210_Open_Image.style.display='inline'; Codehighlighter1_1106_1210_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_1106_1210_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_1106_1210_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:cmp-field column = "RegionID"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   *  primkey-field="true"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:local-method<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />   </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">abstract</span>
						<span style="COLOR: #000000"> Integer getRegionID();<br /><img id="Codehighlighter1_1255_1289_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1255_1289_Open_Text.style.display='none'; Codehighlighter1_1255_1289_Closed_Image.style.display='inline'; Codehighlighter1_1255_1289_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1255_1289_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1255_1289_Closed_Text.style.display='none'; Codehighlighter1_1255_1289_Open_Image.style.display='inline'; Codehighlighter1_1255_1289_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_1255_1289_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_1255_1289_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:local-method<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />   </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">abstract</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> setRegionID(Integer val);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  <br /><img id="Codehighlighter1_1345_1431_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1345_1431_Open_Text.style.display='none'; Codehighlighter1_1345_1431_Closed_Image.style.display='inline'; Codehighlighter1_1345_1431_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1345_1431_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1345_1431_Closed_Text.style.display='none'; Codehighlighter1_1345_1431_Open_Image.style.display='inline'; Codehighlighter1_1345_1431_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_1345_1431_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_1345_1431_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:cmp-field column = "RegionDescription"<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:local-method<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />   </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">abstract</span>
						<span style="COLOR: #000000"> String getRegionDescription();<br /><img id="Codehighlighter1_1484_1518_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1484_1518_Open_Text.style.display='none'; Codehighlighter1_1484_1518_Closed_Image.style.display='inline'; Codehighlighter1_1484_1518_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1484_1518_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1484_1518_Closed_Text.style.display='none'; Codehighlighter1_1484_1518_Open_Image.style.display='inline'; Codehighlighter1_1484_1518_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span id="Codehighlighter1_1484_1518_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_1484_1518_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   * @ejbgen:local-method<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />   </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">abstract</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> setRegionDescription(String val);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>上面的代码中已经手动添加了一个叫做findAll的方法，该方法可以得到RegionBean的集合。<br />2.现在建立一个Session Bean。通过这个Session Bean调用RegionBean的findAll方法，并将之保存到一个数组中。代码如下：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> RegionEJB;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.Serializable;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.rmi.RemoteException;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.Collection;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.Iterator;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.ejb.</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> weblogic.ejb.</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.naming.Context;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.naming.InitialContext;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.ejb.SessionContext;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.ejb.SessionBean;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> javax.ejb.CreateException;<br /><br /></span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br /> * @ejbgen:session type="Stateless"<br /> *   ejb-name = "RegionView"<br /> *<br /> * @ejbgen:jndi-name local="ejb.RegionViewLocalHome"<br /> *   remote = "ejb.RegionViewRemoteHome"<br /> *<br /> * @ejbgen:file-generation remote-class = "true" remote-class-name = "RegionViewRemote" remote-home = "true" remote-home-name = "RegionViewHome" local-class="true" local-class-name = "RegionViewLocal" local-home="true" local-home-name = "RegionViewLocalHome"<br /> * @ejbgen:ejb-local-ref type="Entity" name="ejb/Region" link="RegionBean" jndi-name="ejb.RegionBeanHome" local="Region" home="RegionHome" <br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> RegionView<br />  </span>
				<span style="COLOR: #0000ff">extends</span>
				<span style="COLOR: #000000"> GenericSessionBean<br />  </span>
				<span style="COLOR: #0000ff">implements</span>
				<span style="COLOR: #000000"> SessionBean<br />{<br />    SessionContext sessionContext;<br />    Context context;<br />    RegionHome regionHome;<br />  </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> ejbCreate() </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> CreateException {<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> Your code here</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">  }<br />  </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> setSessionContext(SessionContext sessionContext)<br />  {<br />    </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.sessionContext</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">sessionContext;<br />    </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000">
						<br />    {<br />        initRegionHome();<br />    }<br />    </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000">(Exception ex)<br />    {<br />        </span>
				<span style="COLOR: #0000ff">throw</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> EJBException(ex.getMessage());<br />    }<br />  }<br />  </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> initRegionHome() </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> Exception<br />  {<br />    </span>
				<span style="COLOR: #0000ff">final</span>
				<span style="COLOR: #000000"> String ENTITY_NAME</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">java:comp/env/ejb/Region</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.context</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> InitialContext();<br />    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">regionHome)<br />    {<br />        </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000">
						<br />        {<br />            Object obj</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">context.lookup(ENTITY_NAME);<br />            regionHome</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">(RegionHome)obj;<br />        }<br />        </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000">(Exception ex)<br />        {<br />            </span>
				<span style="COLOR: #0000ff">throw</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> EJBException(ex.getMessage());<br />        }<br />    }<br />  }<br />  </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />   * @ejbgen:local-method<br />   </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />  </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> addRegion(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> id,String desc) </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> Exception<br />  {<br />    </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000">
						<br />    {<br />        Region region</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">regionHome.create(</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Integer(id));<br />        region.setRegionDescription(desc);<br />    }<br />    </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000">(Exception ex)<br />    {<br />        </span>
				<span style="COLOR: #0000ff">throw</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Exception(ex.getMessage());<br />        <br />    }<br />    <br />  }<br />  </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />   * @ejbgen:local-method<br />   </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />  </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> Object[] getAllRegionView() </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> Exception<br />  {<br />    </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000">
						<br />        {<br />           Collection collection</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">regionHome.findAll();<br />           </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> size</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">collection.size();<br />           </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(size</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">)<br />            </span>
				<span style="COLOR: #0000ff">throw</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Exception(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Null Ejb Object Found!!</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />           RegionInfo[] regionInfo</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> RegionInfo[collection.size()];<br />           Iterator iter</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">collection.iterator();<br />           </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> regionIndex</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br />           </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000">(iter.hasNext())<br />           {<br />               RegionEJB.Region ejb</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">(RegionEJB.Region)iter.next();<br />               regionInfo[regionIndex]</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> RegionInfo(ejb.getRegionID(),ejb.getRegionDescription());<br />               regionIndex</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">regionIndex</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br />               </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">regionInfo[regionIndex]=new RegionInfo(new Integer(regionIndex),iter.next().getClass().toString());</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">           }<br />           </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> regionInfo;<br />        }<br />        </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000">(Exception e)<br />        {<br />           </span>
				<span style="COLOR: #0000ff">throw</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Exception(e.getMessage());<br />        }<br />    <br />  }<br />   </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> RegionInfo </span>
				<span style="COLOR: #0000ff">implements</span>
				<span style="COLOR: #000000"> Serializable<br />    {<br />        </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> java.lang.Integer regionID;<br />        </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> String regionDescription;<br />        <br />        </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> RegionInfo()<br />        {<br />        }<br />        </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> RegionInfo(java.lang.Integer regionID,String regionDescription)<br />        {<br />            </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.regionID</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">regionID;<br />            </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.regionDescription</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">regionDescription;<br />        }<br />    }<br />}<br /><br /><br /></span>
		</div>
		<p>在注释中用@ejbgen来配置Weblogic Workshop所提供的EJBGenerate工具生成EJB。在上面的代码中，session type是手动添加的。另外为了调用其它的EJB，还要配置ejb-local-ref。因为被发布在同一个服务器中，所以使用本地调用即可。这里提取这段代码来看一下：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> @ejbgen:ejb</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">local</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">ref type</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Entity</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> name</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">ejb/Region</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> link</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">RegionBean</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> jndi</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">name</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">ejb.RegionBeanHome</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> local</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Region</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> home</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">RegionHome</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
		</div>
		<p>因为被调用的对象类型为Entity Bean，所以在type属性中选择Entity。如果被调用对象为Session Bean,则可选择Session。name为对该引用定义指定的名字。link属性填入被引用EJB组件的名称。jndi-name填入被引用EJB的JNDI，local填入本地接口的名称，home填入home接口的名称。填写的时候即可以手动输入，也可以在右侧的property editor中填写。<br />这里调用findAll的方法getAllRegionView前面的注释中需要添加ejbgen:local-method以定义为本地方法，这样ejbgen才会在生成Bean代码的时候找到它。<br />3.在jsp页面中调用这个Session Bean的方法。</p>
		<p>首先添加一个EJB控件来包容该EJB调用。然后再在页面流中实例化一个EJB控件对象。然后为页面流添加一个方法getAllRegion，最后配置一下JSP页面中的netui标签以展现数据。下面是getAllRegion方法：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> Object[] getAllRegion()<br />    {<br />        </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000">
						<br />        {<br />            </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> regionViewCtrl.getAllRegionView();<br />        }<br />        </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000">(Exception ex)<br />        {<br />            </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">;<br />        }<br />    }</span>
		</div>
		<p>下面是JSP页面的内容：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ page </span>
				<span style="COLOR: #ff0000">language</span>
				<span style="COLOR: #0000ff">="java"</span>
				<span style="COLOR: #ff0000"> contentType</span>
				<span style="COLOR: #0000ff">="text/html;charset=UTF-8"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-databinding.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui-data"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-html.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">%@ taglib </span>
				<span style="COLOR: #ff0000">uri</span>
				<span style="COLOR: #0000ff">="netui-tags-template.tld"</span>
				<span style="COLOR: #ff0000"> prefix</span>
				<span style="COLOR: #0000ff">="netui-template"</span>
				<span style="COLOR: #ff0000">%</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:html</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">head</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">title</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            Web Application Page<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">title</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">head</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">body</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">p</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        Hi!You Have Clicked Ok Button!<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">p</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />       </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeater </span>
				<span style="COLOR: #ff0000">dataSource</span>
				<span style="COLOR: #0000ff">="{pageFlow.allRegion}"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterHeader</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">table </span>
				<span style="COLOR: #ff0000">border</span>
				<span style="COLOR: #0000ff">="1"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">b</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">ID</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">b</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;&lt;</span>
				<span style="COLOR: #800000">b</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">Description</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">b</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterHeader</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterItem</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:label </span>
				<span style="COLOR: #ff0000">value</span>
				<span style="COLOR: #0000ff">="{container.item.regionID}"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui:label </span>
				<span style="COLOR: #ff0000">value</span>
				<span style="COLOR: #0000ff">="{container.item.regionDescription}"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">td</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">tr</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterItem</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">netui-data:repeaterFooter</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">table</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeaterFooter</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui-data:repeater</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">body</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">netui:html</span>
				<span style="COLOR: #0000ff">&gt;</span>
		</div>
		<p>
				<br /> </p>
<img src ="http://www.blogjava.net/qzb2006e/aggbug/69500.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qzb2006e/" target="_blank">littlegai</a> 2006-09-13 23:19 <a href="http://www.blogjava.net/qzb2006e/archive/2006/09/13/69500.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>