Results 1 to 3 of 3

Thread: Spring MVC - accessing model from jsp/javascript view

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Default Spring MVC - accessing model from jsp/javascript view

    Hi,

    Apologies for the ignorance - I'm quite new to all the technologies/frameworks etc mentioned below..

    I have a Spring MVC 3 application (running on Google Apps Engine) where the controller populates some data from a database (a list of "Entry" objects) and sends them to the view which is in JSP and also uses some javascript (to generate a google map).

    I need to access the model from a javascript function. How would I go about it? Here's a pseudo-pseudo () code of what I want to do:

    Code:
    // inside a javascript function
    for (Entry : model.entries) {
       x = entry.getCoords.getX();
       y = entry.getCoords.getY();
       ...
       // and then call javascript function
       jsFunction(x, y, ...);
    }
    Hope that makes sense!

    Thanks

  2. #2

    Red face jstl stylee

    Code:
    //inside javascript funtion
    <c:if test="${not empty entries}">
         <c:foreach var="entry" items="entries">
              x = <c:out value="${entry.coords.x}"/>;
              y = <c:out value="${entry.coords.y}"/>;
              ...
              // and then call javascript function
              jsFunction(x, y, ...);
    
         </c:foreach>
    </c:if>
    assumes your list of stuff is called entries in the model

  3. #3
    Join Date
    Aug 2010
    Posts
    2

    Default

    works thanks!

Tags for this Thread

Posting Permissions

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