Announcement Announcement Module
No announcement yet.
accessing spring variables from struts html taglib Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • accessing spring variables from struts html taglib

    It seeems that the standard spring way to specify the selected item in an option menu (drop down list) is by looping through a list and checking each value for equality with a c:if statement (or using ternary ? operator), something like this:

    <spring:bind path="tableInfo.table">
    <select name="<c:out value="${status.expression}"/>">
    <c:forEach items="${tableInfo.tables}" var="table">
    <option value="<c:out value='${table}'/>"
    <c:if test="${table eq tableInfo.table}">selected</c:if>>
    <c:out value="${table}"/>

    This compares poorly to the html:options tag provided with struts which can automatically deduce the selected item in the list. Is there any way to use html:options with a spring backed form? I couldn't get it to work, but it could look something like this:

    <spring:bind path="tableInfo.table">
    <html:select property="${tableInfo.table}">
    <html:options collection="${tableInfo.tables}"/>

    I guess the problem is that the html:options tag looks for a struts backed form to determine what is the current tableInfo.table value? Or maybe it's a namespace resolution conflict between struts and spring? It would be nice to be able to use the struts html tags to access spring variables, has anyone done this?