天天看點

jboss seam dvdstore示例說明二3 home.xhtml首頁顯示,使用seam标簽和jsf的标簽4 首頁主功能選項的實作5 首頁面的登陸、建立使用者、登出功能實作

3 home.xhtml首頁顯示,使用seam标簽和jsf的标簽

3.1說明:

<ui:composition template="/WEB-INF/template.xhtml">為合成标簽,<ui:define name="topnav">定義的元件内容最終會通過/WEB-INF/template.xhtml頁面來引用 <ui:insert name="topnav">,最終顯示由JSF建構元件樹,渲染完成。

3.2Home.xhtml代碼段:

    <ui:composition template="/WEB-INF/template.xhtml">

        <ui:define name="topnav">

            <ui:include src="/WEB-INF/incl/store_nav.xhtml">

                <ui:param name="page" value="home" />

            </ui:include>

        </ui:define>

       ……

</ui:composition>

3.3 /WEB-INF/template.xhtml代碼段:

<div id="header">JBoss Seam DVD 商店</div>

        <div id="nav" name="i_do_not_know_nav">

            <ui:insert name="topnav">

                TOPNAV

            </ui:insert>

   </div>

4 首頁主功能選項的實作

jboss seam dvdstore示例說明二3 home.xhtml首頁顯示,使用seam标簽和jsf的标簽4 首頁主功能選項的實作5 首頁面的登陸、建立使用者、登出功能實作

home.xhtml當中包含的/WEB-INF/incl/store_nav.xhtml頁來實作。使用了seam超連結标簽。

5 首頁面的登陸、建立使用者、登出功能實作

home.xhtml當中包含的/WEB-INF/incl/login.xhtml頁來實作。使用了JSF标簽。

注:h:commandLink 當中的action屬性說明,要調用的session bean當中的方法。

如action="#{editCustomer.startEdit}",editCustomer為session bean,

startEdit為類中的方法。

5.1 登陸功能

說明:通過org.jboss.seam.security.Identity,使用此類身份驗證實作登陸功能。

登陸功能頁面代碼:

<h:commandButton id="Login"

action="#{identity.login}"

value="#{messages.loginPrompt}"                                          styleClass="formButton"

style="width: 166px;"/>

5.2 建立使用者功能

說明:通過com.jboss.dvd.seam. EditCustomerAction,使用此類實作使用者管理功能。

建立使用者頁面代碼:        

<h:commandLink id="CreateAccount" action="#{editCustomer.startEdit}">

Create Account</h:commandLink>