Este contenido no está disponible en el idioma seleccionado.

31.2. Annotations


Seam also provides annotations to let you use Seam components as JSF converters and validators:
@Converter
@Name("itemConverter") 
@BypassInterceptors 
@Converter 
public class ItemConverter implements Converter { 
  @Transactional 
  public Object getAsObject(FacesContext context, UIComponent cmp, 
                            String value) { 
    EntityManager entityManager = 
      (EntityManager) Component.getInstance("entityManager"); 
    entityManager.joinTransaction(); // Do the conversion 
  } 
  public String getAsString(FacesContext context, UIComponent cmp, 
                            Object value) { 
    // Do the conversion 
  } 
}
Copy to Clipboard Toggle word wrap
<h:inputText value="#{shop.item}" converter="itemConverter" />
Copy to Clipboard Toggle word wrap
Registers the Seam component as a JSF converter. Here, the converter accesses the JPA EntityManager inside a JTA transaction when converting the value back to its object representation.
@Validator
@Name("itemValidator") 
@BypassInterceptors 
@org.jboss.seam.annotations.faces.Validator 
public class ItemValidator implements javax.faces.validator.Validator { 
  public void validate(FacesContext context, UIComponent cmp, 
                       Object value) throws ValidatorException { 
    ItemController ItemController = 
      (ItemController) Component.getInstance("itemController"); 
    boolean valid = itemController.validate(value); 
    if (!valid) { 
      throw ValidatorException("Invalid value " + value); 
    } 
  } 
}
Copy to Clipboard Toggle word wrap
<h:inputText value="#{shop.item}" validator="itemValidator" />
Copy to Clipboard Toggle word wrap
Registers the Seam component as a JSF validator. Here, the validator injects another Seam component; the injected component is used to validate the value.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat