Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update the screen without reloading jsp/sertvlet ?

 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- I must have a JTREE in my JSP or Servlet. I used MyFaces. Is it good ? Or is there other projects ? We don't want to use applets because we find that it's very slow.
- When i click in a node in the tree i don't want to reload the page to get some properties in the database for this node. I want to get properties
in background and display these properties in a textfield for example.
Is there a way ? a tool for this ?and it must be fast of course for retrieving and displaying my datas.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can make calls to a server from Javascript and then update HTML elements without repainting the whole page. Google on "AJAX" which is all the rage for this kind of thing right now.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JSF forum.
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you mean AJAX If you speak about updating the part of the page without reloading it.

This is a list of the steps have to be done to add AJAX behaviour to the JSF application:

1 Create a Javascript function that returns a XMLHttpRequest/XMLHTTP object appropriate for the browser in use.
2 Create a Javascript function for processing the response XML from the server.
3 Associate your XMLHttpRequest instance�s onreadystatechange delegate with your javascript function.
4 Use the open method on the XMLHttpRequest object to connect to the server.
5 Use the send method on the XMLHttpRequest object to do a transaction.
6 Receive the request on the server side and process it
7 Get access to the application data and change it according to the request
8 Update the Component Tree
9 Extract the difference from the previous interaction and form the responce
10 Receive the response for the server and update the portion of the DOM tree with Javascript function
11 When you need to repeat, reinitialize the XMLHttpRequest and reset its onreadystatechange delegate.

--
Sergey : http://jsfTutorials.net
 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please elaborate on Steps 8, 9 and 10.

I have a JSP page with simple MyFaces components like two inputTexts and a button. What I want is whatever the user types in the first textbox should get into second textbox on click of the button. I am trying to use Ajax for this. My approach is to have a separate Ajax Servlet and return the response to the JSP.
When I test, I see that the response is captured by JSP page and the textbox gets the data into it.... but just for a second or so. After that the page appears to reload and the textbox loses its data and is blank.

I guess I am not implementing the steps correctly.

Can someone please suggest a simple Hello World for this.

Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic