0 Replies Latest reply on Mar 27, 2002 1:29 AM by winghoe

    Struts: Problem using <html:options> tag, request.get/setAtt

    winghoe

      Hi,
      In my Action class, I have these statements:

      ChargeTypeList chargeTypeList = new ChargeTypeList();
      request.setAttribute("chargeTypeListLabel",chargeTypeList.getLabel());
      request.setAttribute("chargeTypeListProps", chargeTypeList.getProperty());

      Both getLabel() and getProperty() methods return Collection objects.

      In my JSP page the codes for retrieval are as below:

      <%
      Collection cChargeTypeListLabel = (Collection)request.getAttribute("chargeTypeListLabel");
      pageContext.setAttribute("chargeTypeListLabel", cChargeTypeListLabel, PageContext.PAGE_SCOPE);

      Collection cChargeTypeListProps = (Collection)request.getAttribute("chargeTypeListProps");
      pageContext.setAttribute("chargeTypeListProps", cChargeTypeListProps, PageContext.PAGE_SCOPE);
      %>

      In the html section:

      <html:select property="selChargeType">
      <html:options name="chargesForm" labelName="chargesForm" labelProperty="chargeTypeListLabel" property="chargeTypeListProps"/>
      </html:select>

      I get NullPointerException if I use this option.

      <html:select property="selChargeType">
      <html:options name="chargeTypeListProps" labelName="chargeTypeListLabel"/>
      </html:select>

      I get "Can't find bean under name " error message if I use this option.

      What am I doing wrong? I can't seem to be able to use System.out.println() to test it either.

      I'm suspecting that request.setAttribute() in my Action class is not executed and request.getAttribute() in my JSP can't retrieve the set attributes.

      Any comments and examples would be appreciated greatly.

      Thanks.

      Wing Hoe