<p:selectmanymenu return =“”arraylist =“”size =“”0 =“”

时间:2018-05-26 11:37:22

标签: java jsf primefaces

=“”

我对selectMany有疑问Primefaces的组成部分。

我检查selectManyMenu中的一些选项,但在bean bReservarPista中返回arrayList size 0

<p:selectManyMenu id="manyHoras" value="#{bReservarPista.horasCheckMarcadas}" converter="HoraCheckConverter"
                                  var="horaCheck" filter="true" filterMatchMode="contains" showCheckbox="true" style="height: 235px">
                    <f:selectItems value="#{bReservarPista.horasCheck}" var="horaCheck" itemLabel="#{horaCheck.label}" itemValue="#{horaCheck}" />


                   <p:column>
                        <h:outputText value="#{horaCheck.label}" />
                   </p:column>

                </p:selectManyMenu>

在bean中,foward方法收到arraylist horasCheckMarcadas size 0

 public void setHorasCheckMarcadas(ArrayList<HoraCheck> horasCheckMarcadas) {
    this.horasCheckMarcadas = horasCheckMarcadas;

这是转换器

   @FacesConverter("HoraCheckConverter")

public class HoraCheckConverter implements Converter{
@Override  //Este método lo que hace es devolver un objeto buscado con un string value. 
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if(value != null && value.trim().length() > 0) {
        try {
            // el original de cine. se conectaba a ModeloBD. Podría hacer un ModeloBD aqui, o conectar con el dao
             DaoHoraCheck daohoraCheck =  new DaoImplHoraCheck();
             HoraCheck cat= daohoraCheck.verHoraCheck(Integer.parseInt(value));
            return cat;

        } catch(NumberFormatException e) {
            throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid Cine."));
        }
    }
    else {
        return null;
    }
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {

        try {

    if(value != null) {
        return String.valueOf(((HoraCheck)value).getIdHoraCheck());
    }
    else {
        return null;
    }

      }
      catch (Exception e) {
       return null;
      }

}

由于

0 个答案:

没有答案