Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dropdown menu in Servlet to displayed the selected value

 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a Servlet with a dropdown menu of Items to be selected.
Upon selecting and clicking a submit button, the doPost will be invoked, and another section with some graphics will appear below the dropdown menu. However dropdown menu will no longer show the selected value since the doPost rewrite the dropdown menu.

doPost(){

if click() {
write the dropdown menu and a section with Graphics.
}
}

How can i have the selected value still displayed?

Upon selecting another item (before the submit button is clicked), I want to remove the section again. So that after another item is selected and submit button is clicked, then I shall display a section below with other graphics.

Any help is greatly appreciated.

[ September 11, 2006: Message edited by: Bear Bibeault ]
[ September 11, 2006: Message edited by: Ken Flor ]
 
Lanka Prasad
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ken,

According to you requirement description it is better to apply an AJAX solution.

It needs a little servlet + javascripting.
-Lanka
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for your reply. However we are building from Servlet.

I find it a hassle that Servlet either call doGet or doPost and will override and re-paint the current html screen.
Is there anyway that we can prevent it from override/re-paint the screen? So that my selected value from drop down menu will not be overridden?


thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Flor:

I find it a hassle that Servlet either call doGet or doPost and will override and re-paint the current html screen.
Is there anyway that we can prevent it from override/re-paint the screen? So that my selected value from drop down menu will not be overridden?


Yes, and Lanka just told you what it is.

That you're coding the server side of this app with Servlets (or PHP, or ASP, or Perl, etc..) doesn't change the fact that the end result is going to be client side HTML and Javascript. If you don't want to re-draw the entire screen, you're going to have to do some client side scripting.
[ September 12, 2006: Message edited by: Ben Souther ]
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for all the help rendered.

Can I just check. If I use AJAX, can I embed the AJAX codes in my servlet?

So that dropdown menu is binded to the AJAX. So if i choose something in the dropdown menu, AJAX sent to the the same servlet, and did some processing and return the value without reloading the servlet.
Yet at the same time, if there is another button called "Show Content" on the same servlet, and if I click on this button, it will invoke doGet?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic