├── .gitignore ├── JavaServerFaces_01HelloWorld ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── common │ │ ├── HelloBean.java │ │ ├── HelloBeanForApplicationScoped.java │ │ ├── HelloBeanForNoneScoped.java │ │ ├── HelloBeanForRequestScoped.java │ │ ├── HelloBeanForSessionScoped.java │ │ └── HelloBeanForViewScoped.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── hello.xhtml │ ├── helloForApplicationScope.xhtml │ ├── helloForNoneScoped.xhtml │ ├── helloForRequestScoped.xhtml │ ├── helloForSessionScoped.xhtml │ ├── helloForViewScoped.xhtml │ ├── helloScopesIndex.xhtml │ ├── welcome.xhtml │ ├── welcomeForApplicationScoped.xhtml │ ├── welcomeForNoneScoped.xhtml │ ├── welcomeForRequestScoped.xhtml │ ├── welcomeForSessionScoped.xhtml │ └── welcomeForViewScoped.xhtml ├── JavaServerFaces_02HelloWorldAjax ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── common │ │ └── HelloBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── helloAjax.xhtml ├── JavaServerFaces_03ManagedBeans ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── common │ │ └── HelloBean.java │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ ├── manage-beans.xml │ └── web.xml │ └── helloAjax.xhtml ├── JavaServerFaces_04InjectManagedBeans ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── common │ │ ├── HelloBean.java │ │ └── MessageBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── helloAjax.xhtml ├── JavaServerFaces_05ImplicitNavigation ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── controller │ │ └── PageController.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── page1.xhtml │ └── page2.xhtml ├── JavaServerFaces_06ConditionalNavigation ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── controller │ │ └── PaymentController.java │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ ├── ordermore.xhtml │ ├── payment.xhtml │ ├── register.xhtml │ └── start.xhtml ├── JavaServerFaces_07FormActionNavigation ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── controller │ │ └── PageController.java │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ ├── page1.xhtml │ ├── page2.xhtml │ └── start.xhtml ├── JavaServerFaces_08PageRedirection ├── pom.xml └── src │ └── main │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ ├── page1.xhtml │ └── start.xhtml ├── JavaServerFaces_09ResourceBundles ├── pom.xml └── src │ └── main │ ├── resources │ └── com.xxy │ │ └── messages.properties │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ └── hello.xhtml ├── JavaServerFaces_10Internationlization ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── LanguageBean.java │ ├── resources │ └── com.xxy │ │ ├── welcome.properties │ │ └── welcome_zh_CN.properties │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ └── default.xhtml ├── JavaServerFaces_11TextBox ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── user.xhtml ├── JavaServerFaces_12Password ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── user.xhtml ├── JavaServerFaces_13TextArea ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── user.xhtml ├── JavaServerFaces_14HiddenValue ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── demo.xhtml ├── JavaServerFaces_15Checkboxes ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── result.xhtml ├── JavaServerFaces_16RadioButtons ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── result.xhtml ├── JavaServerFaces_17Listbox ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── result.xhtml ├── JavaServerFaces_18MultiSelectListbox ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── result.xhtml ├── JavaServerFaces_19DropdownBox ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── result.xhtml ├── JavaServerFaces_20MultipleSelectDropdownBox └── pom.xml ├── JavaServerFaces_21OutputText ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── demo.xhtml ├── JavaServerFaces_22OutputFormat ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── form │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── demo.xhtml ├── JavaServerFaces_23GraphicImage ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── resources │ └── images │ └── sofa.png ├── JavaServerFaces_24OutputStyleSheet ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── resources │ └── css │ └── style.css ├── JavaServerFaces_25OutputScript ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── resources │ └── js │ └── common.js ├── JavaServerFaces_26ButtonCommanButton ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ └── login.xhtml ├── JavaServerFaces_27LinkCommandLinkOutputlink ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── demo.xhtml │ ├── login.xhtml │ └── resources │ └── images │ └── sofa.png ├── JavaServerFaces_28PanelGrid ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── DummyBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_29Message ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_30Param ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_31Attribute ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_32SetpropertyActionListener ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_33DataTable ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ ├── resources │ └── com │ │ └── mkyong │ │ └── order.properties │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_34DataTableAdd ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_35DataTableUpdate ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_36DataTableDelete ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_37DataTableRowNumbers ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── PersonBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_38RepeatTag ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_39DataTableSorting ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── OrderBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_40DataTableSortingDataModel ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── OrderBean.java │ │ └── SortableDataModel.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_41FaceletsTemplate ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ ├── page1.xhtml │ ├── resources │ └── css │ │ └── common-style.css │ └── template │ └── common │ ├── commonContent.xhtml │ ├── commonFooter.xhtml │ ├── commonHeader.xhtml │ └── commonLayout.xhtml ├── JavaServerFaces_42ParameterInTemplate ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ ├── page1.xhtml │ ├── resources │ └── css │ │ └── common-style.css │ └── template │ └── common │ ├── commonContent.xhtml │ ├── commonFooter.xhtml │ ├── commonHeader.xhtml │ └── commonLayout.xhtml ├── JavaServerFaces_43CustomTag ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ ├── mkyong.taglib.xml │ ├── tags │ │ └── com │ │ │ └── mkyong │ │ │ └── button.xhtml │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── common-style.css ├── JavaServerFaces_44RemoveTag ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── MessageBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── default.xhtml ├── JavaServerFaces_45ConverNumber ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── ReceiptBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── receipt.xhtml ├── JavaServerFaces_46ConverDateTime ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── ReceiptBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── receipt.xhtml ├── JavaServerFaces_47ValidateLength ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_48ValidateLongRange ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_49ValidateDoubleRange ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_50ValidateRequired ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_51ValidateRegex ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_52CustomValidation ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ ├── resources │ └── com │ │ └── mkyong │ │ └── MyMessage.properties │ └── webapp │ ├── WEB-INF │ ├── faces-config.xml │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_53CustomConverter ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── URLBookmark.java │ │ ├── URLConverter.java │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_54CustomValidator ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── EmailValidator.java │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_55ValidatorMultipleComponents ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── PasswordValidator.java │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ ├── default1.xhtml │ └── thanks.xhtml ├── JavaServerFaces_56CompositeComponents ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ ├── resources │ └── mkyong │ │ └── register.xhtml │ └── result.xhtml ├── JavaServerFaces_57ValueChangeListener ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── CountryBean.java │ │ └── CountryValueListener.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── default.xhtml ├── JavaServerFaces_58ActionListener ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── NormalActionListener.java │ │ └── NormalBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── result.xhtml ├── JavaServerFaces_59PostConstructApplicationEvent ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── FacesAppListener.java │ └── webapp │ └── WEB-INF │ ├── faces-config.xml │ └── web.xml ├── JavaServerFaces_60PreRenderViewEvent ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── access-denied.xhtml │ └── default.xhtml ├── JavaServerFaces_61ValidatorMultipleComponents ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── PasswordValidator.java │ │ └── UserBean.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ ├── default1.xhtml │ └── thanks.xhtml ├── JavaServerFaces_62JDBCIntegration ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── CustomerBean.java │ │ └── customer │ │ └── model │ │ └── Customer.java │ └── webapp │ ├── META-INF │ └── context.xml │ ├── WEB-INF │ └── web.xml │ ├── default.xhtml │ └── resources │ └── css │ └── table-style.css ├── JavaServerFaces_63Spring ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── UserBean.java │ │ └── user │ │ └── bo │ │ ├── UserBo.java │ │ └── impl │ │ └── UserBoImpl.java │ └── webapp │ ├── WEB-INF │ ├── applicationContext.xml │ ├── faces-config.xml │ └── web.xml │ └── default.xhtml ├── JavaServerFaces_64SpringHibernateIntegration ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xxy │ │ ├── CustomerBean.java │ │ └── customer │ │ ├── bo │ │ ├── CustomerBo.java │ │ └── impl │ │ │ └── CustomerBoImpl.java │ │ ├── dao │ │ ├── CustomerDao.java │ │ └── impl │ │ │ └── CustomerDaoImpl.java │ │ └── model │ │ └── Customer.java │ └── webapp │ ├── WEB-INF │ ├── applicationContext.xml │ ├── faces-config.xml │ └── web.xml │ ├── default.xhtml │ └── resources │ ├── com │ └── xxy │ │ └── customer │ │ ├── hibernate │ │ └── Customer.hbm.xml │ │ └── spring │ │ └── CustomerBean.xml │ ├── config │ ├── database │ │ └── db.properties │ └── spring │ │ └── beans │ │ ├── DataSource.xml │ │ └── HibernateSessionFactory.xml │ └── css │ └── table-style.css └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | koss-root.ids 2 | *.iml 3 | *.ipr 4 | *.ids 5 | *.iws 6 | .idea 7 | */*.log 8 | buildNumber.properties 9 | */target/ 10 | /sh/ 11 | /esb/* 12 | /document 13 | */null 14 | *.DS_Store 15 | *.settings 16 | *.project 17 | *.classpath 18 | *.db 19 | *.tmp 20 | beans.xml 21 | 22 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | JavaServerFaces 8 | JavaServerFaces-parent 9 | 1.0-SNAPSHOT 10 | 11 | 12 | JavaServerFaces_01HelloWorld 13 | war 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class HelloBean implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private String name; 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBeanForApplicationScoped.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ApplicationScoped; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.ViewScoped; 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @ApplicationScoped 10 | public class HelloBeanForApplicationScoped implements Serializable { 11 | 12 | public int commitTimes =0; 13 | private String name; 14 | 15 | public String doSomething(){ 16 | commitTimes++; 17 | return "welcomeForApplicationScoped"; 18 | } 19 | 20 | public int getCommitTimes() { 21 | return commitTimes; 22 | } 23 | 24 | public void setCommitTimes(int commitTimes) { 25 | this.commitTimes = commitTimes; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBeanForNoneScoped.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.NoneScoped; 5 | import javax.faces.bean.SessionScoped; 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @NoneScoped 10 | public class HelloBeanForNoneScoped implements Serializable { 11 | 12 | public int commitTimes =0; 13 | private String name; 14 | 15 | public String doSomething(){ 16 | commitTimes++; 17 | return "welcomeForNoneScoped"; 18 | } 19 | 20 | public int getCommitTimes() { 21 | return commitTimes; 22 | } 23 | 24 | public void setCommitTimes(int commitTimes) { 25 | this.commitTimes = commitTimes; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBeanForRequestScoped.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.RequestScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean 8 | @RequestScoped 9 | public class HelloBeanForRequestScoped implements Serializable { 10 | 11 | public int commitTimes =0; 12 | private String name; 13 | 14 | public String doSomething(){ 15 | commitTimes++; 16 | return "welcomeForRequestScoped"; 17 | } 18 | 19 | public int getCommitTimes() { 20 | return commitTimes; 21 | } 22 | 23 | public void setCommitTimes(int commitTimes) { 24 | this.commitTimes = commitTimes; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBeanForSessionScoped.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import javax.faces.bean.ViewScoped; 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class HelloBeanForSessionScoped implements Serializable { 11 | 12 | public int commitTimes =0; 13 | private String name; 14 | 15 | public String doSomething(){ 16 | commitTimes++; 17 | return "welcomeForSessionScoped"; 18 | } 19 | 20 | public int getCommitTimes() { 21 | return commitTimes; 22 | } 23 | 24 | public void setCommitTimes(int commitTimes) { 25 | this.commitTimes = commitTimes; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/java/com/xxy/common/HelloBeanForViewScoped.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.ViewScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean 8 | @ViewScoped 9 | public class HelloBeanForViewScoped implements Serializable { 10 | 11 | public int commitTimes =0; 12 | private String name; 13 | 14 | public String toAnotherView(){ 15 | commitTimes++; 16 | return "welcomeForViewScoped"; 17 | } 18 | 19 | public void stayInThisView(){ 20 | commitTimes++; 21 | } 22 | 23 | public String toThisView(){ 24 | commitTimes++; 25 | return "helloForViewScoped"; 26 | } 27 | 28 | public int getCommitTimes() { 29 | return commitTimes; 30 | } 31 | 32 | public void setCommitTimes(int commitTimes) { 33 | this.commitTimes = commitTimes; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/hello.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - hello.xhtml

13 | 14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloForApplicationScope.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloForApplicationScoped.xhtml

13 | 14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloForNoneScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloForNoneScoped.xhtml

13 | 14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloForRequestScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloForRequestScoped.xhtml

13 | 14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloForSessionScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloForSessionScoped.xhtml

13 | 14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloForViewScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloForViewScoped.xhtml

13 | 14 | 15 |

16 | 17 |

18 | 19 |

20 | 21 |

22 | 23 |
24 |
25 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/helloScopesIndex.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - helloScopesIndex.xhtml

13 | 14 | 15 | 16 |

17 |

18 | 19 |

20 |

21 | 22 |

23 |

24 | 25 |

26 |

27 | 28 |
29 |
30 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcome.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcome.xhtml

13 |

Welcome #{helloBean.name}

14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcomeForApplicationScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcomeForApplicationScoped.xhtml

13 |

Welcome #{helloBeanForApplicationScoped.name}, Commit #{helloBeanForApplicationScoped.commitTimes} times.

14 |
15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcomeForNoneScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcomeForNoneScoped.xhtml

13 |

Welcome #{helloBeanForNoneScoped.name}, Commit #{helloBeanForNoneScoped.commitTimes} times.

14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcomeForRequestScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcomeForRequestScoped.xhtml

13 |

Welcome #{helloBeanForRequestScoped.name}, Commit #{helloBeanForRequestScoped.commitTimes} times.

14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcomeForSessionScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcomeForSessionScoped.xhtml

13 |

Welcome #{helloBeanForSessionScoped.name}, Commit #{helloBeanForSessionScoped.commitTimes} times.

14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_01HelloWorld/src/main/webapp/welcomeForViewScoped.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | JSF 2.0 Hello World 10 | 11 | 12 |

JSF 2.0 Hello World Example - welcomeForViewScoped.xhtml

13 |

Welcome #{helloBeanForViewScoped.name}, Commit #{helloBeanForViewScoped.commitTimes} times.

14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_02HelloWorldAjax/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 4.0.0 12 | war 13 | JavaServerFaces_02HelloWorldAjax 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_02HelloWorldAjax/src/main/java/com/xxy/common/HelloBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean 8 | @SessionScoped 9 | public class HelloBean implements Serializable { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | private String name; 14 | private String name2; 15 | 16 | public String getName2() { 17 | return name2; 18 | } 19 | 20 | public void setName2(String name2) { 21 | this.name2 = name2; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /JavaServerFaces_02HelloWorldAjax/src/main/webapp/helloAjax.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 |

JSF 2.0 + Ajax Hello World Example

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

The first input value:

17 |

The second input value:

18 |
19 |
20 | -------------------------------------------------------------------------------- /JavaServerFaces_03ManagedBeans/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | ../JavaServerFaces/pom.xml 10 | 11 | 4.0.0 12 | 13 | JavaServerFaces_03ManagedBeans 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_03ManagedBeans/src/main/java/com/xxy/common/HelloBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.faces.bean.ManagedBean; 6 | import javax.faces.bean.SessionScoped; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class HelloBean implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private String name; 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getSayWelcome(){ 25 | //check if null? 26 | if("".equals(name) || name ==null){ 27 | return ""; 28 | }else{ 29 | return "Ajax message : Welcome " + name; 30 | } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /JavaServerFaces_03ManagedBeans/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_03ManagedBeans/src/main/webapp/WEB-INF/manage-beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | helloBean 10 | com.xxy.common.HelloBean 11 | session 12 | 13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_03ManagedBeans/src/main/webapp/helloAjax.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 |

JSF 2.0 + Ajax Hello World Example

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 |
19 | 20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_04InjectManagedBeans/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_04InjectManagedBeans 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_04InjectManagedBeans/src/main/java/com/xxy/common/HelloBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.faces.bean.ManagedBean; 6 | import javax.faces.bean.ManagedProperty; 7 | import javax.faces.bean.SessionScoped; 8 | 9 | @ManagedBean 10 | @SessionScoped 11 | public class HelloBean implements Serializable { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | @ManagedProperty(value="#{message}") 16 | private MessageBean messageBean; 17 | 18 | public void setMessageBean(MessageBean messageBean) { 19 | this.messageBean = messageBean; 20 | } 21 | 22 | private String name; 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getSayWelcome(){ 33 | //check if null? 34 | if("".equals(name) || name ==null){ 35 | return ""; 36 | }else{ 37 | return messageBean.getSayWelcome() + name; 38 | } 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /JavaServerFaces_04InjectManagedBeans/src/main/java/com/xxy/common/MessageBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.common; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.faces.bean.ManagedBean; 6 | import javax.faces.bean.SessionScoped; 7 | 8 | @ManagedBean(name="message") 9 | @SessionScoped 10 | public class MessageBean implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private String sayWelcome = "Welcome to JSF 2.0"; 15 | 16 | public String getSayWelcome() { 17 | return sayWelcome; 18 | } 19 | 20 | public void setSayWelcome(String sayWelcome) { 21 | this.sayWelcome = sayWelcome; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /JavaServerFaces_04InjectManagedBeans/src/main/webapp/helloAjax.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 |

JSF 2.0 + Ajax Hello World Example

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 |
19 | 20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_05ImplicitNavigation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_05ImplicitNavigation 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_05ImplicitNavigation/src/main/java/com/xxy/controller/PageController.java: -------------------------------------------------------------------------------- 1 | package com.xxy.controller; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class PageController implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public String moveToPage1(){ 15 | return "page1"; 16 | } 17 | 18 | public String moveToPage2(){ 19 | return "page2"; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_05ImplicitNavigation/src/main/webapp/page1.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is page1.xhtml

9 | 10 | 11 | 12 | 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_05ImplicitNavigation/src/main/webapp/page2.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is page2.xhtml

9 | 10 | 11 | 12 | 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_06ConditionalNavigation 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/java/com/xxy/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.xxy.controller; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class PaymentController implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public boolean registerCompleted = true; 15 | public int orderQty = 99; 16 | 17 | public int getOrderQty() { 18 | return orderQty; 19 | } 20 | 21 | public void setOrderQty(int orderQty) { 22 | this.orderQty = orderQty; 23 | } 24 | 25 | public boolean isRegisterCompleted() { 26 | return registerCompleted; 27 | } 28 | 29 | public void setRegisterCompleted(boolean registerCompleted) { 30 | this.registerCompleted = registerCompleted; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | start.xhtml 11 | 12 | payment 13 | #{paymentController.orderQty < 100} 14 | ordermore.xhtml 15 | 16 | 17 | payment 18 | #{paymentController.registerCompleted} 19 | payment.xhtml 20 | 21 | 22 | payment 23 | register.xhtml 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/webapp/ordermore.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is ordermore.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/webapp/payment.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is payment.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/webapp/register.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is resgister.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_06ConditionalNavigation/src/main/webapp/start.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is start.xhtml

9 | 10 | 11 | 12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_07FormActionNavigation 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/src/main/java/com/xxy/controller/PageController.java: -------------------------------------------------------------------------------- 1 | package com.xxy.controller; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | import java.io.Serializable; 7 | 8 | @ManagedBean 9 | @SessionScoped 10 | public class PageController implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public String processPage1(){ 15 | return "success"; 16 | } 17 | 18 | public String processPage2(){ 19 | return "success"; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | start.xhtml 11 | 12 | #{pageController.processPage1} 13 | success 14 | page1.xhtml 15 | 16 | 17 | #{pageController.processPage2} 18 | success 19 | page2.xhtml 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/src/main/webapp/page1.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is page1.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/src/main/webapp/page2.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is page2.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_07FormActionNavigation/src/main/webapp/start.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is start.xhtml

9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /JavaServerFaces_08PageRedirection/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_08PageRedirection 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_08PageRedirection/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | -------------------------------------------------------------------------------- /JavaServerFaces_08PageRedirection/src/main/webapp/page1.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is page1.xhtml

9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_08PageRedirection/src/main/webapp/start.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

This is start.xhtml

9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /JavaServerFaces_09ResourceBundles/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_09ResourceBundles 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_09ResourceBundles/src/main/resources/com.xxy/messages.properties: -------------------------------------------------------------------------------- 1 | message = This is "message" 2 | message.test1 = This is "message.test1" 3 | message.test2 = This is "

message.test3

" 4 | message.test3 = This is "<h2>message.test4</h2>" 5 | message.param1 = This is "message.param1" - {0} 6 | message.param2 = This is "message.param2" - {0} and {1} -------------------------------------------------------------------------------- /JavaServerFaces_09ResourceBundles/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | com.xxy.messages 11 | msg 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_09ResourceBundles/src/main/webapp/hello.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 11 | 12 | 13 |

JSF 2.0 and Resource Bundles Examples

14 |
    15 | 16 |
  1. 17 | 18 |
  2. 19 | 20 |
  3. 21 |
  4. 22 | 23 |
  5. 24 |
  6. 25 | 26 |
  7. 27 | 28 | 29 | 30 |
  8. 31 |
  9. 32 | 33 | 34 | 35 | 36 |
  10. 37 |
38 |
39 | -------------------------------------------------------------------------------- /JavaServerFaces_10Internationlization/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_10Internationlization 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_10Internationlization/src/main/resources/com.xxy/welcome.properties: -------------------------------------------------------------------------------- 1 | welcome.jsf = Happy learning JSF 2.0 -------------------------------------------------------------------------------- /JavaServerFaces_10Internationlization/src/main/resources/com.xxy/welcome_zh_CN.properties: -------------------------------------------------------------------------------- 1 | welcome.jsf = \u5feb\u4e50\u5b66\u4e60 JSF 2.0 -------------------------------------------------------------------------------- /JavaServerFaces_10Internationlization/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | en 11 | 12 | 13 | com.xxy.welcome 14 | msg 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_10Internationlization/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 |

JSF 2 internationalization example

13 | 14 | 15 | 16 |

17 | 18 |

19 | 20 | 21 | 22 | Language : 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 | 34 |
35 | -------------------------------------------------------------------------------- /JavaServerFaces_11TextBox/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_11TextBox 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_11TextBox/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean 8 | @SessionScoped 9 | public class UserBean implements Serializable { 10 | 11 | private String userName; 12 | 13 | public String getUserName() { 14 | return userName; 15 | } 16 | 17 | public void setUserName(String userName) { 18 | this.userName = userName; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_11TextBox/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaServerFaces_11TextBox 4 | 5 | javax.faces.PROJECT_STAGE 6 | Development 7 | 8 | 9 | faces/demo.xhtml 10 | 11 | 12 | Faces Servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | Faces Servlet 18 | /faces/* 19 | 20 | 21 | Faces Servlet 22 | *.jsf 23 | 24 | 25 | Faces Servlet 26 | *.faces 27 | 28 | 29 | Faces Servlet 30 | *.xhtml 31 | 32 | -------------------------------------------------------------------------------- /JavaServerFaces_11TextBox/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 textbox example

9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /JavaServerFaces_11TextBox/src/main/webapp/user.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 textbox example

9 | 10 | Submitted value : 11 | 12 |
13 | -------------------------------------------------------------------------------- /JavaServerFaces_12Password/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_12Password 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_12Password/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean 8 | @SessionScoped 9 | public class UserBean implements Serializable { 10 | 11 | private String password; 12 | 13 | public String getPassword() { 14 | return password; 15 | } 16 | 17 | public void setPassword(String password) { 18 | this.password = password; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_12Password/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 password example

9 | 10 | 11 | Password : 12 | 13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /JavaServerFaces_12Password/src/main/webapp/user.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 password example

9 | 10 | Password : 11 | 12 |
13 | -------------------------------------------------------------------------------- /JavaServerFaces_13TextArea/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_13TextArea 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_13TextArea/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable { 10 | 11 | private String address; 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_13TextArea/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 textarea example

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
Address :
17 | 18 |
19 | 20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_13TextArea/src/main/webapp/user.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2 textarea example

9 | 10 | Address : 11 | 12 |
13 | -------------------------------------------------------------------------------- /JavaServerFaces_14HiddenValue/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_14HiddenValue 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_14HiddenValue/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import java.io.Serializable; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable { 10 | 11 | String answer = "I'm Hidden value!"; 12 | 13 | public String getAnswer() { 14 | return answer; 15 | } 16 | 17 | public void setAnswer(String answer) { 18 | this.answer = answer; 19 | } 20 | 21 | 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_14HiddenValue/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 17 | 18 | 19 |

JSF 2 hidden value example

20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | -------------------------------------------------------------------------------- /JavaServerFaces_15Checkboxes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_15Checkboxes 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_15Checkboxes/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 checkboxes example

11 | 12 |

result.xhtml

13 | 14 |
    15 |
  1. user.rememberMe : #{user.rememberMe}
  2. 16 |
  3. user.favNumber1 : #{user.favNumber1InString}
  4. 17 |
  5. user.favNumber2 : #{user.favNumber2InString}
  6. 18 |
  7. user.favNumber3 : #{user.favNumber3InString}
  8. 19 |
  9. user.favNumber4 : #{user.favNumber4InString}
  10. 20 |
21 |
22 | 23 | -------------------------------------------------------------------------------- /JavaServerFaces_16RadioButtons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_16RadioButtons 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_16RadioButtons/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 radio button example

11 | 12 |

result.xhtml

13 | 14 |
    15 |
  1. user.favColor1 : #{user.favColor1}
  2. 16 |
  3. user.favColor2 : #{user.favColor2}
  4. 17 |
  5. user.favColor3 : #{user.favColor3}
  6. 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /JavaServerFaces_17Listbox/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_17Listbox 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_17Listbox/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaServerFaces_17Listbox 4 | 5 | javax.faces.PROJECT_STAGE 6 | Development 7 | 8 | 9 | faces/demo.xhtml 10 | 11 | 12 | Faces Servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | Faces Servlet 18 | /faces/* 19 | 20 | 21 | Faces Servlet 22 | *.jsf 23 | 24 | 25 | Faces Servlet 26 | *.faces 27 | 28 | 29 | Faces Servlet 30 | *.xhtml 31 | 32 | -------------------------------------------------------------------------------- /JavaServerFaces_17Listbox/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 listbox example

11 | 12 |

result.xhtml

13 | 14 |
    15 |
  1. user.favYear1 : #{user.favYear1}
  2. 16 |
  3. user.favYear2 : #{user.favYear2}
  4. 17 |
  5. user.favYear3 : #{user.favYear3}
  6. 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /JavaServerFaces_18MultiSelectListbox/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_18MultiSelectListbox 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_18MultiSelectListbox/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 multi-select listbox example

11 | 12 |

result.xhtml

13 | 14 |
    15 |
  1. user.favFood1 : #{user.favFood1InString}
  2. 16 |
  3. user.favFood2 : #{user.favFood2InString}
  4. 17 |
  5. user.favFood3 : #{user.favFood3InString}
  6. 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /JavaServerFaces_19DropdownBox/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_19DropdownBox 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_19DropdownBox/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 dropdown box example

11 | 12 |

result.xhtml

13 | 14 |
    15 |
  1. user.favCoffee1 : #{user.favCoffee1}
  2. 16 |
  3. user.favCoffee2 : #{user.favCoffee2}
  4. 17 |
  5. user.favCoffee3 : #{user.favCoffee3}
  6. 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /JavaServerFaces_20MultipleSelectDropdownBox/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_20MultipleSelectDropdownBox 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_21OutputText/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_21OutputText 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_21OutputText/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String text = "This is Text!"; 11 | public String htmlInput = ""; 12 | 13 | public String getText() { 14 | return text; 15 | } 16 | public void setText(String text) { 17 | this.text = text; 18 | } 19 | public String getHtmlInput() { 20 | return htmlInput; 21 | } 22 | public void setHtmlInput(String htmlInput) { 23 | this.htmlInput = htmlInput; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /JavaServerFaces_21OutputText/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 |

JSF 2.0 h:outputText Example

9 |
    10 |
  1. #{user.text}
  2. 11 | 12 |
  3. 13 | 14 |
  4. 15 | 16 |
  5. 17 | 18 |
  6. 19 |
20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_22OutputFormat/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_22OutputFormat 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_22OutputFormat/src/main/java/com/xxy/form/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy.form; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String text = "Hello {0}"; 11 | public String htmlInput = ""; 12 | 13 | public String getText() { 14 | return text; 15 | } 16 | public void setText(String text) { 17 | this.text = text; 18 | } 19 | public String getHtmlInput() { 20 | return htmlInput; 21 | } 22 | public void setHtmlInput(String htmlInput) { 23 | this.htmlInput = htmlInput; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /JavaServerFaces_22OutputFormat/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

JSF 2.0 h:outputFormat Example

11 |
    12 |
  1. 13 | 14 | 15 | 16 | 17 |
  2. 18 |
  3. 19 | 20 | 21 | 22 |
  4. 23 | 24 |
  5. 25 | 26 | 27 | 28 | 29 |
  6. 30 | 31 | 32 |
  7. 33 | 34 | 35 | 36 | 37 |
  8. 38 | 39 |
  9. 40 | 41 | 42 | 43 | 44 |
  10. 45 | 46 | 47 |
48 |
49 | -------------------------------------------------------------------------------- /JavaServerFaces_23GraphicImage/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_23GraphicImage 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_23GraphicImage/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | 11 | } -------------------------------------------------------------------------------- /JavaServerFaces_23GraphicImage/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 graphicImage example

11 | 12 |
    13 |
  1. Normal way -
  2. 14 |
  3. Library way -
  4. 15 |
16 | 17 |
18 | 19 | -------------------------------------------------------------------------------- /JavaServerFaces_23GraphicImage/src/main/webapp/resources/images/sofa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HenryXi/JavaServerFaces/3ed47649f0af39aa07d33da054c2f6865628f10e/JavaServerFaces_23GraphicImage/src/main/webapp/resources/images/sofa.png -------------------------------------------------------------------------------- /JavaServerFaces_24OutputStyleSheet/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_24OutputStyleSheet 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_24OutputStyleSheet/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | 11 | } -------------------------------------------------------------------------------- /JavaServerFaces_24OutputStyleSheet/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 outputStylesheet example

11 | 12 | 13 | 14 |
This is red color
15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /JavaServerFaces_24OutputStyleSheet/src/main/webapp/resources/css/style.css: -------------------------------------------------------------------------------- 1 | .red{ 2 | color:red; 3 | } -------------------------------------------------------------------------------- /JavaServerFaces_25OutputScript/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_25OutputScript 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_25OutputScript/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | 11 | } -------------------------------------------------------------------------------- /JavaServerFaces_25OutputScript/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 outputScript example

11 | 12 | 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_25OutputScript/src/main/webapp/resources/js/common.js: -------------------------------------------------------------------------------- 1 | document.write('Testing'); -------------------------------------------------------------------------------- /JavaServerFaces_26ButtonCommanButton/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_26ButtonCommanButton 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_26ButtonCommanButton/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String goLoginPage(){ 11 | 12 | return "login"; 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /JavaServerFaces_26ButtonCommanButton/src/main/webapp/demo.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 button and commandButton example

11 | 12 | 13 |
    14 |
  1. 15 | 16 |
  2. 17 |
  3. 18 | 19 |
  4. 20 |
  5. 21 | 22 |
  6. 23 |
  7. 24 | 25 |
  8. 26 |
  9. 27 | 28 |
  10. 29 |
  11. 30 | 31 |
  12. 32 |
  13. 33 | 34 |
  14. 35 |
36 |
37 | 38 |
39 | 40 | -------------------------------------------------------------------------------- /JavaServerFaces_26ButtonCommanButton/src/main/webapp/login.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

login.xhtml

11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_27LinkCommandLinkOutputlink/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_27LinkCommandLinkOutputlink 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_27LinkCommandLinkOutputlink/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String goLoginPage(){ 11 | 12 | return "login"; 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /JavaServerFaces_27LinkCommandLinkOutputlink/src/main/webapp/login.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

login.xhtml

11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_27LinkCommandLinkOutputlink/src/main/webapp/resources/images/sofa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HenryXi/JavaServerFaces/3ed47649f0af39aa07d33da054c2f6865628f10e/JavaServerFaces_27LinkCommandLinkOutputlink/src/main/webapp/resources/images/sofa.png -------------------------------------------------------------------------------- /JavaServerFaces_28PanelGrid/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_28PanelGrid 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_28PanelGrid/src/main/java/com/xxy/DummyBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="dummy") 8 | @SessionScoped 9 | public class DummyBean implements Serializable{ 10 | 11 | int number; 12 | 13 | public int getNumber() { 14 | return number; 15 | } 16 | 17 | public void setNumber(int number) { 18 | this.number = number; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_28PanelGrid/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 panelGrid example

12 | 13 | 14 | 15 | 16 | 17 | Enter a number : 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | -------------------------------------------------------------------------------- /JavaServerFaces_28PanelGrid/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 panelGrid example

12 | 13 | Number : 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_29Message/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_29Message 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_29Message/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public String username; 14 | public int age; 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | public void setUsername(String username) { 20 | this.username = username; 21 | } 22 | public int getAge() { 23 | return age; 24 | } 25 | public void setAge(int age) { 26 | this.age = age; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /JavaServerFaces_29Message/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 |

JSF 2 message + messages example

13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | Enter your username : 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | Enter your age : 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 |
48 | -------------------------------------------------------------------------------- /JavaServerFaces_29Message/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 message + messages example

11 | 12 | Username : #{user.username} 13 | 14 |
15 | 16 | Age : #{user.age} 17 | 18 |
19 | -------------------------------------------------------------------------------- /JavaServerFaces_30Param/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_30Param 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_30Param/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.util.Map; 4 | 5 | import javax.faces.bean.ManagedBean; 6 | import javax.faces.bean.SessionScoped; 7 | import javax.faces.context.FacesContext; 8 | 9 | @ManagedBean(name="user") 10 | @SessionScoped 11 | public class UserBean{ 12 | 13 | public String name; 14 | public String country; 15 | 16 | public String outcome(){ 17 | 18 | FacesContext fc = FacesContext.getCurrentInstance(); 19 | this.country = getCountryParam(fc); 20 | 21 | return "result"; 22 | } 23 | 24 | //get value from "f:param" 25 | public String getCountryParam(FacesContext fc){ 26 | 27 | Map params = fc.getExternalContext().getRequestParameterMap(); 28 | return params.get("country"); 29 | 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getCountry() { 41 | return country; 42 | } 43 | 44 | public void setCountry(String country) { 45 | this.country = country; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /JavaServerFaces_30Param/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaServerFaces_30Param 4 | 5 | javax.faces.PROJECT_STAGE 6 | Development 7 | 8 | 9 | faces/default.xhtml 10 | 11 | 12 | Faces Servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | Faces Servlet 18 | /faces/* 19 | 20 | 21 | Faces Servlet 22 | *.jsf 23 | 24 | 25 | Faces Servlet 26 | *.faces 27 | 28 | 29 | Faces Servlet 30 | *.xhtml 31 | 32 | -------------------------------------------------------------------------------- /JavaServerFaces_30Param/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 |

JSF 2 param example

12 | 13 | 14 | 15 | Enter your name : 16 | 17 | 18 |

19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | -------------------------------------------------------------------------------- /JavaServerFaces_30Param/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 |

JSF 2 param example

12 | 13 |

14 | 15 | 16 | 17 | 18 |

19 | 20 |
21 | 22 | -------------------------------------------------------------------------------- /JavaServerFaces_31Attribute/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_31Attribute 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_31Attribute/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import javax.faces.event.ActionEvent; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean{ 10 | 11 | public String nickname; 12 | 13 | //action listener event 14 | public void attrListener(ActionEvent event){ 15 | 16 | nickname = (String)event.getComponent().getAttributes().get("username"); 17 | 18 | } 19 | 20 | public String outcome(){ 21 | return "result"; 22 | } 23 | 24 | public String getNickname() { 25 | return nickname; 26 | } 27 | 28 | 29 | public void setNickname(String nickname) { 30 | this.nickname = nickname; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /JavaServerFaces_31Attribute/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 |

JSF 2 attribute example

12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | -------------------------------------------------------------------------------- /JavaServerFaces_31Attribute/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 attribute example

11 | 12 | #{user.nickname} 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_32SetpropertyActionListener/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_32SetpropertyActionListener 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_32SetpropertyActionListener/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String username; 11 | 12 | public String outcome(){ 13 | return "result"; 14 | } 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | 20 | public void setUsername(String username) { 21 | this.username = username; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /JavaServerFaces_32SetpropertyActionListener/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 |

JSF 2 setPropertyActionListener example

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /JavaServerFaces_32SetpropertyActionListener/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 setPropertyActionListener example

11 | 12 | #{user.username} 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_33DataTable/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_33DataTable 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_33DataTable/src/main/resources/com/mkyong/order.properties: -------------------------------------------------------------------------------- 1 | order.orderNoColumn = Order No 2 | order.productNameColumn = Product Name 3 | order.priceColumn = Price 4 | order.qtyColumn = Quantity 5 | order.dateColumn = Date -------------------------------------------------------------------------------- /JavaServerFaces_33DataTable/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_34DataTableAdd/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_34DataTableAdd 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_34DataTableAdd/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_35DataTableUpdate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_35DataTableUpdate 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_35DataTableUpdate/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_36DataTableDelete/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_36DataTableDelete 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_36DataTableDelete/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_37DataTableRowNumbers/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_37DataTableRowNumbers 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_37DataTableRowNumbers/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .person-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .person-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .person-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .person-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_38RepeatTag/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_38RepeatTag 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_38RepeatTag/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_39DataTableSorting/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_39DataTableSorting 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_39DataTableSorting/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_40DataTableSortingDataModel/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_40DataTableSortingDataModel 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_40DataTableSortingDataModel/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_41FaceletsTemplate 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | //... 12 | 13 | } -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/page1.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 |

This is page1 content

14 |
15 | 16 | 17 |

This is page1 Footer

18 |
19 | 20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/resources/css/common-style.css: -------------------------------------------------------------------------------- 1 | #page{ 2 | width: 800px; 3 | margin: 0 auto; 4 | } 5 | 6 | #header{ 7 | width: 100%; 8 | height:100px; 9 | border: 1px solid #000; 10 | margin-bottom:16px; 11 | } 12 | 13 | #content{ 14 | width: 100%; 15 | height:200px; 16 | margin-right:16px; 17 | margin-bottom:16px; 18 | border: 1px solid #000; 19 | } 20 | 21 | #footer{ 22 | width: 100%; 23 | height:100px; 24 | border: 1px solid #000; 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/template/common/commonContent.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default content

11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/template/common/commonFooter.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default footer

11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/template/common/commonHeader.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default header

11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_41FaceletsTemplate/src/main/webapp/template/common/commonLayout.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 | 34 | 35 |
36 | 37 |
38 | 39 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_42ParameterInTemplate 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | //... 12 | 13 | } -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/page1.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

This is page1 content

15 |
16 | 17 |
18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/resources/css/common-style.css: -------------------------------------------------------------------------------- 1 | #page{ 2 | width: 800px; 3 | margin: 0 auto; 4 | } 5 | 6 | #header{ 7 | width: 100%; 8 | height:150px; 9 | border: 1px solid #000; 10 | margin-bottom:16px; 11 | } 12 | 13 | #content{ 14 | width: 100%; 15 | height:200px; 16 | margin-right:16px; 17 | margin-bottom:16px; 18 | border: 1px solid #000; 19 | } 20 | 21 | #footer{ 22 | width: 100%; 23 | height:100px; 24 | border: 1px solid #000; 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/template/common/commonContent.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default content

11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/template/common/commonFooter.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default footer

11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/template/common/commonHeader.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

This is default header

11 |

Tag Line : #{tagLine}

12 | 13 |
14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /JavaServerFaces_42ParameterInTemplate/src/main/webapp/template/common/commonLayout.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 24 | 25 |
26 | Current File : #{curFileName} 27 | 28 | 29 | 30 |
31 | 32 | 37 | 38 |
39 | 40 |
41 | 42 | -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_43CustomTag 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | //... 12 | 13 | } -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/src/main/webapp/WEB-INF/mkyong.taglib.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | http://mkyong.com/facelets 7 | 8 | button 9 | tags/com/mkyong/button.xhtml 10 | 11 | -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/src/main/webapp/WEB-INF/tags/com/mkyong/button.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 |

Custome Tags in JSF 2.0

11 | 12 | 15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /JavaServerFaces_43CustomTag/src/main/webapp/resources/css/common-style.css: -------------------------------------------------------------------------------- 1 | #page{ 2 | width: 800px; 3 | margin: 0 auto; 4 | } 5 | 6 | #header{ 7 | width: 100%; 8 | height:150px; 9 | border: 1px solid #000; 10 | margin-bottom:16px; 11 | } 12 | 13 | #content{ 14 | width: 100%; 15 | height:200px; 16 | margin-right:16px; 17 | margin-bottom:16px; 18 | border: 1px solid #000; 19 | } 20 | 21 | #footer{ 22 | width: 100%; 23 | height:100px; 24 | border: 1px solid #000; 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_44RemoveTag/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_44RemoveTag 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_44RemoveTag/src/main/java/com/xxy/MessageBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="msg") 8 | @SessionScoped 9 | public class MessageBean implements Serializable{ 10 | 11 | String buttonLabel = "Submit"; 12 | 13 | public String getButtonLabel() { 14 | return buttonLabel; 15 | } 16 | 17 | public void setButtonLabel(String buttonLabel) { 18 | this.buttonLabel = buttonLabel; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_44RemoveTag/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 |

How to uses comments in JSF 2.0

10 | 11 | 12 | 14 | 15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /JavaServerFaces_45ConverNumber/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_45ConverNumber 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_45ConverNumber/src/main/java/com/xxy/ReceiptBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="receipt") 8 | @SessionScoped 9 | public class ReceiptBean implements Serializable{ 10 | 11 | double amount; 12 | 13 | public double getAmount() { 14 | return amount; 15 | } 16 | 17 | public void setAmount(double amount) { 18 | this.amount = amount; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_45ConverNumber/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 convertNumber example

12 | 13 | 14 | 15 | 16 | 17 | Amount : 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | -------------------------------------------------------------------------------- /JavaServerFaces_46ConverDateTime/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_46ConverDateTime 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_46ConverDateTime/src/main/java/com/xxy/ReceiptBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | import javax.faces.bean.ManagedBean; 7 | import javax.faces.bean.SessionScoped; 8 | 9 | @ManagedBean(name="receipt") 10 | @SessionScoped 11 | public class ReceiptBean implements Serializable{ 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | Date date; 16 | 17 | public Date getDate() { 18 | return date; 19 | } 20 | 21 | public void setDate(Date date) { 22 | this.date = date; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_46ConverDateTime/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 convertDate example

12 | 13 | 14 | 15 | 16 | 17 | Receipt Date : 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | -------------------------------------------------------------------------------- /JavaServerFaces_46ConverDateTime/src/main/webapp/receipt.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 convertDate example

12 | 13 | Receipt Date : 14 | 15 | 16 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /JavaServerFaces_47ValidateLength/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_47ValidateLength 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_47ValidateLength/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | String username; 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | public void setUsername(String username) { 18 | this.username = username; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_47ValidateLength/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateLength example

12 | 13 | 14 | 15 | 16 | 17 | Enter UserName : 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | -------------------------------------------------------------------------------- /JavaServerFaces_47ValidateLength/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateLength example

12 | 13 | UserName : 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_48ValidateLongRange/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_48ValidateLongRange 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_48ValidateLongRange/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | int age; 12 | 13 | public int getAge() { 14 | return age; 15 | } 16 | 17 | public void setAge(int age) { 18 | this.age = age; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_48ValidateLongRange/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateLongRange example

12 | 13 | 14 | 15 | 16 | 17 | Enter your age : 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | -------------------------------------------------------------------------------- /JavaServerFaces_48ValidateLongRange/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateLongRange example

12 | 13 | Age : 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_49ValidateDoubleRange/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_49ValidateDoubleRange 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_49ValidateDoubleRange/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | double salary; 12 | 13 | public double getSalary() { 14 | return salary; 15 | } 16 | 17 | public void setSalary(double salary) { 18 | this.salary = salary; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_49ValidateDoubleRange/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

JSF 2 validateDoubleRange example

11 | 12 | 13 | 14 | 15 | 16 | Enter your salary : 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | -------------------------------------------------------------------------------- /JavaServerFaces_49ValidateDoubleRange/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateDoubleRange example

12 | 13 | Salary : 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /JavaServerFaces_50ValidateRequired/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_50ValidateRequired 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_50ValidateRequired/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | String password; 12 | String confPassword; 13 | 14 | public String getPassword() { 15 | return password; 16 | } 17 | public void setPassword(String password) { 18 | this.password = password; 19 | } 20 | public String getConfPassword() { 21 | return confPassword; 22 | } 23 | public void setConfPassword(String confPassword) { 24 | this.confPassword = confPassword; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /JavaServerFaces_50ValidateRequired/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

JSF 2 validateRequired example

11 | 12 | 13 | 14 | 15 | 16 | Enter your password : 17 | 18 | 21 | 22 | 23 | 24 | Enter your password again : 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | -------------------------------------------------------------------------------- /JavaServerFaces_50ValidateRequired/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateRequired example

12 | 13 | 14 | 15 | Password : 16 | 17 | 18 | Confirm Password : 19 | 20 | 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /JavaServerFaces_51ValidateRegex/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_51ValidateRegex 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_51ValidateRegex/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | String password; 12 | 13 | public String getPassword() { 14 | return password; 15 | } 16 | 17 | public void setPassword(String password) { 18 | this.password = password; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_51ValidateRegex/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

JSF 2 validateRegex example

11 | 12 | 13 | 14 | 15 | 16 | Enter your password : 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /JavaServerFaces_51ValidateRegex/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

JSF 2 validateRegex example

12 | 13 | 14 | 15 | Password : 16 | 17 | 18 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_52CustomValidation 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Date; 5 | 6 | import javax.faces.bean.ManagedBean; 7 | import javax.faces.bean.SessionScoped; 8 | 9 | @ManagedBean(name="user") 10 | @SessionScoped 11 | public class UserBean implements Serializable{ 12 | 13 | String username; 14 | Date dob; 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | public void setUsername(String username) { 20 | this.username = username; 21 | } 22 | public Date getDob() { 23 | return dob; 24 | } 25 | public void setDob(Date dob) { 26 | this.dob = dob; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/src/main/resources/com/mkyong/MyMessage.properties: -------------------------------------------------------------------------------- 1 | javax.faces.converter.DateTimeConverter.DATE={2}: ''{0}'' could not be understood as a date. 2 | javax.faces.converter.DateTimeConverter.DATE_detail=Invalid date format. 3 | 4 | javax.faces.validator.LengthValidator.MINIMUM=Minimum length of ''{0}'' is required. -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | com.xxy.MyMessage 11 | 12 | 13 | -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

Customize validation error message in JSF 2.0

11 | 12 | 13 | 14 | 15 | 16 | Enter your username : 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | Enter your DOB : 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | -------------------------------------------------------------------------------- /JavaServerFaces_52CustomValidation/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

Customize validation error message in JSF 2.0

12 | 13 | 14 | 15 | Username : 16 | 17 | 18 | D.O.B : 19 | 20 | 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /JavaServerFaces_53CustomConverter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_53CustomConverter 13 | 14 | 15 | commons-validator 16 | commons-validator 17 | 1.3.1 18 | 19 | 20 | 21 | oro 22 | oro 23 | 2.0.8 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /JavaServerFaces_53CustomConverter/src/main/java/com/xxy/URLBookmark.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | public class URLBookmark{ 4 | 5 | String fullURL; 6 | 7 | public URLBookmark(String fullURL) { 8 | this.fullURL = fullURL; 9 | } 10 | 11 | public String getFullURL() { 12 | return fullURL; 13 | } 14 | 15 | public void setFullURL(String fullURL) { 16 | this.fullURL = fullURL; 17 | } 18 | 19 | public String toString(){ 20 | return fullURL; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /JavaServerFaces_53CustomConverter/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | String bookmarkURL; 12 | 13 | public String getBookmarkURL() { 14 | return bookmarkURL; 15 | } 16 | 17 | public void setBookmarkURL(String bookmarkURL) { 18 | this.bookmarkURL = bookmarkURL; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /JavaServerFaces_53CustomConverter/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

Custom converter in JSF 2.0

11 | 12 | 13 | 14 | 15 | 16 | Enter your bookmark URL : 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /JavaServerFaces_53CustomConverter/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |

Custom converter in JSF 2.0

12 | 13 | 14 | 15 | Bookmark URL : 16 | 17 | 18 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /JavaServerFaces_54CustomValidator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_54CustomValidator 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_54CustomValidator/src/main/java/com/xxy/EmailValidator.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import javax.faces.application.FacesMessage; 7 | import javax.faces.component.UIComponent; 8 | import javax.faces.context.FacesContext; 9 | import javax.faces.validator.FacesValidator; 10 | import javax.faces.validator.Validator; 11 | import javax.faces.validator.ValidatorException; 12 | 13 | @FacesValidator("com.xxy.EmailValidator") 14 | public class EmailValidator implements Validator{ 15 | 16 | private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\." + 17 | "[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*" + 18 | "(\\.[A-Za-z]{2,})$"; 19 | 20 | private Pattern pattern; 21 | private Matcher matcher; 22 | 23 | public EmailValidator(){ 24 | pattern = Pattern.compile(EMAIL_PATTERN); 25 | } 26 | 27 | @Override 28 | public void validate(FacesContext context, UIComponent component, 29 | Object value) throws ValidatorException { 30 | 31 | matcher = pattern.matcher(value.toString()); 32 | if(!matcher.matches()){ 33 | 34 | FacesMessage msg = 35 | new FacesMessage("E-mail validation failed.", 36 | "Invalid E-mail format."); 37 | msg.setSeverity(FacesMessage.SEVERITY_ERROR); 38 | throw new ValidatorException(msg); 39 | 40 | } 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /JavaServerFaces_54CustomValidator/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | 7 | @ManagedBean(name="user") 8 | @SessionScoped 9 | public class UserBean implements Serializable{ 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | String email; 14 | 15 | public String getEmail() { 16 | return email; 17 | } 18 | 19 | public void setEmail(String email) { 20 | this.email = email; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /JavaServerFaces_54CustomValidator/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |

Custom validator in JSF 2.0

11 | 12 | 13 | 14 | 15 | 16 | Enter your email : 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /JavaServerFaces_54CustomValidator/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 |

Custom validator in JSF 2.0

10 | 11 | 12 | 13 | Email Address : 14 | 15 | 16 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /JavaServerFaces_55ValidatorMultipleComponents/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_55ValidatorMultipleComponents 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_55ValidatorMultipleComponents/src/main/java/com/xxy/PasswordValidator.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.application.FacesMessage; 4 | import javax.faces.component.UIComponent; 5 | import javax.faces.component.UIInput; 6 | import javax.faces.context.FacesContext; 7 | import javax.faces.validator.FacesValidator; 8 | import javax.faces.validator.Validator; 9 | import javax.faces.validator.ValidatorException; 10 | 11 | @FacesValidator("passwordValidator") 12 | public class PasswordValidator implements Validator { 13 | 14 | @Override 15 | public void validate(FacesContext context, UIComponent component, 16 | Object value) throws ValidatorException { 17 | 18 | String password = value.toString(); 19 | 20 | UIInput uiInputConfirmPassword = (UIInput) component.getAttributes() 21 | .get("confirmPassword"); 22 | String confirmPassword = uiInputConfirmPassword.getSubmittedValue() 23 | .toString(); 24 | 25 | // Let required="true" do its job. 26 | if (password == null || password.isEmpty() || confirmPassword == null 27 | || confirmPassword.isEmpty()) { 28 | return; 29 | } 30 | 31 | if (!password.equals(confirmPassword)) { 32 | uiInputConfirmPassword.setValid(false); 33 | throw new ValidatorException(new FacesMessage( 34 | "Password must match confirm password.")); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /JavaServerFaces_55ValidatorMultipleComponents/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | JavaServerFaces 9 | 10 | 11 | 12 | javax.faces.PROJECT_STAGE 13 | Development 14 | 15 | 16 | 17 | 18 | default.jsf 19 | 20 | 21 | 22 | facesServlet 23 | javax.faces.webapp.FacesServlet 24 | 1 25 | 26 | 27 | facesServlet 28 | *.jsf 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /JavaServerFaces_55ValidatorMultipleComponents/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |

Multiple-Components Validator in JSF 2.0

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | -------------------------------------------------------------------------------- /JavaServerFaces_55ValidatorMultipleComponents/src/main/webapp/thanks.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 |

Thanks for register

8 | 9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_56CompositeComponents/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_56CompositeComponents 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_56CompositeComponents/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | 6 | @ManagedBean(name="user") 7 | @SessionScoped 8 | public class UserBean{ 9 | 10 | public String name; 11 | public String email; 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | public String getEmail() { 20 | return email; 21 | } 22 | public void setEmail(String email) { 23 | this.email = email; 24 | } 25 | 26 | public String registerAction(){ 27 | return "result"; 28 | } 29 | } -------------------------------------------------------------------------------- /JavaServerFaces_56CompositeComponents/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 |

Composite Components in JSF 2.0

12 | 13 | 22 | 23 |
24 | 25 | -------------------------------------------------------------------------------- /JavaServerFaces_56CompositeComponents/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

Composite Components in JSF 2.0

11 | 12 | Name : #{user.name} 13 | 14 |
15 | 16 | E-mail : #{user.email} 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /JavaServerFaces_57ValueChangeListener/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_57ValueChangeListener 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_57ValueChangeListener/src/main/java/com/xxy/CountryBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | import javax.faces.bean.ManagedBean; 7 | import javax.faces.bean.SessionScoped; 8 | import javax.faces.event.ValueChangeEvent; 9 | 10 | @ManagedBean(name="country") 11 | @SessionScoped 12 | public class CountryBean implements Serializable{ 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | private static Map countries; 17 | 18 | private String localeCode = "en"; //default value 19 | 20 | static{ 21 | countries = new LinkedHashMap(); 22 | countries.put("United Kingdom", "en"); //label, value 23 | countries.put("French", "fr"); 24 | countries.put("German", "de"); 25 | countries.put("China", "zh_CN"); 26 | } 27 | 28 | public void countryLocaleCodeChanged(ValueChangeEvent e){ 29 | //assign new value to localeCode 30 | localeCode = e.getNewValue().toString(); 31 | 32 | } 33 | 34 | public Map getCountryInMap() { 35 | return this.countries; 36 | } 37 | 38 | public String getLocaleCode() { 39 | return localeCode; 40 | } 41 | 42 | public void setLocaleCode(String localeCode) { 43 | this.localeCode = localeCode; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /JavaServerFaces_57ValueChangeListener/src/main/java/com/xxy/CountryValueListener.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import com.xxy.CountryBean; 4 | 5 | import javax.faces.context.FacesContext; 6 | import javax.faces.event.AbortProcessingException; 7 | import javax.faces.event.ValueChangeEvent; 8 | import javax.faces.event.ValueChangeListener; 9 | 10 | public class CountryValueListener implements ValueChangeListener{ 11 | 12 | @Override 13 | public void processValueChange(ValueChangeEvent event) 14 | throws AbortProcessingException { 15 | 16 | //access country bean directly 17 | CountryBean country = (CountryBean) FacesContext.getCurrentInstance(). 18 | getExternalContext().getSessionMap().get("country"); 19 | 20 | country.setLocaleCode(event.getNewValue().toString()); 21 | 22 | } 23 | 24 | 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_58ActionListener/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_58ActionListener 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_58ActionListener/src/main/java/com/xxy/NormalActionListener.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.event.AbortProcessingException; 4 | import javax.faces.event.ActionEvent; 5 | import javax.faces.event.ActionListener; 6 | 7 | public class NormalActionListener implements ActionListener{ 8 | 9 | @Override 10 | public void processAction(ActionEvent event) 11 | throws AbortProcessingException { 12 | 13 | System.out.println("Any use case here?"); 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /JavaServerFaces_58ActionListener/src/main/java/com/xxy/NormalBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | import javax.faces.bean.SessionScoped; 5 | import javax.faces.event.ActionEvent; 6 | 7 | @ManagedBean(name="normal") 8 | @SessionScoped 9 | public class NormalBean{ 10 | 11 | public String buttonId; 12 | 13 | public String getButtonId() { 14 | return buttonId; 15 | } 16 | 17 | public void setButtonId(String buttonId) { 18 | this.buttonId = buttonId; 19 | } 20 | 21 | public void printIt(ActionEvent event){ 22 | 23 | //Get submit button id 24 | buttonId = event.getComponent().getClientId(); 25 | 26 | } 27 | 28 | public String outcome(){ 29 | return "result"; 30 | } 31 | } -------------------------------------------------------------------------------- /JavaServerFaces_58ActionListener/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 |

JSF 2 actionListener example

13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | -------------------------------------------------------------------------------- /JavaServerFaces_58ActionListener/src/main/webapp/result.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2 actionListener example

11 | 12 | #{normal.buttonId} 13 | 14 |
15 | -------------------------------------------------------------------------------- /JavaServerFaces_59PostConstructApplicationEvent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_59PostConstructApplicationEvent 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_59PostConstructApplicationEvent/src/main/java/com/xxy/FacesAppListener.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.application.Application; 4 | import javax.faces.event.AbortProcessingException; 5 | import javax.faces.event.PostConstructApplicationEvent; 6 | import javax.faces.event.PreDestroyApplicationEvent; 7 | import javax.faces.event.SystemEvent; 8 | import javax.faces.event.SystemEventListener; 9 | 10 | public class FacesAppListener implements SystemEventListener{ 11 | 12 | @Override 13 | public void processEvent(SystemEvent event) throws AbortProcessingException { 14 | 15 | if(event instanceof PostConstructApplicationEvent){ 16 | System.out.println("PostConstructApplicationEvent is Called"); 17 | } 18 | 19 | if(event instanceof PreDestroyApplicationEvent){ 20 | System.out.println("PreDestroyApplicationEvent is Called"); 21 | } 22 | 23 | } 24 | 25 | @Override 26 | public boolean isListenerForSource(Object source) { 27 | //only for Application 28 | return (source instanceof Application); 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /JavaServerFaces_59PostConstructApplicationEvent/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | com.xxy.FacesAppListener 14 | 15 | javax.faces.event.PostConstructApplicationEvent 16 | 17 | 18 | 19 | 20 | 21 | com.xxy.FacesAppListener 22 | 23 | 24 | javax.faces.event.PreDestroyApplicationEvent 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /JavaServerFaces_60PreRenderViewEvent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_60PreRenderViewEvent 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_60PreRenderViewEvent/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.application.ConfigurableNavigationHandler; 4 | import javax.faces.bean.ManagedBean; 5 | import javax.faces.bean.SessionScoped; 6 | import javax.faces.context.FacesContext; 7 | import javax.faces.event.ComponentSystemEvent; 8 | 9 | @ManagedBean(name="user") 10 | @SessionScoped 11 | public class UserBean{ 12 | 13 | public void isAdmin(ComponentSystemEvent event){ 14 | 15 | FacesContext fc = FacesContext.getCurrentInstance(); 16 | 17 | if (!"admin".equals(fc.getExternalContext().getSessionMap().get("role"))){ 18 | ConfigurableNavigationHandler nav 19 | = (ConfigurableNavigationHandler) 20 | fc.getApplication().getNavigationHandler(); 21 | 22 | nav.performNavigation("access-denied"); 23 | } 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /JavaServerFaces_60PreRenderViewEvent/src/main/webapp/access-denied.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

Access Denied!

11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_60PreRenderViewEvent/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 |

JSF 2 protected page example

14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_61ValidatorMultipleComponents/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_61ValidatorMultipleComponents 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_61ValidatorMultipleComponents/src/main/java/com/xxy/PasswordValidator.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.faces.application.FacesMessage; 4 | import javax.faces.component.UIComponent; 5 | import javax.faces.component.UIInput; 6 | import javax.faces.context.FacesContext; 7 | import javax.faces.validator.FacesValidator; 8 | import javax.faces.validator.Validator; 9 | import javax.faces.validator.ValidatorException; 10 | 11 | @FacesValidator("passwordValidator") 12 | public class PasswordValidator implements Validator { 13 | 14 | @Override 15 | public void validate(FacesContext context, UIComponent component, 16 | Object value) throws ValidatorException { 17 | 18 | String password = value.toString(); 19 | 20 | UIInput uiInputConfirmPassword = (UIInput) component.getAttributes() 21 | .get("confirmPassword"); 22 | String confirmPassword = uiInputConfirmPassword.getSubmittedValue() 23 | .toString(); 24 | 25 | // Let required="true" do its job. 26 | if (password == null || password.isEmpty() || confirmPassword == null 27 | || confirmPassword.isEmpty()) { 28 | return; 29 | } 30 | 31 | if (!password.equals(confirmPassword)) { 32 | uiInputConfirmPassword.setValid(false); 33 | throw new ValidatorException(new FacesMessage( 34 | "Password must match confirm password.")); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /JavaServerFaces_61ValidatorMultipleComponents/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaServerFaces_61ValidatorMultipleComponents 4 | 5 | javax.faces.PROJECT_STAGE 6 | Development 7 | 8 | 9 | default.jsf 10 | 11 | 12 | facesServlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | facesServlet 18 | *.jsf 19 | 20 | -------------------------------------------------------------------------------- /JavaServerFaces_61ValidatorMultipleComponents/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |

Multiple-Components Validator in JSF 2.0

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | -------------------------------------------------------------------------------- /JavaServerFaces_61ValidatorMultipleComponents/src/main/webapp/thanks.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 |

Thanks for register

8 | 9 |
10 | -------------------------------------------------------------------------------- /JavaServerFaces_62JDBCIntegration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | JavaServerFaces-parent 7 | JavaServerFaces 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | JavaServerFaces_62JDBCIntegration 13 | 14 | 15 | -------------------------------------------------------------------------------- /JavaServerFaces_62JDBCIntegration/src/main/java/com/xxy/customer/model/Customer.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Customer{ 6 | 7 | public long customerID; 8 | public String name; 9 | public String address; 10 | public Date created_date; 11 | 12 | public long getCustomerID() { 13 | return customerID; 14 | } 15 | public void setCustomerID(long customerID) { 16 | this.customerID = customerID; 17 | } 18 | public String getName() { 19 | return name; 20 | } 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | public String getAddress() { 25 | return address; 26 | } 27 | public void setAddress(String address) { 28 | this.address = address; 29 | } 30 | public Date getCreated_date() { 31 | return created_date; 32 | } 33 | public void setCreated_date(Date created_date) { 34 | this.created_date = created_date; 35 | } 36 | } -------------------------------------------------------------------------------- /JavaServerFaces_62JDBCIntegration/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JavaServerFaces_62JDBCIntegration/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

JSF 2.0 + JDBC Example

15 | 16 | 21 | 22 | 23 | 24 | Customer ID 25 | 26 | #{c.customerID} 27 | 28 | 29 | 30 | 31 | Name 32 | 33 | #{c.name} 34 | 35 | 36 | 37 | 38 | Address 39 | 40 | #{c.address} 41 | 42 | 43 | 44 | 45 | Created Date 46 | 47 | #{c.created_date} 48 | 49 | 50 | 51 | 52 |
53 | 54 | -------------------------------------------------------------------------------- /JavaServerFaces_62JDBCIntegration/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/java/com/xxy/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | import org.springframework.context.annotation.Scope; 6 | import com.xxy.user.bo.UserBo; 7 | 8 | @Named 9 | @Scope("session") 10 | public class UserBean { 11 | 12 | @Inject 13 | UserBo userBo; 14 | 15 | public void setUserBo(UserBo userBo) { 16 | this.userBo = userBo; 17 | } 18 | 19 | public String printMsgFromSpring() { 20 | return userBo.getMessage(); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/java/com/xxy/user/bo/UserBo.java: -------------------------------------------------------------------------------- 1 | package com.xxy.user.bo; 2 | 3 | public interface UserBo{ 4 | 5 | public String getMessage(); 6 | 7 | } -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/java/com/xxy/user/bo/impl/UserBoImpl.java: -------------------------------------------------------------------------------- 1 | package com.xxy.user.bo.impl; 2 | 3 | import javax.inject.Named; 4 | 5 | import com.xxy.user.bo.UserBo; 6 | 7 | @Named 8 | public class UserBoImpl implements UserBo{ 9 | 10 | public String getMessage() { 11 | 12 | return "JSF 2 + Spring Integration"; 13 | 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 14 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | org.springframework.web.jsf.el.SpringBeanFacesELResolver 10 | 11 | 12 | 13 | user 14 | com.xxy.UserBean 15 | session 16 | 17 | userBo 18 | #{userBo} 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /JavaServerFaces_63Spring/src/main/webapp/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 |

JSF 2.0 + Spring Example

11 | 12 | #{userBean.printMsgFromSpring()} 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/CustomerBean.java: -------------------------------------------------------------------------------- 1 | package com.xxy; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.xxy.customer.bo.CustomerBo; 7 | import com.xxy.customer.model.Customer; 8 | 9 | public class CustomerBean implements Serializable{ 10 | 11 | //DI via Spring 12 | CustomerBo customerBo; 13 | 14 | public String name; 15 | public String address; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | public void setAddress(String address) { 30 | this.address = address; 31 | } 32 | 33 | public void setCustomerBo(CustomerBo customerBo) { 34 | this.customerBo = customerBo; 35 | } 36 | 37 | //get all customer data from database 38 | public List getCustomerList(){ 39 | return customerBo.findAllCustomer(); 40 | } 41 | 42 | //add a new customer data into database 43 | public String addCustomer(){ 44 | 45 | Customer cust = new Customer(); 46 | cust.setName(getName()); 47 | cust.setAddress(getAddress()); 48 | 49 | customerBo.addCustomer(cust); 50 | 51 | clearForm(); 52 | 53 | return ""; 54 | } 55 | 56 | //clear form values 57 | private void clearForm(){ 58 | setName(""); 59 | setAddress(""); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/customer/bo/CustomerBo.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.bo; 2 | 3 | import java.util.List; 4 | 5 | import com.xxy.customer.model.Customer; 6 | 7 | public interface CustomerBo{ 8 | 9 | void addCustomer(Customer customer); 10 | 11 | List findAllCustomer(); 12 | 13 | } -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/customer/bo/impl/CustomerBoImpl.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.bo.impl; 2 | 3 | import java.util.List; 4 | 5 | import com.xxy.customer.bo.CustomerBo; 6 | import com.xxy.customer.dao.CustomerDao; 7 | import com.xxy.customer.model.Customer; 8 | 9 | public class CustomerBoImpl implements CustomerBo{ 10 | 11 | CustomerDao customerDao; 12 | 13 | public void setCustomerDao(CustomerDao customerDao) { 14 | this.customerDao = customerDao; 15 | } 16 | 17 | public void addCustomer(Customer customer){ 18 | 19 | customerDao.addCustomer(customer); 20 | 21 | } 22 | 23 | public List findAllCustomer(){ 24 | 25 | return customerDao.findAllCustomer(); 26 | } 27 | } -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/customer/dao/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xxy.customer.model.Customer; 6 | 7 | public interface CustomerDao{ 8 | 9 | void addCustomer(Customer customer); 10 | 11 | List findAllCustomer(); 12 | 13 | } -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/customer/dao/impl/CustomerDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.dao.impl; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import com.xxy.customer.dao.CustomerDao; 7 | import com.xxy.customer.model.Customer; 8 | import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 9 | 10 | public class CustomerDaoImpl extends 11 | HibernateDaoSupport implements CustomerDao{ 12 | 13 | public void addCustomer(Customer customer){ 14 | 15 | customer.setCreatedDate(new Date()); 16 | getHibernateTemplate().save(customer); 17 | 18 | } 19 | 20 | public List findAllCustomer(){ 21 | 22 | return getHibernateTemplate().find("from Customer"); 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/java/com/xxy/customer/model/Customer.java: -------------------------------------------------------------------------------- 1 | package com.xxy.customer.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Customer{ 6 | 7 | public long customerId; 8 | public String name; 9 | public String address; 10 | public Date createdDate; 11 | 12 | public long getCustomerId() { 13 | return customerId; 14 | } 15 | public void setCustomerId(long customerId) { 16 | this.customerId = customerId; 17 | } 18 | public String getName() { 19 | return name; 20 | } 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | public String getAddress() { 25 | return address; 26 | } 27 | public void setAddress(String address) { 28 | this.address = address; 29 | } 30 | public Date getCreatedDate() { 31 | return createdDate; 32 | } 33 | public void setCreatedDate(Date createdDate) { 34 | this.createdDate = createdDate; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | org.springframework.web.jsf.el.SpringBeanFacesELResolver 12 | 13 | 14 | 15 | 16 | customer 17 | com.xxy.CustomerBean 18 | session 19 | 20 | customerBo 21 | #{customerBo} 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/com/xxy/customer/hibernate/Customer.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/com/xxy/customer/spring/CustomerBean.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/config/database/db.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClassName=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://localhost:3306/xxydb 3 | jdbc.username=root 4 | jdbc.password=password -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/config/spring/beans/DataSource.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | config/database/db.properties 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/config/spring/beans/HibernateSessionFactory.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | org.hibernate.dialect.MySQLDialect 18 | true 19 | 20 | 21 | 22 | 23 | 24 | com/xxy/customer/hibernate/Customer.hbm.xml 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /JavaServerFaces_64SpringHibernateIntegration/src/main/webapp/resources/css/table-style.css: -------------------------------------------------------------------------------- 1 | .order-table{ 2 | border-collapse:collapse; 3 | } 4 | 5 | .order-table-header{ 6 | text-align:center; 7 | background:none repeat scroll 0 0 #E5E5E5; 8 | border-bottom:1px solid #BBBBBB; 9 | padding:16px; 10 | } 11 | 12 | .order-table-odd-row{ 13 | text-align:center; 14 | background:none repeat scroll 0 0 #FFFFFF; 15 | border-top:1px solid #BBBBBB; 16 | } 17 | 18 | .order-table-even-row{ 19 | text-align:center; 20 | background:none repeat scroll 0 0 #F9F9F9; 21 | border-top:1px solid #BBBBBB; 22 | } --------------------------------------------------------------------------------