Reputation: 251
I need to change (parse) one of the object property. Is it any way I can save the parse value in the js variable and then pass it back. This is what I tried but it does not work:
<c:forEach var="user" items="${requestScope.users}">
var parsedName= parseUserName("${user.name}");
<c:set target = "${user}" property = "parsedName" value ="${parsedName}"/>
</c:forEach>
Upvotes: 0
Views: 6097
Reputation: 41
If possible try to implement the parseUserName() logic in JSP itself using JSTL.
If you need help with that post the JS method logic here.
Upvotes: 0
Reputation: 982
No it is not possible to do what you are trying to do. The only possible solution is to send the variable to the server using a partial refresh and set the required property once the page has been refreshed
Upvotes: 2
Reputation: 9179
Your idea is:
<c:forEach var="user" items="${requestScope.users}">
<script type="javascript">
var parsedName= parseUserName("${user.name}");
</script>
<c:set target = "${user}" property = "parsedName" value ="${parsedName}"/>
</c:forEach>
unfortunately it is not possible.
The jstl
code happen on the server side and javascript on the client side.
Upvotes: 2