List 有条件地包装HTML元素
在我的Seam应用程序中,我有一个Seam组件,它返回一个(List 有条件地包装HTML元素,list,jsf,seam,List,Jsf,Seam,在我的Seam应用程序中,我有一个Seam组件,它返回一个(@Datamodel)列表,其中列出了我要转换为一组HTML元素的项。我有这个工作没有问题 但是现在,我想根据EL表达式来划分列表。因此EL表达式确定是否应启动新的元素。我尝试了以下方法: <s:fragment rendered="#{action.isNewList(index)}"> <ul> </s:fragment> <!-- stuff that does the <li&
@Datamodel
)列表,其中列出了我要转换为一组
HTML元素的项。我有这个工作没有问题
但是现在,我想根据EL表达式来划分列表。因此EL表达式确定是否应启动新的
元素。我尝试了以下方法:
<s:fragment rendered="#{action.isNewList(index)}">
<ul>
</s:fragment>
<!-- stuff that does the <li>'s goes here -->
<s:fragment rendered="#{action.isNewList(index)}">
</ul>
</s:fragment>
但是这是无效的,因为
的嵌套是错误的
我该怎么做呢?我不熟悉Seam框架,但如果我正确理解了问题,类似的方法可能会奏效
<!-- before your loop, open your first <ul> if the (@Datamodel) is not empty -->
<s:fragment rendered="#{action.isNewList(index)}">
</ul>
<ul>
</s:fragment>
<!-- stuff that does the <li>'s goes here -->
<!-- after your loop, close your last </ul> if the (@Datamodel) is not empty -->
我对Seam不太熟悉,但我在使用XSLT和其他基于XML的框架时也遇到过同样的问题
通常有两种解决方案:
您应该有如下内容(我将使用伪代码):
-
您可以使用JSF
标记来实现这一点,该标记虽然不漂亮,但很有效:
<f:verbatim rendered="#{action.isNewList(index)}">
<ul>
</f:verbatim>
<!-- stuff that does the <li>'s goes here -->
<f:verbatim rendered="#{action.isNewList(index)}">
</ul>
</f:verbatim>
保险商实验室
/保险商实验室
我们需要了解您是如何迭代的。请发布更多的代码。以及所述代码的输出,以便我们可以看到嵌套的无效之处。没有输出,但显然不是格式良好的xml,因为嵌套发生了。不,这不起作用,因为xml的嵌套是错误的。
<f:verbatim rendered="#{action.isNewList(index)}">
<ul>
</f:verbatim>
<!-- stuff that does the <li>'s goes here -->
<f:verbatim rendered="#{action.isNewList(index)}">
</ul>
</f:verbatim>