栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JSF 2 —在f:ajax上具有可选的listener属性的复合组件

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JSF 2 —在f:ajax上具有可选的listener属性的复合组件

您需要指定标签的

method-signature
属性,
<cc:attribute>
以便将属性值视为方法表达式。您可以使用JSTL视图构建时间标记
<c:if>
来有条件地添加
<f:ajax>
标记。

<cc:interface>    <cc:attribute name="listener" method-signature="void listener()" /></cc:interface><cc:implementation>    <h:someComponent>        <c:if test="#{cc.getValueexpression('listener') != null}"> <f:ajax listener="#{cc.attrs.listener}" />        </c:if>    </h:someComponent></cc:implementation>

#{not empty cc.attrs.listener}
因为EL不能正常工作,所以会将属性作为值表达式隐式评估)

然后,您可以按以下方式使用它:

<my:someComposite listener="#{bean.listener}" />

或者,当您的环境不支持EL 2.2时,请创建一个支持组件:

@FacesComponent("someComponent")public class SomeComponent extends UINamingContainer {    public boolean isHasListener() {        return getValueexpression("listener") != null;    }}

声明并用作

<cc:interface type="someComponent">    <cc:attribute name="listener" method-signature="void listener()" /></cc:interface><cc:implementation>    <h:someComponent>        <c:if test="#{cc.hasListener}"> <f:ajax listener="#{cc.attrs.listener}" />        </c:if>    </h:someComponent></cc:implementation>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/427401.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号