首页 \ 问答 \ 在JSF 2复合组件中使用id-attribute和目标(Using id-attribute in JSF 2 composite component with targets)

在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替换idtargets属性中的#{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} in id and targets attribute with a defined String like myId 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
更新时间:2022-07-05 13:07

最满意答案

看来可下载包虽然是.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.

相关问答

更多
  • 请参考: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 ...
  • 运行db2setupwin企业版下的setup,进入安装界面: 2 点击“安装产品”按钮 3 点击“下一步”按钮 4 再点击“下一步” 5 选定 我接受许可证协议中的全部条款 后,在点击“下一步” 6 选择“典型安装”,再选择“下一步” 7 点击“下一步” 点击“下一步” 输入DB2的密码后,点击“下一步” 点击“下一步” 点击“确定” 点击“下一步” 点击“下一步” 点击“下一步” 点击“下一步” 点击“安装” 安装完成后出现如下界面 点击“完成”,至此DB2安装结束。
  • 首先第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的网站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时 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)