天天看点

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>