Announcement Announcement Module
Collapse
No announcement yet.
Invoking JavaScript Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invoking JavaScript

    Hi, ye Wizards of Spring!

    Consider the following scenario:

    A user is presented with a searchform of some kind. He/she enters applicable search criteria in an awesome rich user interface 8), and press the "Search" button.

    But, alas, no corresponding item is found in the database. So the user is presented a JavaScript dialog saying something like "No items found" instead of a boring empty result view or even another JSP-page with a similar message. On closing the JavaScript dialog the application of course is ready for another search session in the searchform.

    How do I implement this?

    Thanks in advance!

  • #2
    one way of doing it
    install velocity, this will allow you to easily access data sent by your formbacking or your referendata methods. It might possible to do that with spring tags but I don't know how

    in html in the body tag add a javascript onload=myonload()

    in the onload javascript function write something like
    if ( $result.getSize() < 1){
    alert("no data found...");
    }

    that's it
    note: $result is the way to display data with velocity (part i think of jakarta project)
    the getsize() is whatever will give you the size of the result

    Comment


    • #3
      Hi eg!

      Velocity, huh?
      Hmm, that was a bit more complicated than I had hoped. Already trying to keep up with of Spring, Hibernate, MySQL, J2EE, Java and starting out on Acaegi.... lots of juggling already.

      I was kind of hoping that one could implement a view with a single JavaScript in an onLoad event handler. Problem is to gt back to the search view after however....

      Thanks for answering!

      Comment


      • #4
        Well, it's very(!) early in the morning here and I'm catching a cold which must have weakened my already minimal intelligence....

        This should do it:
        Code:
        <c&#58;if test="$&#123;myResults.size == 0&#125;">
           <script>showNoItemsDialog&#40;&#41;</script>
        </c&#58;if>
        The showNoItemsDialog() function could be declared in an external file and in its turn invoke the reset() function on the current form.

        Of course I'm always interested in further clever solutions.

        Comment

        Working...
        X