1 17 package org.alfresco.web.ui.common.converter; 18 19 import java.util.ResourceBundle ; 20 21 import javax.faces.component.UIComponent; 22 import javax.faces.context.FacesContext; 23 import javax.faces.convert.Converter; 24 import javax.faces.convert.ConverterException; 25 26 import org.alfresco.web.app.Application; 27 28 33 public class BooleanLabelConverter implements Converter 34 { 35 38 public static final String CONVERTER_ID = "org.alfresco.faces.BooleanLabelConverter"; 39 40 private static final String MSG_YES = "yes"; 41 private static final String MSG_NO = "no"; 42 43 46 public Object getAsObject(FacesContext context, UIComponent component, String value) 47 throws ConverterException 48 { 49 return Boolean.valueOf(value); 50 } 51 52 55 public String getAsString(FacesContext context, UIComponent component, Object value) 56 throws ConverterException 57 { 58 ResourceBundle bundle = Application.getBundle(context); 59 60 String result = bundle.getString(MSG_NO); 61 62 if (value instanceof Boolean ) 63 { 64 result = ((Boolean )value).booleanValue() ? bundle.getString(MSG_YES) : bundle.getString(MSG_NO); 65 } 66 67 return result; 68 } 69 } 70 | Popular Tags |