Announcement Announcement Module
Collapse
No announcement yet.
Regarding javascript in spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X