Results 1 to 2 of 2

Thread: Regarding javascript in spring

  1. #1
    Join Date
    Nov 2005
    Posts
    148

    Question Regarding javascript in spring

    Hi,

    i want to pass my messages from message resource to javascript function. So i can perorm some validation on client side (complusory field validation and other etc).
    i want something like this:

    <body onload="loadmessages(<spring:message code="application.ajx.server.error"></spring:message>,<spring:message code="application.publisher.error.ajax.zone"></spring:message>)">

    ------some code here----

    </body>
    How i can achieve it?

    Regards.
    Shahzad

  2. #2

    Default

    This is fairly simple, you just need to write them into the body of the JSP:

    Code:
    var messageResolver = new Array();
    messageResolver["login.error"] = "<spring:message code="error.login.general"/>";
    messageResolver["login.username"] = "<spring:message code="error.login.username"/>";
    messageResolver["login.password"] = "<spring:message code="error.login.password"/>";
    // etc...
    Be sure to escape any apostrophes or quotes in the error messages or you'll get a javascript error.

Posting Permissions

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