Ce contenu n'est pas disponible dans la langue sélectionnée.

25.2. Preparing your component


To prepare a Seam component to be called with GWT, you must first create both synchronous and asynchronous service interfaces for the methods you wish to call. Both interfaces should extend the GWT interface com.google.gwt.user.client.rpc.RemoteService:
public interface MyService extends RemoteService { 
  public String askIt(String question);      
}
Copy to Clipboard Toggle word wrap
The asynchronous interface should be identical, except for an additional AsyncCallback parameter for each of the methods it declares:
public interface MyServiceAsync extends RemoteService { 
  public void askIt(String question, AsyncCallback callback); 
}
Copy to Clipboard Toggle word wrap
The asynchronous interface (in this case, MyServiceAsync) is implemented by GWT, and should never be implemented directly.
The next step is to create a Seam component that implements the synchronous interface:
@Name("org.jboss.seam.example.remoting.gwt.client.MyService")
public class ServiceImpl implements MyService {

  @WebRemote
  public String askIt(String question) {
   
    if (!validate(question)) {
      throw new IllegalStateException("Hey, this shouldn't happen, " + 
                                      "I checked on the client, but " +
                                      "it's always good to double check.");
    }
    return "42. Its the real question that you seek now.";
  }
   
  public boolean validate(String q) {
    ValidationUtility util = new ValidationUtility();
    return util.isValid(q);
  }
}
Copy to Clipboard Toggle word wrap
The Seam component's name must match the fully-qualified name of the GWT client interface (as shown), or the Seam Resource Servlet will not be able to find it when a client makes a GWT call. Methods that GWT will make accessible must be annotated with @WebRemote.
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat