gpt4 book ai didi

jsf - p :commandButton in composite component 的操作和操作监听器

转载 作者:行者123 更新时间:2023-12-02 05:49:57 25 4
gpt4 key购买 nike

我正在制作具有命令按钮的复合组件。但这不起作用。

用法:

<wk:commandButton value="Non-Ajax actionListener" actionListener="#{ioBean.saveListener}" />  

组件代码:commandButton.xhtml

<?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>

这是日志:

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 文档,action 和 actionListener 的默认值为 null。一种选择是制作四种不同的变体,其中 action 和 actionListener 为 null 或已定义,但这似乎不是一个好的解决方案。

最佳答案

使用<cc:attribute targets>而不是明确指定可能的 null Action (监听器)。

<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>

关于jsf - p :commandButton in composite component 的操作和操作监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19364933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com