JSF的commandButton、commandLink、outputLink分析

本文介绍了JSF中的几种关键组件,包括h:commandButton、h:outputLink及h:commandLink的使用方法与区别。通过示例展示了如何利用这些组件实现表单提交、链接跳转等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚开始学习JSF,不知道说的对不对,如有错误的,望大家能回复....行风居士

h:commandButton

h:commandButton 看到名字就会想得到这就是一个BUTTON当然要在一个<from>只才能提交表单内容.

<h:commandButton actionListener="#{actionListener.check}" value="送出" action="#{user.check}" />

actionListener 响应的一个事件,当然这个和js中的事件不一样.actionListener="#{actionListener.check}"响应的是服务器端的事件actionListener类的check方法.

action 用过STRUTS的都知道,提交后执行的方法.当然在SRTUTS中action="URL"而这里是一个user类的check方法.

h:outputLink

h:outputLink 这个和普通的<a href=""></a>链接没什么差别,只不过这是JSF的标签.使用方法如下:

<h:outputLink value="productEdit.faces">
                <h:outputText value="编辑"/>
                <f:param name="productId" value="#{report.password}"/>
                </h:outputLink>
</h:column>

f:param 参数组件.加上<f:param name="productId" value="#{report.password}"/> 其效果为<a href="..jsf?productId=..."></a>

h:commandLink

h:commandLink 和h:outputLink的差别在于,h:outputLink没有进入JSF的生命周期,而h:commandLink和h:commandButton都要进入JSF的生命周期.

<h:commandLink action="#{user.testLink}"><f:verbatim>增加</f:verbatim></h:commandLink>

初学者,还需要深入了解....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值