<table>
<c:if test="${output.list == nul}">
<tr><td><input type="text" /><select></select><input type="text" />
</td>
</tr>
</c:if>
<c:forEach var="iter" items="${output.list}">
<tr><td><input type="text" /><select></select><input type="text" value="${iter.getVal()}" />
</td>
</tr>
</c:forEach>
</tbody>
</table>
If my ${list}
is empty, how can I display .clone
row without duplicating codes or using JavaScript?
I do not know whether I understood your problem. If you want output one row with all content, when list is empty, try next approach:
<table>
<c:forEach var="i" begin="0" end="${not empty list?(fn:length(list)-1):0}">
<tr class="clone">
<td>
<input type="text" />
<select></select>
<input type="text" value="${list[i]!=null?list[i].getVal():''}" />
</td>
</tr>
</c:forEach>
</tbody>
For use fn:
namespace just add in begin of your file <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
Udate: changed according question changes