• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the equivalent of JOptionPane in JSP?

 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I want to get a message when i press the button,so, what's the equivalent of JOptionPane in Jsp?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP is a server-side technology; it has no GUI facilities. On the client-side you can use JavaScript; its "alert" and "confirm" methods fulfill similar purposes.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please give me an example to better understand
where javascript is written?not in a jsp page ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JavaScript can be part of the HTML page (which may be written by a JSP page), or it might be included via a <script src="..."> tag.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put this :

Where i put the <script src="..."> tag?
I want to display a Message like "Are you sure to delete this category?", if i choose "Yes" ,the category deleted from the database and if i choose "no" this operation not performed.
how can i do this ?
Thank you in advance
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sarra Sakka wrote:I put this :

Where i put the <script src="..."> tag?
I want to display a Message like "Are you sure to delete this category?", if i choose "Yes" ,the category deleted from the database and if i choose "no" this operation not performed.
how can i do this ?
Thank you in advance



The script tag goes into the head of the document if you are linking an external JavaScript page. Most likely, it would also go in the head if you are simply writing the JavaScript in the page. Both methods will work



 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to think that JSP is something different from HTML. JSP is just a template for creating an HTML file.

Please read this article to understand this.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sarra Sakka wrote:
I want to display a Message like "Are you sure to delete this category?", if i choose "Yes" ,the category deleted from the database and if i choose "no" this operation not performed.
how can i do this ?


If you don't mind appearances, the window.confirm() JavaScript function should serve your purposes. If you want to get fancier, you'll need to find a dialog plugin.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Raymond Gillespie:i should choose one of these method :
1-

If the jasascipt page is externel.

2-

If the JavaScript in inside the jsp page.
This is what you mean?is not it ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened when you tried?

BTW, I think line 4 of the second approach will not work as is - it doesn't look at the value in that field, but at the field itself.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bear Bibeault: Could you please give me a simple example "dialog plugin" ?
I find this :

what is your opinion about this?
thank you in advance
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried with this code:

Only when i open my page, this message display.
If i want to display it, for example when i pressed a button, how can i do it?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The button needs an onClick handler that calls a JavaScript function - so you need to move the code to a function.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now, i know how can i display a confirm message, thanks to you.
But, i have another problem, how can i delete this category from my database when i click a delete button?

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to submit the form to a URL that can do this. All required information would need to be part of the form submit, maybe the "category" has an ID to identify it.

Note that you should use a POST (and thus an actual form submit) to perform data-altering operations, not a GET like you would be doing in the way you suggest.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean like this:
but, that's no what i want :/

test.png
[Thumbnail for test.png]
That the result with a form
test2.png
[Thumbnail for test2.png]
And this without form
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why isn't that what you want?
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want the result like the second picture.
And when i use form, the first picture that what i get .
If i use the form tag the picture will change :/
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm certain there is a way of turning off repeated background images. Consult an HTML reference for how to do that.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there's a way to turning off repeated background image and i tried it

Now, the image completly disappear :/
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic