【问题标题】:JSF: How to pass ui:param to a custom facelets tag?JSF:如何将 ui:param 传递给自定义 facelets 标记?
【发布时间】:2016-10-07 15:20:33
【问题描述】:

我已经创建了一个这样的自定义 facelets 标记:

<ui:composition xmlns...>
    <h:form>
        <h:commandLink action="#{controller.doSomething()}"/>
    </h:form>
</ui:composition>

我正在尝试这样使用它:

<myNs:myTag>
    <ui:param name="controller" value="#{theActualController}"/>
</myNs:myTag>

但是点击commandLink会导致以下异常:

Target Unreachable, identifier 'controller' resolved to null

这个问题facelets: passing bean name with ui:param to action attribute 看起来有些相似,但那里提出的解决方案对我不起作用。

【问题讨论】:

    标签: jsf


    【解决方案1】:

    可以像这样在 taglib xml 文件中定义属性,而不是使用 ui:param 传递参数:

    <tag>
        <tag-name>myTag</tag-name>
        <source>myTag.xhtml</source>
        <attribute>
            <name>controller</name>
            <required>true</requierd>
        </attribute>
    </tag>
    

    然后像这样传递控制器:

    <myNs:myTag controller="#{theActualController}"/>
    

    【讨论】:

      猜你喜欢
      • 2010-12-19
      • 2013-04-27
      • 1970-01-01
      • 2014-01-02
      • 2011-12-21
      • 2011-09-12
      • 2011-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多