JavaServer Faces Tooling User GuideWord格式.docx
- 文档编号:8658751
- 上传时间:2023-05-12
- 格式:DOCX
- 页数:16
- 大小:484.64KB
JavaServer Faces Tooling User GuideWord格式.docx
《JavaServer Faces Tooling User GuideWord格式.docx》由会员分享,可在线阅读,更多相关《JavaServer Faces Tooling User GuideWord格式.docx(16页珍藏版)》请在冰点文库上搜索。
CreateaNewDynamicWebApplicationwiththenameof
JSFFaceletsTutorial.Setthetargetruntimetothe
ApacheTomcat6.0
Inthe
Configuration
section,clickonthe
Modify
buttonandselectthe
“JavaServerFaces2.0”
facet.SkipthenextpaneltogettotheJSFCapabilitiespage.
OntheJSFCapabilitiespage,fromthedrop-downfortheTypeoftheJSFLibrary,select
UserLibrary.
Clickonthe
Downloadlibrary
icon.TheDownloadLibrarydialogisdisplayedwiththelistofprovidersfortheJSFimplementationJARfiles.SelecttheJSF2.0(Mojarra)library.Click
Next.Acceptthelicenseandhit
Finish
ThetooldownloadstheJARfiles,createsaJDTUserLibraryandaddsittothecurrentproject.Selectthecheckboxforthenewlibraryifitisnotselected.Next,selectthe
Managelibraries
icon.
buttontocreatetheJavaServerFacesApplication.YoumaybeaskedtochoosetheJ2EEperspectiveuponcompletion.ClickOK.
YourJSFapplicationhasbeencreated.
CreateFaceletstemplatepages
YouwillnowcreateaFaceletstemplatepage.Createafoldercalled
templates
underthe
WEB-INF
folder.UsetheHTMLwizardtocreateatemplatepagecalled,
BasicTemplate.xhtml
underthisfolder.Right-clickonthe
template
folder,select
New»
HTML
tolaunchtheHTMLwizard.IntheSelectTemplatespageofthewizard,selectthe
NewFaceletTemplate
template.ClickFinish.
Editthetemplatefilefollowingtheinstructionsinthetemplate.Youwillcreateandincludetheheaderandfootertemplates.Yourfinaltemplatefileshouldbeasshownbelow.
BasicTemplate.xhtml
<
!
DOCTYPEhtmlPUBLIC"
-//W3C//DTDXHTML1.0Transitional//EN"
"
http:
//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
htmlxmlns="
//www.w3.org/1999/xhtml"
xmlns:
ui="
head>
<
title>
ui:
insertname="
title"
FaceletsTutorial<
/ui:
insert>
/title>
/head>
body>
divid="
header"
includesrc="
/WEB-INF/templates/header.xhtml"
/>
/div>
content"
footer"
/WEB-INF/templates/footer.xhtml"
/body>
/html>
Createtheheaderandfootertemplatesunderthe
folderusingthe
NewHTMLWizard
asdescribedabove.IntheSelectTemplatepageofthewizard,choosethecorrespondingtemplatefiles,
NewFaceletHeader
and
NewFaceletFooter.Makechangestothetemplatesasshownbelow.
CreateaJSFPage
CreateaJSFpagewithFaceletstagsthatwillusethetemplatecreatedinthepreviousstep.UsetheHTMLPagewizardtocreateapagecalled
login.xhtml
intheWebContentfolderofthenewapplication.IntheSelectTemplatespageofthewizard,selectthe
NewFaceletCompositionPage
template.ClickFinish.
login.xhtml
h="
f="
compositiontemplate="
"
definename="
Addyourheaderhereordeletetousethedefault
define>
Addyourcontenthereordeletetousethedefault
Addyourfooterhereordeletetousethedefault
composition>
FaceletsTagAttributeValidationandContentAssist
TheJSFToolsprojectaddssupportforvalidatingattributesofFaceletstagsandalsoprovidesContentAssistsonthem.Notethewarningonthe
attributeofthe
tag.
Positionthecursorinbetweenthedouble-quotesofthe
attributeandhit
Ctrl+spacebar
togetContentAssist.Youshouldseeapop-uplistingthedirectoriesunderthe
WebContent
folder.Select/WEB-INF/templates/BasicTemplate.xhtml
CompletetheJSFpage
Deletethe
tagsfortheheaderandfooter.Thepagewillgettheheaderandfooterfromthetemplate.Addthetagsforthelogininthe
content
sectionasshownbelow.PleasenotethatthecurrentreleaseoftheJSFToolsprojectdoesn'
tsupportthevisualrenderingofanXHTMLpageintheJSFWebPageEditor.However,alltheproductivityfeaturesavailableintheSourcePageoftheWebPageEditorforeditingaJSPpageareavailableintheHTMLSourceEditorforbuildingaJSFFaceletspageinXHTML.
/WEB-INF/templates/BasicTemplate.xhtml"
h:
form>
panelGridcolumns="
2"
outputTextvalue="
Name"
/h:
outputText>
inputTextvalue="
#{loginBean.name}"
inputText>
Password"
inputSecretvalue="
#{loginBean.password}"
inputSecret>
panelGrid>
commandButtonvalue="
Login"
action="
login"
commandButton>
ConfiguretheManagedBean
IntheProjectExplorer,expandthenode,JSFFaceletsTutorial->
WebContent.Double-clickon
faces-config.xml
.ThiswilllaunchtheFacesConfigurationeditor.Selectthe
ManagedBean
tab.
Add
button.ThiswilllaunchtheNewManagedBeanwizard.Selecttheoption,
CreateanewJavaclass.Inthenextwizardpanel,enterthepackageas,
com.tutorial
andtheNameoftheclassas
LoginBean
.ClicktheFinishbutton.
ThiswillcreatetheJavaclassandregisteritasamanagedbean.SavetheFacesConfigurationeditor.ToedittheJavaclass,clickonthehyperlink,
ManagedBeanclass
intheManagedbeanpageasshowninthefigurebelow.ThiswilllaunchtheJavaeditor.
EdittheJavaclass,
com.tutorial.LoginBean.Addthefollowingcodeandsave.
LoginBean.java
/**
*LoginBean.java
*
*/
packagecom.tutorial;
publicclassLoginBean
{
privateStringname;
privateStringpassword;
publicStringgetName()
{
returnname;
}
publicvoidsetName(finalStringname)
this.name=name;
publicStringgetPassword()
returnpassword;
publicvoidsetPassword(finalStringpassword)
this.password=password;
}
AddAnotherPage
CreateanewHTMLpagewelcome.xhtmlinWebContentwiththefollowingcontent:
welcome.xhtml
outputLabelvalue="
Welcome#{loginBean.name}"
outputLabel>
SetupPageNavigationRules
Double-clickonfaces-config.xmltoopentheFacesConfigurationEditor.Clickonthe
NavigationRule
tab.Nowdragthelogin.xhtmlandwelcome.xhtmlfilesfromProjectExplorerontotheNavigationRulegridasshown.
ClickontheLinktoolinthepaletteontheright.Nowdrawanarrowfromlogin.xhtmltowelcome.xhtmlasshown.
Now,clickonthearrowandopenthe
Properties
view.Clickonthebuttonwiththeellipsesnexttothe“FromOutcome”field
Select“Login”inthisdialog.ClickOK
Ournavigationruleisnowsetup.
RuntheJSFFaceletsPage
Youwillnowexecutethe
pageagainsttheApacheTomcatserver.Choose
RunonServer
usingthecontextmenuwhileselectingthe
pageinthenavigator.ChooseyourApacheTomcatserverandsetitupasrequiredifyouhadnotalreadydoneso.ClickFinish.YoushouldseefromtheConsoleviewthattheTomcatserverstartsandthenyoushouldseetheexecutingloginpageappearintheWebBrowserlikebelow.
Congratulations!
YouhavecreatedandexecutedyourfirstJSFFaceletsapplication.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JavaServer Faces Tooling User Guide
![提示](https://static.bingdoc.com/images/bang_tan.gif)