我想要做的是将公共数据表头声明为复合组件。但是这个答案使我明白了,因为它没有给出:
基本上,它指示我尝试我自己的taglib,这非常好,除了我的头有一个链接,在其中做reRender。当按下此链接时,将引发MethodNotFoundException。
这是我的定制标签库:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://stackoverflowdummy.com/dumb/components</namespace>
<tag>
<tag-name>tableHeader</tag-name>
<source>tags/tableHeader.xhtml</source>
<attribute>
<description></description>
<name>value</name>
</attribute>
<attribute>
<description>The listener that handles sorting</description>
<name>sortAction</name>
<method-signature>java.lang.String action()</method-signature>
</attribute>
<attribute>
<description>The property that holds the current id to sort on
</description>
<name>sortValue</name>
</attribute>
<attribute>
<description>The component that needs to be updated after changes
</description>
<name>reRender</name>
</attribute>
</tag>
</facelet-taglib>我尝试了没有方法签名,我也尝试删除“动作”。我的web.xml确实包括这样的标签库:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/cc.taglib.xml</param-value>
</context-param>我也试过用"facelets.LIBRARIES“,但没什么区别。
<h:commandLink value="#{o.label}" action="#{sortAction}" immediate="true" reRender="#{reRender}">
<f:setPropertyActionListener target="#{sortValue}" value="#{o.column.sortId}" />
</h:commandLink>终端使用的定义如下:
sortAction="#{myBean.sort}"该bean有一个带有签名字符串sort()的方法;如果我只定义它并使用我自己的标记跳过它,它就能很好地工作。但是,除了action方法之外,所有东西都与标记一起工作.
发布于 2014-01-16 13:38:51
JavaBean规范给出了如何调用方法的多种方法。实际上,您可以将一个操作称为正常方式#{actionBean.actionMethod},也可以称为#{actionBean['actionMethod']}方式。
您提供的排序操作是作为一个MethodExpression传输的,与ValueExpression相比,这在某些JSF环境中给我带来了问题。
我想让您尝试测试的是,将操作作为两个单独的(值)参数:
sortActionBean="#{myBean}"sortActionMethod="sort"并将模板中的这些调用为#{sortActionBean['sortActionMethod']}。关于这个主题的一篇很好的文章是传递动作方法facelets标记。
希望能帮上忙..。
https://stackoverflow.com/questions/21162888
复制相似问题