Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Demo Application > Displaying User Messages

Displaying User Messages

I created a utility class called RpcStatus, which is used to show messages inside one of two div tags. One div is designed for informational messages, the other for errors or exceptions. Figure 9 shows an informational message and an error message.

An Ajax application shows an error message because the server is down

Figure 9. An Ajax application shows an error message because the server is down

Here is the source code for that utility class.

package com.parkerriver.gwt.intro.client;

import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.DOM;

/**
 * A utility class for displaying messages
 */
public class RpcStatus {
  private String statusDivId;

  public RpcStatus() {
      this("status");
  }

  public RpcStatus(String statusDivId) {
      this.statusDivId = statusDivId;
  }

  public String getStatusDivId() {
      return statusDivId;
  }

  public void setStatusDivId(String statusDivId) {
      this.statusDivId = statusDivId;
  }

  public void showStatus(boolean _on, String message,
                         String color){
      Element el = DOM.getElementById(getStatusDivId());
      if(el != null)  {
          if(_on) {
              DOM.setStyleA....

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint