Reputation: 7955
In my Seam application, I have a Seam component that returns a (@Datamodel
) list of items I want to transform into a set of <li>
HTML elements. I have this working without a problem.
But now, I want to split up the list according to an EL expression. So the EL expression determines if a new <ul>
element should be started. I tried the following:
<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>
But that's invalid, because the nesting for <ul>
is wrong.
How should I do this?
Upvotes: 0
Views: 748
Reputation: 17344
You can do this using the JSF <f:verbatim>
tag, which isn't pretty but works:
<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>
Upvotes: 1
Reputation: 9922
You should have something like this (i will use pseudo code):
<ul>
<s:for items="itemList" ...>
<s:fragment rendered="#{action.isNewList(index) && index > 0}">
</ul>
<ul>
</s:fragment>
<li>
<!-- stuff that does the <li>'s goes here -->
</li>
</s:for>
</ul>
Upvotes: 0
Reputation: 1211
I'm not familiar with Seam specifically, but I've seen this same problem come up when working with XSLT and other XML-based frameworks.
There are generally two solutions:
Upvotes: 0
Reputation: 5593
I'm not familiar with the Seam Framework, but if I understand the problem correctly something like this might work.
<!-- 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 -->
Upvotes: 0