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自定义标记上的重复ID_Jsf_Jsf 2_Mojarra_Custom Tag - Fatal编程技术网

嵌套标记时JSF自定义标记上的重复ID

嵌套标记时JSF自定义标记上的重复ID,jsf,jsf-2,mojarra,custom-tag,Jsf,Jsf 2,Mojarra,Custom Tag,由于性能问题,我正在将一些组合迁移到自定义标记。当使用复合时,所有Id都正确生成,但当使用自定义标记时,我有重复Id异常,甚至我创建了一个自定义EL表达式来生成新Id 经过一些研究,似乎是因为嵌套标记时继承了标记属性: <far:fcontainer name="**father1**" type="panel"> <far:fcontainer type="panel"> <far:fcontainer type="panel">child 3<

由于性能问题,我正在将一些组合迁移到自定义标记。当使用复合时,所有Id都正确生成,但当使用自定义标记时,我有重复Id异常,甚至我创建了一个自定义EL表达式来生成新Id

经过一些研究,似乎是因为嵌套标记时继承了标记属性:

<far:fcontainer name="**father1**" type="panel">
 <far:fcontainer type="panel">
  <far:fcontainer type="panel">child 3</farTag:fcontainer>
 </far:fcontainer>
</far:fcontainer>

儿童3
在本例中,第一个fcontainer应该具有idfather1,嵌套的fcontainer应该具有生成的id,但这就是我所拥有的:

<div id="**father1**" class="ui-widget-content">
 <div id="**father1**" class="ui-widget-content">
  <div id="**father1**" class="ui-widget-content">child3</div>
 </div>
</div>

孩子3
自定义标记为:

<ui:composition>
    <p:outputPanel layout="block" styleClass="#{type == 'panel'?'ui-widget-content':''}" 
         id="#{empty name ? far:generateId() : name}">
        <ui:insert />
    </p:outputPanel>
<ui:composition>

这正常吗?有什么解决办法吗

在Mojarra 2.1.26上测试

提前谢谢


更新:在MyFaces 2.1.12上进行了测试,似乎运行良好,Mojarra的bug?

解决此bug的方法是始终使用自定义EL表达式,在其中,您可以首先检查父组件是否设置了属性。

在MyFaces中,id生成算法有一个很大的改进,使其更可预测、更独特,从而更稳定。说来话长,那里有很多艰苦的工作,但在我看来,这是迄今为止解决这个问题的最好办法。Mojarra似乎仍然有旧的facelets 1.1.x算法,我想你在Mojarra中看到的Syntom是由MyFaces 2.2.x中发现的该算法的一些重要缺陷引起的,记住facelets代码也捐赠给了MyFaces,所以这两个实现最初都使用了相同的代码。您可以在生成的标记之前连接一些单词吗?你试过了吗?