Items of <p:selectOneMenu/> do not appear

Asked

Viewed 316 times

0

I’m developing a web application and java web jsf primefaces, <f:selectItems/> do not appear

Look at this

inserir a descrição da imagem aqui

 <h:panelGroup layout="block" styleClass="parcelas">
                       <p>Parcelas:</p> <p:selectOneMenu id="tamanhos" value="#{parcela.parcelas}" styleClass="tamanho" effect="fold" editable="true">
        <f:selectItem itemLabel="Selecione " itemValue=""/>
        <f:selectItems value="#{parcela.Parcelas()}"/>
    </p:selectOneMenu>
                     </h:panelGroup>   

                       <h:panelGroup layout="block" styleClass="tamanho">
                       <p>Tamanho:</p> <p:selectOneMenu id="tamanhos" value="" styleClass="tamanho" effect="fold" editable="true">
        <f:selectItem itemLabel="Selecione " itemValue=""/>
        <f:selectItems value="#{tamanho.Tamanhos()}"/>
    </p:selectOneMenu>

        </h:panelGroup>

         @ManagedBean(name="tamanho")
       @RequestScoped
       public class Tamanho {

     private Map<String,String> tamanhos = new HashMap<String, String>();


private String tamanho;

public  Map<String, String> Tamanhos(){

tamanhos = new HashMap<String, String>();
    tamanhos.put("PP", "PP");
   tamanhos.put("P","P");
    tamanhos.put("M","M");
    tamanhos.put("G","G");
    tamanhos.put("GG","GG");

    return tamanhos;
    } 

public String getTamanho() {
    return tamanho;
}

public void setTamanho(String tamanho) {
    this.tamanho = tamanho;
}
}


@ManagedBean(name="parcela")
@RequestScoped
public class Parcelas {

private int parcelas;

 private Map<Integer,Integer> parcela= new HashMap<Integer,Integer>();



 public  Map<Integer, Integer> Parcelas(){

parcela = new HashMap<Integer, Integer>();
    parcela.put(1, 1);
    parcela.put(2, 2);
      parcela.put(3, 3);
        parcela.put(4, 4);
          parcela.put(5, 5);
            parcela.put(6, 6);
              parcela.put(7, 7);

          parcela.put(8, 8);
            parcela.put(9, 9);
              parcela.put(10,10);
                parcela.put(11,11);
                  parcela.put(12, 12);

    return parcela;
    } 






public int getParcelas() {
    return parcelas;
}

public void setParcelas(int parcelas) {
    this.parcelas = parcelas;
}

}

1 answer

0


  • man I put it the way you told me but select items is gone

  • Did you test it too? <f:selectItems value="#{size.Sizes()}" var="t" itemValue="#{t. key}" itemLabel="#{t. value}"/>

  • Face I really think you’ll have to change your get method!

  • It has to look like this public Map<String, String> getTamanho() { Return Sizes; }

  • that’s right, thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.