J2EE Trinidad

  • View
    249

  • Download
    2

Embed Size (px)

Text of J2EE Trinidad

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

vogella.de

Home Blog

Twitter

Java

Eclipse Google Web Technology AlgorithmsJSF and Apache M yFace s Support and Consulting f or JSF Trainings in German and Englishwww.irian.at

Java Re porting Tool 100% Java - Seamless Integration. Dow nload New Trial Version Today!www.Jinfonet.com

ApacheMyfacesTrinidadwithEclipse-TutorialLarsVogelVersion0.2 Copyright2008LarsVogel 22.11.2008RevisionHistoryRevision0.1 FirstDRAFT Revision0.2 Firstworkingversion 22.11.2008 LarsVogel 12.11.2008 LarsVogel

ApacheMyFacesTrinidad ThisarticledescribeshowtousesetupApacheMyFacesTrinidadandhowtousesomeofthe additionalcomponents(comparedwiththeJSFstandard>. TableofContents 1.ApacheMyFacesTrinidad-Overview 2.ExampleJSFapplicationwithApacheMyFacesTrinidad 2.1.Installation 2.2.CreateProject 2.3.Configuration 2.4.DomainModel 2.5.ManagedBeans 2.6.CreateTestJsp 2.7.Runyourapplication 3.UsingthegraphsfromTrinidad 3.1.DomainModel 3.2.ManagedBeans 3.3.CreateJSP 3.4.Runyourapplication

1 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

4.Thankyou 5.QuestionsandDiscussion 6.LinksandLiterature 6.1.TutorialsandWebsites 6.2.JSFcomponentlibraries

1.ApacheMyFacesTrinidad-OverviewTheJSFstandardimplementations(MojarraorApacheMyFaces)provideasetofcomponents. ApacheMyFacesTrinidadprovidesextendedcomponentsviatheMyFacesproject. TouseApacheMyFacesTrinidadyouneed: ThestandardJSFlibraries ApacheMyFacesTrinidadlibraries Therightsettingsinweb.xml,faces-config.xml Anadditionalfile"trinidad-config.xml"whichcontainssomeTrinidadspecificsettings.

YoufindniceexamplesintheTrindadexamplewarfileswhichcanbedownloaded fromhttp://myfaces.apache.org/trinidad/download.html.Youcanalsousethese examplestocheckthenecessarysettingsinweb.xml,faces-config.xmlandtrinidadconfig.xmlApplication Load Te s ting Analysis & Testing of Applications of Load Capacity & Perf ormance.www.Webmetrics.com

2.ExampleJSFapplicationwithApacheMyFacesTrinidadThefollowingisanexplanationonhowtocreateasimpleJSFapplicationwithApacheMyFaces Trinidad.ForageneralintroductionofJSFwithEclipsepleaseseeJSF-JavaServerFaceswith EclipseTutorial.

2.1.InstallationTousethecomponentsfromApacheMyFacesTrinidadyouneedinadditiontotheinstalled components.

2 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

ThestandardJSFlibrary-SeeJSFintroductionforinstructiononhowtoinstallanduse standardJSF. Thetrinidaddistribution-fromhttp://myfaces.apache.org/trinidad/download.html ExtractthelibrariesandaddthemtoyouravailablelibrariesforJSF.Usethename"Trinidad"The followingtwojarmustbeadded.Theflag"IsJSFimplementation"shouldnotbeset. trinidad-api-YOUR_VERSION_NUMBER.jar trinidad-impl-YOUR_VERSION_NUMBER.jar SeeJSFintroductionfordetailsonhowtoaddaJSFlibrarytoEclipsed.

3 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

2.2.CreateProjectCreateinEclipsethedynamicwebprojectwiththename"de.vogella.jsf.trinidad.first".Makesureyou selecttheJavaServerFacesv1.2Projectconfiguration.AddtheTrinidadlibrarytotheproject.Again seeJSFintroductionfordetailsonhowtodothis.

4 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

2.3.ConfigurationYouneedtrinidad-config.xmlconfiguredinyourWEB-INFdirectory.

5 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

true default simple

Youneedtomaintaintherendererkitinyourfaces-config.xml.

org.apache.myfaces.trinidad.core

Adjusttheweb.xmltothefollowing

6 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

de.vogella.jsf.trinidad.first index.html index.htm index.jsp default.html default.htm default.jsp

FacesServlet javax.faces.webapp.FacesServlet 1 FacesServlet /faces/* *.jsf javax.faces.STATE_SAVING_METHOD client org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE false org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION true org.apache.myfaces.trinidad.CHANGE_PERSISTENCE session

7 of 16

trinidad org.apache.myfaces.trinidad.webapp.TrinidadFilter

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

2.4.DomainModelCreatethepackagede.vogella.jsf.trinidad.firstandthetwofollowingclasses.Wewilllaterusethese classesforanexampletoshowtheTrinidadtablecomponent.

packagede.vogella.jsf.trinidad.first; publicclassPerson{ privateStringfirstName; privateStringlastName; publicPerson(StringfirstName,StringlastName){ this.firstName=firstName; this.lastName=lastName; } publicStringgetFirstName(){ returnfirstName; } publicvoidsetFirstName(StringfirstName){ this.firstName=firstName; } publicStringgetLastName(){ returnlastName; } publicvoidsetLastName(StringlastName){ this.lastName=lastName; } }

8 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

packagede.vogella.jsf.trinidad.first; importjava.util.ArrayList; importjava.util.List; publicclassTableValues{ privateListpersons; publicTableValues(){ //ImagineaverycomplexDBaccesshere persons=newArrayList(); Personp=newPerson("Lars","Vogel"); persons.add(p); p=newPerson("Jim","Knopf"); persons.add(p); p=newPerson("Tim","Tester"); persons.add(p); p=newPerson("Tim2","Tester"); persons.add(p); p=newPerson("Tim3","Tester"); persons.add(p); p=newPerson("Tim4","Tester"); persons.add(p); p=newPerson("Tim5","Tester"); persons.add(p); } publicListgetPersons(){ returnpersons; } }

2.5.ManagedBeansConfigureTableValuestobeasessionscopemanagedbean.AgainseeJSFintroductionfordetails onhowtodothis.

2.6.CreateTestJspCreatethefollowingJSP"TestPage.jsp".

9 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

ThispagedemonstratesafewofthefeaturesofTrinidad. inputTexthasaattributeforalabelandahotkey(alt+hotkey)-labelAndAccessKey requiredfieldsaremarkedwith"*" panelFormLayout-usedtolineupelements selectManyShuttle-Coolselectionbox panelHeader-Panelwhichallowstoplaceaheadertextinsideit10 of 16 08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

table-Cooltablewhichallowssortingandconfigurationofthenumberofdisplayedrows. inputNumberSpinbox-Spinboxtoselectanumber

2.7.RunyourapplicationTheresultshouldlooklikethefollowing.

3.UsingthegraphsfromTrinidadThefollowingshowshowtousethegraphsprovidedbyTrinidad.Itisbasedontheprevious example.

3.1.DomainModelCreateinthepackagede.vogella.jsf.trinidad.firsttheclass"MyChartModel".

11 of 16

08/05/2010 08:17 AM

Apache Myfaces T rinidad with Eclipse - T utorial

http://www.vogella.de/articles/ApacheMyFaces/artic...

packagede.vogella.jsf.trinidad.first; importjava.util.ArrayList; importjava.util.List; importorg.apache.myfaces.trinidad.model.ChartModel; publicclassMyChartModelextendsChartModel{ //Howmanychartsareyougoingtohave @Override publicListgetGroupLabels(){ ListgroupLabels=newArrayList(); groupLabels.add("Java"); groupLabels.add("Linux"); groupLabels.add(".NET"); returngroupLabels; } //Howmanyparts(dataareas)perchart @Override publicListgetSeriesLabels(){ ListseriesLabels=newArrayList(); seriesLabels.add("Loveit"); seriesLabels.add("Hateit"); returnseriesLabels; } @Override publicListgetYValues(){ ListchartValues=newArrayList(); //Fillthegroups for(inti=0;i