使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx

上传人:b****6 文档编号:21829580 上传时间:2023-02-01 格式:DOCX 页数:14 大小:300.20KB
下载 相关 举报
使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx_第1页
第1页 / 共14页
使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx_第2页
第2页 / 共14页
使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx_第3页
第3页 / 共14页
使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx_第4页
第4页 / 共14页
使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx

《使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx(14页珍藏版)》请在冰豆网上搜索。

使用WebCenter和JDeveloper开发PortletWord文档下载推荐.docx

EvolvingGridManagement'

DavidBaum'

catalog3'

July-August2005'

TuningUndoTablespace'

KimberlyFloss'

二、建立一个JSFPortlet

在这部分,我们将使用Oracle数据库作为数据源建立一个JSF应用程序,然后将这个JSF程序转换为portlet。

这个JSF应用程序由一个使用SQL查询动态产生的DataTable组成。

首先,在JDeveloper中选择File->

New建立一个JDeveloper工程,然后使用在NewGallerywizard中的General->

Application。

指定一个工程名后,选择WebCenter应用程序作为应用程序模板。

在建立完WebCenter工程后,所有的数据和资源都会在如图1的ApplicationsNavigator中显示出来。

这个应用程序由用于建立portlet的Portlets工程和用于建立JSF视图页的ViewController工程组成,portlets可以在这个工程中被嵌入。

图1.WebCenter工程效果图

在这里我们将使用WebCenter框架中的JSF-Portlet桥来编写JSF应用程序,这就意味着JSF应用程序将是基于JSR168portlets的。

我们可以选择Tools->

Project项来加入JSF-Portlet桥所需的库。

我们还需要加入ADFFaces运行时库和OracleJDBC库。

接下来,我们将使用如下的步骤在WebCenter框架中实现和发布JSF应用程序:

1.在"

ApplicationsNavigator"

中选择Portlets工程,并选择File->

New

2.在新Gallery模板中,选择Categories中的WebTier->

JSF,然后选择JSFJSP项,单击OK。

3.当JSFJSP模板启动后,单击Next,选择J2EE1.4作为Web应用程序的版本,然后再次单击Next。

4.指定input.jsp作为文件名后,单击Next。

5.在一个新的管制Bean中选择AutomaticallyExposeUIComponents,并指定PortletBean作为类名,然后单击Next。

6.选择默认的tag库,JSFCore1.0和JSFHTML1.0,然后单击Next。

7.选择默认的HTML选择,然后单击Next。

8.单击Finish按钮后,在Portlets工程中建立一个JSF页(也就是input.jsp)和一个faces-config.xml发布文件。

下面我们来建立一个portlet。

一个portlet需要一个portlet.xml文件,因此,我们按如下步骤在Portlets工程中加入一个portlet.xml文件。

1.选择File->

2.在NewGallerywizard中,从Catagories菜单中选择FilterBy->

AllTechnologiesandselectGeneral->

DeploymentDescriptors

3.选择portlet.xml,并单击OK

图2显示了我们的JSFportlet应用程序的目录结构。

图2JSFPortlet应用程序的目录结构

现在,我们准备在应用程序中加入JSF组件。

在ComponentPalette中,选择JSFHTML,并将以下内容加入到input.jsp页中:

1.一个输出标签

2.一个输入文本字段

3.一个命令按钮

4.一个数据表

在JSF页中的文本字段指定一个SQL查询。

当一个用户单击建立数据表命令时,PortletBean.java类中的commandButton_action方法被调用,然后一个数据表被动态地创建。

PortletBean.java中的部分代码如下:

packageportlet.backing;

......

