I want to be abl开发者_StackOverflow社区e to show some data based on criteria the user enters in a text field. I can easily take this data, process the form post, and show the data on another page. However, I want to be able to do it all on the same page - they click the button, and a new div shows up with the information. This doesn't seem too complicated, but I want to use jstl tags to format the data like:
<c:forEach items="${model.data}" var="d">
<tr>
<td><fmt:formatDate type="date" dateStyle="short" timeStyle="default" value="${d.reportDate}" /></td>
<td><c:out value="${d.cardType}"/></td>
</tr>
</c:forEach>
If jstl tags are processed when the page loads, can I use that in this new div? Can I update it via a javascript (using prototype) function to display the proper data? Will I be able to do the same thing if they change the criteria and click the submit button again?
No, you can't. You already said yourself, JSTL only runs at the server side. As you're running this entirely at the client side, your only resort is to use JavaScript to populate the table. I've posted similar answers before here and here with code examples how to populate a table with help of jQuery, JSON, Google Gson and a Servlet. I know that you're using Prototype, but the jQuery syntax should be recognizeable enough to port it to Prototype syntax without any problems.
精彩评论