コード例 #1
0
 @Override
 public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
   if (object == null) {
     return "";
   }
   if (object instanceof Parametros) {
     Parametros o = (Parametros) object;
     return o.toString();
   } else {
     throw new IllegalArgumentException("O objeto´é de uma classe diferente do esperado");
   }
 }
コード例 #2
0
  @Override
  public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
    if (value == null || value.trim().length() == 0) {
      return null;
    }

    ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
    WebApplicationContext context =
        WebApplicationContextUtils.getWebApplicationContext(servletContext);
    ParametrosDAO dao = context.getBean(ParametrosDAO.class);

    Parametros a = new Parametros();
    a.setValorFrete(new BigDecimal(value));
    Collection<Parametros> lista = dao.search(a);
    return lista.toArray()[0];
  }