问题描述
我正在使用ui:repeat标记来渲染图像.我有五个图像,我希望在每次迭代中我的图像都获得像image1,image2,image3 .... imagen这样的ID.我试过了,但是没用.
I am using ui:repeat tag which render images. I have five images i want that on each iteration my image get ids like image1, image2, image3.... imagen. I tried this but it is not working.
<div id="imageGallery">
<ui:repeat value="#{countryPages_Setup.images}" var="image" varStatus="status">
<tr>
<td>
<a href="javascript:void()" class="launchLink">
<p:graphicImage id="image#{status.index}" //problem
value="/resources/images/#{image}"
width="100"
height="100"
rendered="#{countryPages_Setup.renderImages}"/>
</a>
</td>
</tr>
</ui:repeat>
</div>
我还尝试了{staus.index + 1}.我也尝试过id = image#{1 ++},但它也不起作用.我该怎么办?
I also tried {staus.index + 1}. I also tried id= image#{1++} But it is also not working. How can i do it?
谢谢
推荐答案
您不能在id
属性内使用el表达式.它必须是静态的. ui:repeat
本身会为您的ID生成一个前缀.您不需要关心唯一性.
You cannot use el expressions within the id
attribute. It needs to be static. The ui:repeat
itself generates a prefix to your id. You don't need to care about uniqueness.
例如,如果您有id="image"
,则生成的ID为
So, for instance if you have an id="image"
, then the generated ids are
somePrefix:0:image
,somePrefix:1:image
,...
这篇关于如何使用ui:repeat标签在dataTable中动态生成ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!