You can make your UI much easier on your users by giving them clues on what is taking place when they click buttons, enter text or choose items in a picklist. This example shows how you can notify a user that something is taking place in the background when you are performing actions asynchronously. For the sake of example, it uses both facets and JavaScript.
You can run this example on my Developer Site.
In this example the user simply enters their name in the text box. In the code below we've added an actionSupport component to the inputText component. This allows us to invoke a method (specified in the action attribute) in the controller as the result of a JavaScript event.
The attributes for the actionSupport component indicate:
action - the method to be invoked in the controllerevent - the JavaScript event that invokes the method
reRender - the IDs of the components that are redrawn as a result of the AJAX update request returned from the controller
status - the ID of the component that displays the status of the AJAX update request</blockquote>
So when the user enters their name and removes focus from the text box, the JavaScript event fires and invokes the method in the controller. The status component is also invoked to display the messages to the user. In this case the start attribute calls the JavaScript start(); method which dynamically modifies HTML elements on the page.When the AJAX call returns from the controller, the actionStatus component specifies that the stop facet should be displayed as well as the stop(); JavaScript method. This modifies HTML elements and displays messages to the user. The actionSupport component reRenders the pageMessage and thankyou outputPanels so that our new messages from the controller display properly.
The controller for this example is fairly simple. The constructor simply initializes the value of counter to 0 when initially loaded. Each time that the user removes focus from the textbox, the processName method is called. This method increments the counter and then hands off some text to the addThankYou and addPageMessage methods. These methods construct the text for the messages displayed to the user.
FYI... not every Visualforce component support partial page refreshes. If you are using one that is not supported, you can wrap it in an outputPanel component so that it can be reRendered.