mady
mady

Reputation: 23

jstl fn:length tag not working inside spring form tag in a jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

inside a "form:form"

<form:form class="form-container" name ="feedback_popup_form" id="feedback_popup_form"    action="savefeedback" method="post" modelAttribute="feedbackVO" commandName="feedbackVO">

<form:input type="hidden" path="strEmplRefrlSeq" value="${model.strEmplRefrlSeq}" />

<input type="hidden" id="mady" value = "${fn:length(model.strEmplRefrlSeq)}" />

in firebug i am getting

<input id="strEmplRefrlSeq" type="hidden" value="2,10,11," name="strEmplRefrlSeq">
<input id="mady" type="hidden" value="0">

my fn:length is not working for string input. could you please explain why this is happening ?

Upvotes: 2

Views: 2769

Answers (1)

JB Nizet
JB Nizet

Reputation: 692281

The form backing object is placed under the name "feedbackVO", so I guess you actually need

<input type="hidden" id="mady" value="${fn:length(feedbackVO.strEmplRefrlSeq)}" />

Note that the form:input tag doesn't have any value attribute, so your code is equivalent to:

<form:input type="hidden" path="strEmplRefrlSeq" />

which generates the HTML's input value attribute from the path, fetching the value in the command object.

Upvotes: 0

Related Questions