Announcement Announcement Module
No announcement yet.
Problem with Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with

    Hi there.

    Here is my problem..

    Im having difficulty with setting the selected attribute for the option element in a <select> using jspx.

    2 ways I tried:

    <select name="customername">
    <c:forEach items="${customers}" var="cust">
    <option value="${}" ${ == status.value ? ' selected' : ''}>${}</option>

    Error: Element type "option" must be followed by either attribute specifications, ">" or "/>".
    I cannot do it in this way because jspx is xml based.

    <select name="customername">
    <c:forEach items="${customers}" var="cust">

    <jsp:element name="option">
    <jsp:attribute name="value">${}</jsp:attribute>
    <c:if test="${ == status.value}">
    <jsp:attribute name="selected">true</jsp:attribute>


    Error: Attribute selected invalid for tag if according to TLD
    TLD does not allow this.

    If anyone could give me advise on how to fix this or have another way of doing this. Help will be appreciated.


  • #2
    Hi. Fixed my problem. If any one else working with jspx's have this problem, this is what I did in the end. I used the the jakarta-input-taglibs.

    My controller:
    java.util.HashMap a;
    java.util.Hashtable o;
    java.util.TreeMap map;
    // Pupulate Cutomer and set it according to the Order.Customer object //
    a = new java.util.HashMap();
    a.put("onchange", "submit();");
    List customers = custMan.getCustomers();
    o = new java.util.Hashtable();
    o.put("--Select--", "");
    for(int x = 0; x < customers.size(); x++){
    Customer cust = (Customer) customers.get(x);
    o.put(cust.getName(), cust.getId());

    map = new java.util.TreeMap(o);


    My jspx:
    <td>Customer Name: </td><!-- Maak reg die goed -->
    <spring:bind path="">
    <input:select name="${status.expression}" default="${}"
    attributes="${CustAttributes}" options="${CustNames}" />
    <font color="red"><c:out value="${status.errorMessage}"/></font>