File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How to update the screen without reloading jsp/sertvlet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to update the screen without reloading jsp/sertvlet ?" Watch "How to update the screen without reloading jsp/sertvlet ?" New topic
Author

How to update the screen without reloading jsp/sertvlet ?

Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
- 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

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

Moved to the JSF forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
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

Joined: Sep 27, 2004
Posts: 114
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to update the screen without reloading jsp/sertvlet ?