[jboss-user] [JBoss Seam] - Re: Custom Converter

pete.muir@jboss.org do-not-reply at jboss.com
Tue Nov 6 08:05:11 EST 2007


Try

@org.jboss.seam.annotations.jsf.Converter
  | @Intercept(InterceptionType.NEVER)
  | @Name("memberSourceConverter")
  | public class MemberSource implements Converter {
  | 
  |    @Override
  |    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) throws ConverterException {
  |       return value;
  |    }
  | 
  |    @Override
  |    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) throws ConverterException {
  |    String convertedValue = "";
  |    if (Constant.Member.Source.ONLINE.equalsIgnoreCase((String)value)) {
  |       convertedValue = "Online";
  |    } else if (Constant.Member.Source.QTISC.equalsIgnoreCase((String)value)) {
  |       convertedValue = "QTISC";
  |    } else if (Constant.Member.Source.CURRICULUM_COUNCIL_RESULT.equalsIgnoreCase((String)value)) {
  |       convertedValue = "CC Year11";
  |    } else {
  |       FacesMessage facesMsg = new FacesMessage("Converstion error.", String.format("Invalid member status %s.", ((String) value)));
  |       facesMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
  |       FacesMessages.instance().add(facesMsg);
  |       throw new ConverterException(facesMsg); <-- exception thrown here...
  |    }
  |    return convertedValue;
  | }

 <h:outputText value="#{clientHome.instance.source}" converter="memberSourceConverter"></h:outputText>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102199#4102199

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102199



More information about the jboss-user mailing list