How to link label with an input field in data table?
I am curious if there is a nice way to link a label to input field in a data table directly in JSP? Data filling the table are dynamically bounded.
Sample, simplified code below. Values of "label" property are unique in the collection binded to dataTable.
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" />
<f:view>
<html>
<body>
<h:dataTable value="#{screen$monitoring$errorlog$CorrectHopper.dataset}" var="DATA_ROW">
<h:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputLabel value="#{DATA_ROW.label}" for="#{DATA_ROW.label}_id" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Value" />
</f:facet>
<h:inputText value="#{DATA_ROW.label}" id="#{DATA_ROW.label}_id" />
</h:column>
</h:dataTable>
</body>
</html>
</f:view>
</jsp:root>
returns:
17:39:01,390 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: #{DATA_ROW.label}_id
what is related to EL expression in h:inputText's "id" attribute.
Is there any other way to bind label with dynamically created input field in JSP? Do I really have to bind input field directly to component objects with "binding" and set IDs manually with setId() (what is ugly solution because it moves View related logic to Model layer)?

