• Post Reply Bookmark Topic Watch Topic
  • New Topic

Alert box!  RSS feed

 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a standard alert box class available in JFC? or do i need to draw it?

i need alert boxes in a JSP. how can i get them? is there an easy way out?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is JOptionPane in JFC (more commonly called Swing.) This class gives you access to a number of predefined alert boxes. But you can't use Swing in a JSP -- Swing is only for desktop applications. To do an alert box from a JSP, you'd need to embed JavaScript in the JSP, and use JavaScript's "alert()" function.
 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a situation where i cannot call alert from javascript in the JSP.also javascript-jsp communication is very poor.

i looked up in the class JOptionPane but cudnt get any method to "createAlert". it has methods to create dialogs. are they the alerts?

if i make a class that inherits the JOptionPane and draw the desired alert, can i not instantiate it in my JSP?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neeraj Macker:
there is a situation where i cannot call alert from javascript in the JSP.also javascript-jsp communication is very poor.


Such is the nature of Web applications. But things are actually not as bad as you think: you can look into "AJAX", being discussed in several threads in our HTML/JavaScript forum right now.


i looked up in the class JOptionPane but cudnt get any method to "createAlert". it has methods to create dialogs. are they the alerts?


Yes. showMessageDialog() creates what you're calling an "alert."


if i make a class that inherits the JOptionPane and draw the desired alert, can i not instantiate it in my JSP?


You could. But it would run before the user sees the page (since by the time the user sees the HTML page, the JSP code has already run.) And, of course, the Java code in a JSP runs on the Web server, so that's where the alert would pop up! I doubt this is the effect you're going for.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!