Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf <;f:参数>;用于周围环境的复合构件中的标记<;h:outputLink>;和奇怪的行为<;c:forEach>;_Jsf_Jsf 2_Jstl_Facelets_Composite Component_Xhtml - Fatal编程技术网

Jsf <;f:参数>;用于周围环境的复合构件中的标记<;h:outputLink>;和奇怪的行为<;c:forEach>;

Jsf <;f:参数>;用于周围环境的复合构件中的标记<;h:outputLink>;和奇怪的行为<;c:forEach>;,jsf,jsf-2,jstl,facelets,composite-component,xhtml,Jsf,Jsf 2,Jstl,Facelets,Composite Component,Xhtml,我需要编写一个复合组件,该组件放置在..标记中,并输出标记。生成的标记的源是一个由筛选器设置的请求属性,该属性包含一个对象列表,这些对象为属性名称和值提供值 现在有两个问题: 标记不会影响周围 不会迭代从请求属性检索的列表 一般来说,整个组件的行为有点奇怪,因为我可以访问列表中的特定元素并输出其值。但是,只要涉及到,循环就不会输出任何内容 组件当前的外观如下所示: <f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="h

我需要编写一个复合组件,该组件放置在
..
标记中,并输出
标记。生成的
标记的源是一个由筛选器设置的请求属性,该属性包含一个对象列表,这些对象为属性
名称
提供值

现在有两个问题:

  • 标记不会影响周围
  • 不会迭代从请求属性检索的列表
  • 一般来说,整个组件的行为有点奇怪,因为我可以访问列表中的特定元素并输出其值。但是,只要涉及到
    ,循环就不会输出任何内容

    组件当前的外观如下所示:

    <f:view xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:cc="http://xmlns.jcp.org/jsf/composite"
            xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
            xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
            xmlns:h="http://xmlns.jcp.org/jsf/html">
    
      <!-- INTERFACE -->
      <cc:interface>
      </cc:interface>
    
      <!-- IMPLEMENTATION -->
      <cc:implementation>
        <!-- works, outputs e.g. 'confirmationData' -->
        #{activeContentThreadList[0].name}
    
        <!-- does not work, link URL is unaffected -->
        <f:param name="#{activeContentThreadList[0].displayName}"
                 value="#{activeContentThreadList[0].token}" />
    
        <!-- works, outputs e.g. '[some.package.class@7951a73c]' -->
        <h:outputText value="#{activeContentThreadList}" />
    
        <!-- does not work, nothing is outputted -->
        <c:forEach items="#{activeContentThreadList}" var="asd">
          <h:outputText value="#{asd.name}" />
          <h:outputText value="test in loop" />
        </c:forEach>
      </cc:implementation>
    </f:view>
    
    <h:outputLink value="#{request.contextPath}/confirmation/fields/ordersearch.xhtml" styleClass="ext">
      <cst:activeThreads />
    </h:outputLink>
    
    
    #{activeContentThreadList[0].name}
    
    组件的使用方式如下:

    <f:view xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:cc="http://xmlns.jcp.org/jsf/composite"
            xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
            xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
            xmlns:h="http://xmlns.jcp.org/jsf/html">
    
      <!-- INTERFACE -->
      <cc:interface>
      </cc:interface>
    
      <!-- IMPLEMENTATION -->
      <cc:implementation>
        <!-- works, outputs e.g. 'confirmationData' -->
        #{activeContentThreadList[0].name}
    
        <!-- does not work, link URL is unaffected -->
        <f:param name="#{activeContentThreadList[0].displayName}"
                 value="#{activeContentThreadList[0].token}" />
    
        <!-- works, outputs e.g. '[some.package.class@7951a73c]' -->
        <h:outputText value="#{activeContentThreadList}" />
    
        <!-- does not work, nothing is outputted -->
        <c:forEach items="#{activeContentThreadList}" var="asd">
          <h:outputText value="#{asd.name}" />
          <h:outputText value="test in loop" />
        </c:forEach>
      </cc:implementation>
    </f:view>
    
    <h:outputLink value="#{request.contextPath}/confirmation/fields/ordersearch.xhtml" styleClass="ext">
      <cst:activeThreads />
    </h:outputLink>
    
    
    
    我的问题:

    • 为什么我可以访问特定的列表项,但
      什么都不做
    • 为什么链接URL至少不受单个
      标记的影响
    • 甚至可以将
      标记从内部复合组件输出到周围的链接吗

    对于JSF,复合组件是自己的UIContainer。因此,
    h:outputLink
    -标记没有将
    视为其自身的直接子项,因此将忽略它。您可以通过将标记实现为Facelet自定义组件而不是复合组件来解决这个问题(参见示例)。taglib xml或多或少只指向要包含的对象,这并没有太大的偏移量

    关于
    :JSTL核心属性在某些位置破坏JSF代码,因为它们在JSF之前呈现。在这种情况下,为什么不尝试用
    替换


    希望对您有所帮助……

    我考虑过定制组件,但认为它可能太重,但显然不是。不幸的是,你的答案中有一部分被删掉了。我应该用什么来代替
    ?嗨,马吕斯。好的,更正了错误。嗯,定制组件并没有那么多工作。有时我甚至更喜欢它,因为它比复合组件更好、更容易出错地处理给定的参数(方法、bean等等)。如果我找到了一个很好的教程,我也会把它附在答案上。。。祝你工作顺利!嘿,马吕斯,希望你能解决所描述的问题。如果是,请确认以下答案。:-)我当然会的,刚回到办公室。我尝试了
    ,但没有改变任何事情。因此,不可能生成影响周围链接的
    标记。我最后只使用了一个带有静态参数名的