Results 1 to 4 of 4

Thread: Default Model

  1. #1

    Default Default Model

    Hi,
    i have a little question.
    I need to add to all models of my application some common objects such as UserProfile to pass the username and so on to the view.

    How to do this? Do you suggest to create a baseCommand and extend it by every form commands?

    Thank you.

  2. #2
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default

    I would store the userProfile object on the session and that way any view can reference it.

  3. #3

    Default

    Not bad... so i accet it with ${sessionScope...}

    Thank you.

  4. #4
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default

    You can just use jstl to access the object. So for example, say you have a UserProfile object with a attribute of username.

    You would first store the object by setting:
    Code:
    request.getSession().setAttribute("userProfile", userProfile);
    Then you can access it in the jsp using:
    Code:
    <c:out value="${userProfile.username}"/>

Posting Permissions

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