Results 1 to 4 of 4

Thread: Invoking JavaScript

  1. #1
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default 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!
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  2. #2
    Join Date
    Sep 2004
    Posts
    2

    Default

    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

  3. #3
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    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!
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  4. #4
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    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.
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  4. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

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