如何将 ArrayList/lists/iterables 参数传递给 JSF1.2 自定义组件
我正在尝试显示来自我的支持 bean 的图像列表 它有一个函数
public getImgList(){
return ArrayList<string>imgPathList;
}
现在这个列表必须呈现为等效的输出 并排显示的图像。 就像
[image][image][image]
如果我使用
是不可能的,因为它将每行渲染所有一个, 我找不到任何可以渲染它们的方法 使用自定义组件,因为我必须将图像列表传递给 自定义组件。 谁能解释一下如何将列表传递给 JSF 1.2 Mojarra 中的自定义组件?
I am trying to show a list of images from my backing bean
which has a function
public getImgList(){
return ArrayList<string>imgPathList;
}
Now this List has to be rendered to a equivalent output of
images which are displayed side by side.
like
[image][image][image]
Which is not possible if I use <h:datatable>
, because it will render all of them one per row,
And I cant find any method by which I can render them
using custom component as I will have to pass the list of images to the
custom components.
Can anyone please explain how to pass a list to a custom component in JSF 1.2 Mojarra?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将其指定为属性即可。
在
UIComponent#getValueExpression()
。鉴于您已经在问这个简单的问题,我认为开发自定义组件将花费您很多时间。另外,由于已经存在很多解决方案,因此您基本上是在重新发明轮子。我建议采取不同的路线,即仅使用现有的标签/组件。有两个选项:
使用 JSTL
。如果您不将其放入另一个迭代组件(如
)并且不在循环中渲染输入元素,则此方法将起作用。使用第 3 方组件库,它提供了一个完全有价值的 JSF 迭代组件,该组件不呈现任何 HTML。我建议 Tomahawk 的< /代码>.
Just specify it as attribute.
It'll just be available as exactly the same type in the
value
property of your custom component class with help ofUIComponent#getValueExpression()
.Given the fact that you're already asking this trivial question, I think developing the custom component is going to take a lot of time for you. Also, since a lot of solutions already exist, you're basically reinventing the wheel here. I'd suggest to take a different route, namely just using existing tags/components. There are two options:
Use JSTL
<c:forEach>
. This will work if you don't put it inside another iterating component like<h:dataTable>
and you aren't rendering input elements in the loop.Use a 3rd party component library which offers a fullworthy JSF iterating component which doesn't render any HTML. I'd suggest Tomahawk's
<t:dataList>
.