Results 1 to 7 of 7

Thread: Map in JSP

  1. #1
    Join Date
    Aug 2004
    Location
    Stuttgart, Germany
    Posts
    9

    Default Map in JSP

    Hello,

    i'm trying to read the value for a map entry from my command object, but i am struggling with the syntax of the EL. Can you help?

    This is what i have in my JSP:

    Code:
          <spring&#58;bind path="$&#123;command.employee.details.number&#125;">
            <label for="<c&#58;out value="$&#123;status.expression&#125;"/>" class="mandat">Number&#58;</label>
            <input name="<c&#58;out value="$&#123;status.expression&#125;"/>"
                   id="<c&#58;out value="$&#123;status.expression&#125;"/>"
                   value="<c&#58;out value="$&#123;status.value&#125;"/>"><br>
            <c&#58;out value="$&#123;status.errorMessage&#125;"/>
          </spring&#58;bind>
    Employee has a Details property which is a Map and contains an entry {"number" -> "123"}. Tomcat says:

    Code:
    javax.servlet.ServletException&#58; Neither Errors instance nor plain target object for bean name '123' available as request attribute
    I am a little bit lost right now. Can you help?

    Thanks for any hints,
    -Stefan

  2. #2

    Default

    Hi

    I think what you are looking for is

    <spring:bind path="command.employee.details[${number}]">

    Simon

  3. #3
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Did that get rid of your "Neither Errors instance" exception?

    I only ever get this error if I have not correctly populated the model that is being rendered by the view.

    This can be caused by going straight to the jsp, not via the controller, or overriding the wrong method in SimpleFormController.

    If you still get this error, can you post your Controller.java

  4. #4
    Join Date
    Aug 2004
    Location
    Stuttgart, Germany
    Posts
    9

    Default

    Hi Simtin, thanks for your reply.

    That at least doesn't throw an exception anymore. Howerever, it seems that the expression evaluates to null, as no value is displayed. Any ideas?

    btw: this is the formBackingObject() method from my controller:

    Code:
      protected Object formBackingObject&#40;HttpServletRequest request&#41;
              throws Exception &#123;
        CommandContainer commandContainer = new CommandContainer&#40;&#41;;
        org.owms.base.model.user.User user = userManagementService.getUser&#40;&#41;;
    
        commandContainer.setEmployee&#40;user&#41;;
        return commandContainer;
      &#125;
    @Yatesco: I'm remotely debugging this thing, and i can see this method returning the commandContainer as it is supposed to.

    Thanks for your responses so far. I will get back studying EL. ;-)

    Any further hints are still greatly appreciated...
    -Stefan

  5. #5
    Join Date
    Aug 2004
    Location
    Stuttgart, Germany
    Posts
    9

    Default

    FYI: The following works without any problem:

    Code:
    <c&#58;out value="$&#123;command.employee.details.number&#125;"/>
    hmmm.. :?

    -Stefan

  6. #6

    Default

    Hm, I can't imagine what your 'map' (?) actually looks like, but when your mentioned c:out works correctly, I think that the following should work:

    <spring:bind path="command.employee.details.number">

    I'm not sure whether I understand you correctly, but may be this works.

    Simon

  7. #7
    Join Date
    Aug 2004
    Location
    Stuttgart, Germany
    Posts
    9

    Default got it working

    fyi: I got it to work properly using the following path:

    Code:
    <spring&#58;bind path="command.workflowInstance.payload.employee.details&#91;'number'&#93;">
    simtin, yatesco, thanks for your support!

    -Stefan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •