how to get the selected value in the combobox (h:Selectonemenu )?

Asked

Viewed 253 times

1

<h:form>
  <div class="form-group">
    <label>Categoria de Produto</label>
    <h:selectOneMenu value="#{produtoController.produto.categoriaProduto}" styleClass="form-control" style="width: auto">
      <f:selectItem itemLabel="Selecione uma mesa" itemDisabled="false" />
      <f:selectItems value="#{produtoController.listaCategorias}" var="categoria" itemLabel="#{categoria.descricao}" itemValue="#{categoria}" />
    </h:selectOneMenu>
  </div>
  <div class="form-group">
    <label>Descrição do Produto</label>
    <h:inputTextarea value="#{produtoController.produto.descricao}" cols="80" rows="2" class="form-control" />
    <h6 class="help-block">Ex: Um hambúrgues, alface, tomate, milho, ovo, calabresa, bacon, catupiry</h6>
  </div>
  <div class="form-group">
    <label>Marca / Fornecedor</label>
    <h:selectOneMenu value="#{produtoController.produto.marca}" styleClass="form-control" style="width: auto" rendered="true">
      <f:selectItem itemLabel="Selecione uma mesa" itemDisabled="false" />
      <f:selectItems value="#{produtoController.listaMarcas}" var="marca" itemLabel="#{marca.nomeMarca}" itemValue="#{marca}" />
    </h:selectOneMenu>
  </div>
  <hr/>
  <h:commandButton value="Cadastrar" action="#{produtoController.Salvar()}" class="btn btn-default" style="margin-left: 5px" />
</h:form>

I’m not getting the value of the combos. If I select them, it does not enter the h:commandButton method. But if I DO NOT select combos, the method is executed.

I have tested with Valuechangelistener, p:ajax (using the Systener). Using these I can only capture the first selectOneMenu and run the commandButton method, but the value of the second Selectonemenu is null :(

What could be?

  • Does a mistake happen? Put your class Productocontroller.

No answers

Browser other questions tagged

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