在JSF 2复合组件中使用id-attribute和目标(Using id-attribute in JSF 2 composite component with targets)
我正在尝试为按钮创建JSF 2.1复合组件:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jstl/core"> <composite:interface> <composite:attribute name="id" required="true" type="java.lang.String" /> <composite:attribute name="label" required="true" type="java.lang.String" /> <composite:attribute name="action" method-signature="java.lang.String action()" targets="#{cc.attrs.id}" /> </composite:interface> <composite:implementation> <a4j:commandLink id="#{cc.attrs.id}"> <span style="linkButton"><h:outputText value="#{cc.attrs.label}" /></span> </a4j:commandLink> </composite:implementation> </html>
我对此代码的问题是,在呈现页面时它会给出以下异常:
java.lang.ClassCastException: javax.faces.component.UINamingContainer cannot be cast to javax.faces.component.ActionSource2 at com.sun.faces.application.view.FaceletViewHandlingStrategy$MethodRetargetHandlerManager$ActionRegargetHandler.retarget(FaceletViewHandlingStrategy.java:1536) at com.sun.faces.application.view.FaceletViewHandlingStrategy.retargetMethodExpressions(FaceletViewHandlingStrategy.java:689) at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:201) at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:196) ...
当我使用像
myId
这样定义的String替换id
和targets
属性中的#{cc.attrs.id}
,该组件按预期工作,但这使得它不能在同一页面中重复使用,从而消除了创建复合组件的麻烦感首先。我在这里错过了吗?
I am trying to create a JSF 2.1 composite component for a button:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jstl/core"> <composite:interface> <composite:attribute name="id" required="true" type="java.lang.String" /> <composite:attribute name="label" required="true" type="java.lang.String" /> <composite:attribute name="action" method-signature="java.lang.String action()" targets="#{cc.attrs.id}" /> </composite:interface> <composite:implementation> <a4j:commandLink id="#{cc.attrs.id}"> <span style="linkButton"><h:outputText value="#{cc.attrs.label}" /></span> </a4j:commandLink> </composite:implementation> </html>
The problem I have with this code is that it gives the following exception when the page is rendered:
java.lang.ClassCastException: javax.faces.component.UINamingContainer cannot be cast to javax.faces.component.ActionSource2 at com.sun.faces.application.view.FaceletViewHandlingStrategy$MethodRetargetHandlerManager$ActionRegargetHandler.retarget(FaceletViewHandlingStrategy.java:1536) at com.sun.faces.application.view.FaceletViewHandlingStrategy.retargetMethodExpressions(FaceletViewHandlingStrategy.java:689) at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:201) at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:196) ...
When I replace the
#{cc.attrs.id}
inid
andtargets
attribute with a defined String likemyId
then the component works as expected but this makes it not reusable in the same page and thus eliminates the wohle sense in creating a composite component in the first place.Did I miss anything here?
原文:https://stackoverflow.com/questions/20053256
最满意答案
看来可下载包虽然是
.exe
文件,但实际上是一个简单的PKZIP存档。 将文件从.exe
重命名为.zip
并使用Windows归档提取器为我工作。It appears that the downloadable package, though it is an
.exe
file, is in fact a simple PKZIP archive. Renaming the file from.exe
to.zip
and using the Windows archive extractor worked for me.
相关问答
更多-
如何将 DB2 升级到 V10.5[2022-03-21]
请参考:http://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1403db2_migration/index.html 升级前准备 升级之前,客户需要考虑升级条件是否具备,然后制定升级计划。 检查升级条件 主要从两方面来检查是否支持 DB2 升级到 V10.5 版本。在 DB2 版本方面,只支持直接从 DB 9.7 之后(含)的版本升级,如果是更低的版本如 DB2 9.5,需要先升级到 9.7 或 10.1,然后再升级到 V10.5 ... -
windows 7怎么安装db2 10.5[2023-03-25]
运行db2setupwin企业版下的setup,进入安装界面: 2 点击“安装产品”按钮 3 点击“下一步”按钮 4 再点击“下一步” 5 选定 我接受许可证协议中的全部条款 后,在点击“下一步” 6 选择“典型安装”,再选择“下一步” 7 点击“下一步” 点击“下一步” 输入DB2的密码后,点击“下一步” 点击“下一步” 点击“确定” 点击“下一步” 点击“下一步” 点击“下一步” 点击“下一步” 点击“安装” 安装完成后出现如下界面 点击“完成”,至此DB2安装结束。 -
DB2 哪个版本 适用于WINDOWS10 家庭版?[2022-03-03]
首先第0步,在磁盘的尾巴步压缩出一个大概50G的空间,超大预算,压缩出来的空间在这里不用建立成新分区,待后面备用,图不懂可百度。 第一步,当然是下载linux ubuntu14,厦门大学的信息与网络中心。里面有很多linux版本。有Deepin CenOS ubuntu什么什么的。 第二步,下载Ultraiso软碟通工具,下载完成后,插入U盘,使用Ultraiso把LINUX UBUNTU14.X这个iso文件【写入硬盘影像】到U盘,千万记住备份U盘里面的数据,写入过程中请不要让电脑休眠,以免损坏U盘。写完 ... -
看来可下载包虽然是.exe文件,但实际上是一个简单的PKZIP存档。 将文件从.exe重命名为.zip并使用Windows归档提取器为我工作。 It appears that the downloadable package, though it is an .exe file, is in fact a simple PKZIP archive. Renaming the file from .exe to .zip and using the Windows archive extractor work ...
-
您可以使用db2_install没有GUI的情况下安装。 它有一个帮助选项,并在DB2 Knowledge Center中进行了说明 。 该命令位于安装文件的顶级目录中。 You can install without a GUI using db2_install. It has a help option and is documented in the DB2 Knowledge Center. The command is located in the top directory of your i ...
-
您需要设置DBM参数SVCENAME : db2 update DBM CFG using SVCENAME 50000 之后重启实例。 You need to set the DBM parameter SVCENAME: db2 update DBM CFG using SVCENAME 50000 Restart instance afterwards.
-
使用Tableau Desktop连接到IBM DB2时出错?(Error while connecting to IBM DB2 with Tableau Desktop?)[2022-09-11]
您需要从Tableau的网站https://www.tableau.com/support/drivers下载并安装IBM DB2驱动程序。 Tableau的联机帮助包括用于设置与DB2的连接的页面。 我在这里缩写它们。 启动Tableau,在Connect下,选择IBM DB2。 有关数据连接的完整列表,请在“到服务器”下选择更多。 然后执行以下操作: 输入承载数据库的服务器的名称以及要连接的数据库的名称。 输入您的用户名和密码。 如果Tableau无法建立连接,请验证您的凭据是否正确。 如果仍然无法连接 ... -
您需要将ClientTarget="uplevel"添加到aspx文件的page指令中。 <%@ Page ClientTarget="uplevel" ... %> You need to add ClientTarget="uplevel" to the page directive of the aspx file. <%@ Page ClientTarget="uplevel" ... %>
-
显然我需要运行命令: CREATE DATABASE DEMODB AUTOMATIC STORAGE YES ON 'C:\' DBPATH ON 'C:\' 这完全创建了DB并允许我连接并使用它。 db2 => CONNECT TO DEMODB USER DB2ADMIN USING
Database Connection Information Database server = DB2/NT64 10.5.7 SQL authorization ID ... -
在我启动db2setup的控制台中,我发现我需要输入几次dasusrX密码。 没有提示显示。 我相信系统在配置DB2实例任务期间也会挂起,幸运的是我为其他用户使用了相同的密码,因此我也在那里输入了密码以完成安装。 我想出了这个运行dascrt -d -u dasusrX并看到它挂在su dasusrX -c / bin / pwd命令,当我手动尝试该命令时,它为了dasusrX密码而推荐。 这可能是我们的服务器设置的唯一情况,因为root只能通过sudo -i访问,所以在其他情况下,当使用su作为root时 ...