package commons;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import com.gtp.domain.Authority;
public class AuthoryConverter implements Converter {
public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
if (value == null || value.equals("")) {
return null;
}
String[] s = value.split("-");
Authority a= new Authority();
a.setId(Integer.parseInt(s[0]));
a.setName(s[1]);
a.setUrl(s[2]);
return a;
}
public String getAsString(FacesContext facesContext, UIComponent component, Object value) {
if(value == null)
return null;
else
return value.toString();
}
}