publicclassPortletBean{

........

publicStringcommandButton_action(){

ResultSetrs=null;

try{

InitialContextinitialContext=newInitialContext();

javax.sql.DataSourceds=

(javax.sql.DataSource)initialContext.lookup("

java:

comp/env/jdbc/OracleDBConnectionDS"

java.sql.Connectionconnection=ds.getConnection();

Statementstmt=

connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

rs=stmt.executeQuery((String)inputText1.getValue());

dataTable1.setBorder(5);

dataTable1.setCellpadding("

1"

dataTable1.setVar("

catalog"

HtmlOutputTextheaderComponent1=newHtmlOutputText();

headerComponent1.setId("

headerComponent1"

headerComponent1.setValue("

CatalogId"

column1.setHeader(headerComponent1);

HtmlOutputTextheaderComponent2=newHtmlOutputText();

headerComponent2.setId("

headerComponent2"

headerComponent2.setValue("

Journal"

column2.setHeader(headerComponent2);

HtmlOutputTextheaderComponent3=newHtmlOutputText();

headerComponent3.setId("

headerComponent3"

headerComponent3.setValue("

Publisher"

column3.setHeader(headerComponent3);

HtmlOutputTextheaderComponent4=newHtmlOutputText();

headerComponent4.setId("

headerComponent4"

headerComponent4.setValue("

Edition"

column4.setHeader(headerComponent4);

HtmlOutputTextheaderComponent5=newHtmlOutputText();

headerComponent5.setId("

headerComponent5"

headerComponent5.setValue("

Title"

column5.setHeader(headerComponent5);

HtmlOutputTextheaderComponent6=newHtmlOutputText();

headerComponent6.setId("

headerComponent6"

headerComponent6.setValue("

Author"

column6.setHeader(headerComponent6);

HtmlOutputTextcolumn1Text=newHtmlOutputText();

column1Text.setId("

htmlOutputText1"

ValueBindingvb=

FacesContext.getCurrentInstance().getApplication().createValueBinding("

#{catalog.ID}"

column1Text.setValueBinding("

value"

vb);

column1.getChildren().add(column1Text);

HtmlOutputTextcolumn2Text=newHtmlOutputText();

column2Text.setId("

htmlOutputText2"

vb=

#{catalog.JOURNAL}"

column2Text.setValueBinding("

column2.getChildren().add(column2Text);

HtmlOutputTextcolumn3Text=newHtmlOutputText();

column3Text.setId("

htmlOutputText3"

#{catalog.PUBLISHER}"

column3Text.setValueBinding("

column3.getChildren().add(column3Text);

HtmlOutputTextcolumn4Text=newHtmlOutputText();

column4Text.setId("

htmlOutputText4"

#{catalog.EDITION}"

column4Text.setValueBinding("

column4.getChildren().add(column4Text);

HtmlOutputTextcolumn5Text=newHtmlOutputText();

column5Text.setId("

htmlOutputText5"

#{catalog.TITLE}"

column5Text.setValueBinding("

column5.getChildren().add(column5Text);

HtmlOutputTextcolumn6Text=newHtmlOutputText();

column6Text.setId("

htmlOutputText6"

vb=FacesContext.getCurrentInstance().getApplication().createValueBinding("

#{catalog.AUTHOR}"

column6Text.setValueBinding("

column6.getChildren().add(column6Text);

ResultSetDataModeldataModel=newResultSetDataModel();

dataModel.setWrappedData(rs);

dataTable1.setValue(dataModel);

}catch(SQLExceptione){

System.out.println(e.getMessage());

}catch(javax.naming.NamingExceptione){

}

returnnull;

}

在输入文本框中被指定的SQL查询在commandButton_action方法中运行,并为数据表产生一个结果集。

下面将显示input.jsp的全部代码:

<

%@pagecontentType="

text/html;

charset=windows-1252"

%>

%@tagliburi="

prefix="

f"

h"

f:

view>

<

h:

formid="

form1"

>

outputLabelvalue="

SQL"

binding="

#{backing_input.outputLabel1}"

id="

outputLabel1"

/>

inputTextid="

inputText1"

#{backing_input.inputText1}"

commandButtonid="

commandButton1"

value="

CreateDataTable"

#{backing_mandButton1}"

action="

#{backing_mandButton_action}"

dataTableid="

dataTable1"

rows="

5"

#{backing_input.dataTable1}"

columnid="

column1"

#{backing_input.column1}"

column2"

#{backing_input.column2}"

column3"

#{backing_input.column3}"

column4"

#{backing_input.column4}"

column5"

#{backing_input.column5}"

column6"

#{backing_input.column6}"

/h:

dataTable>

form>

/f:

接下来我们应为每一个动态JSP组件指定一个ID。

如果我们不这么做,JSF框架将在portlet标记中产生重复的ID,当portlet运行时会产生以下错误:

DuplicatecomponentID…foundinview.

AninternalerrorhasoccurredinmethodgetMarkup()

编辑web.xml和portlet.xml文件,在web.xml中加入以下context-param结点:

context-param>

param-name>

javax.faces.application.CONFIG_FILES<

/param-name>

param-value>

/WEB-INF/faces-config.xml,/WEB-INF/portlet.xml<

/param-value>

/context-param>

javax.faces.STATE_SAVING_METHOD<

server<

在web.xml中加入以下ADFFacesfilter过滤器:

filter>

filter-name>

adfFaces<

/filter-name>

filter-class>

oracle.adf.view.faces.webapp.AdfFacesFilter<

/filter-class>

/filter>

按着如下步骤编辑portlet.xml文件:

1.使用<

portlet>

/portlet>

结点指定一个portlet。

2.指定一个portlet类oracle.portlet.server.bridges.jsf.FacesPortlet

3.为默认页指定一个结点<

init-param/>

,当portlet运行时这个页被显示。

代码如下:

init-param>

name>

DefaultPage.view<

/name>

value>

/input.jsp<

/value>

/init-param>

4.为BridgeLifecycleListenerslistener类指定一个<

结点,代码如下:

BridgeLifecycleListeners<

oracle.portlet.server.bridges.jsf.adf.ADFFacesBridgeLifecycleListener

下面将显示portlet.xml文件的完整内容:

?

xmlversion="

1.0"

encoding="

UTF-8"

standalone="

yes"

portlet-appversion="

xsi:

schemaLocation="

xmlns:

xsi="

http:

//www.w3.org/2001/XMLSchema-instance"

xmlns="

portlet-name>

DataTablePortlet<

/portlet-name>

display-name>

DataTablePortlet<

/display-name>

portlet-class>

oracle.portlet.server.bridges.jsf.FacesPortlet<

/portlet-class>

oracle.portlet.server.bridges.jsf.adf.ADFFacesBridgeLifecycleListener

supports>

mime-type>

text/html<

/mime-type>

portlet-mode>

VIEW<

/portlet-mode>

/supports>

sup

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1