首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >复合组件中p:commandButton的操作和actionListener

复合组件中p:commandButton的操作和actionListener
EN

Stack Overflow用户
提问于 2013-10-14 16:36:34
回答 1查看 4.2K关注 0票数 4

我正在制作具有commandButton的复合组件。但不起作用。

用法:

代码语言:javascript
复制
<wk:commandButton value="Non-Ajax actionListener" actionListener="#{ioBean.saveListener}" />  

组件代码: commandButton.xhtml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
    <cc:attribute name="value" />
    <cc:attribute name="action" method-signature="void action(javax.faces.event.ActionEvent)" default="null"/>
    <cc:attribute name="actionListener" method-signature="void actionListener(javax.faces.event.ActionEvent)" default="null"/>
    <cc:attribute name="styleClass" default="button" />
</cc:interface>
    <cc:implementation>
            <p:commandButton
                            value="#{cc.attrs.value}"
                            action="#{cc.attrs.action}"
                            actionListener="#{cc.attrs.actionListener}"
                            styleClass="#{styleClass}">
                <cc:insertChildren />
            </p:commandButton>
    </cc:implementation>
</html>

这是日志:

代码语言:javascript
复制
0000006c FaceletViewDe E   Inner component action not found when retargetMethodExpressions
0000006c FaceletViewDe E   Inner component actionListener not found when retargetMethodExpressions
0000006c srt           W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: Ostrzeżenie: nie można ustawić nagłówka. Odpowiedź została już zatwierdzona.

我认为问题在于操作和actionListener的默认值。但是根据PrimeFaces文档,操作和actionListener的默认值为null。一种选择是创建四个不同的变量,其中操作和actionListener为null或定义为null,但它似乎不是很好的解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-30 11:04:30

使用<cc:attribute targets>而不是显式指定可能的null操作(侦听器)。

代码语言:javascript
复制
<cc:interface>
    <cc:attribute name="value" />
    <cc:attribute name="action" targets="buttonId" />
    <cc:attribute name="actionListener" targets="buttonId" />
</cc:interface>
<cc:implementation>
    <p:commandButton id="buttonId" value="#{cc.attrs.value}" />
</cc:implementation>
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19364933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档