<?xml version="1.0" encoding="ISO-8859-1"?>

<jsp:root	xmlns:jsp="http://java.sun.com/JSP/Page" 
				xmlns:c="http://java.sun.com/jsp/jstl/core" 
				xmlns:fe="http://www.emdt.ardeo.net/jsp/fe"
				xmlns:bean="http://jakarta.apache.org/struts/tags-bean"
				xmlns:webapp="http://www.emdt.ardeo.net/jsp/webapp"
				xmlns:logic="http://struts.apache.org/tags-logic"
				version="2.0">
	<jsp:directive.page contentType="text/html" />
	<fe:formElement var="fe" element="${currentElement}"/>
	<fe:getAttribute var="size" element="${currentElement}" attribute="size"/>
	<c:set var="values" value="${xmlFormCtx.data[fe.id]}"/>
	<fe:forEach var="node" element="${currentElement}">
		<c:choose>
			<c:when test="${node.nodeName == 'item'}">
				<fe:formElement var="option" element="${node}"/>
				<c:set var="selected" value="false"/>
				<c:forEach var="val" items="${values}">
					<c:if test="${option.value == val}">
						<c:set var="selected" value="true"/>
					</c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${selected == 'true'}">
						<input type="checkbox" id="<c:out value="${fe.id }"/>" name="<c:out value="${fe.id }"/>" value="<c:out value="${option.value}"/>" checked="checked"/>
					</c:when>
					<c:otherwise>
						<input type="checkbox" id="<c:out value="${fe.id }"/>" name="<c:out value="${fe.id }"/>" value="<c:out value="${option.value}"/>"/>
					</c:otherwise>
				</c:choose>
				<c:out value="${option.label}"/><br/>
			</c:when>
			<c:when test="${node.nodeName == 'named-list'}">
				<fe:getAttribute var="nlName" element="${node}" attribute="name" />
				<fe:getAttribute var="nlDomain" element="${node}" attribute="domain" />
				<webapp:namedList name="${nlName }" domain="${nlDomain }" id="nl"/>
				<c:forEach var="pair" items="${nl.pairs }">
					<c:set var="selected" value="false"/>
					<c:forEach var="val" items="${values}">
						<c:if test="${pair.first == val}">
							<c:set var="selected" value="true"/>
						</c:if>
					</c:forEach>
					<c:choose>
						<c:when test="${selected == 'true'}">
							<input type="checkbox" id="<c:out value="${fe.id }"/>" name="<c:out value="${fe.id }"/>" value="<c:out value="${pair.first}"/>" checked="checked"/>
						</c:when>
						<c:otherwise>
							<input type="checkbox" id="<c:out value="${fe.id }"/>" name="<c:out value="${fe.id }"/>" value="<c:out value="${pair.first}"/>" />
						</c:otherwise>
					</c:choose>
					<c:out value="${pair.second}"/><br/>
				</c:forEach>
			</c:when>
		</c:choose>
	</fe:forEach>
</jsp:root>