2 Replies Latest reply on Dec 14, 2009 5:43 PM by zack de la rocha

    How get selected valuess in backing bean for <h:SelectManyLi

    zack de la rocha Newbie

      I use RF 3.1.3 and Myfaces 1.1.4

      This code is working :
      <f:view>
      <h:form>
      <a4j:region id ="region2">
      <h:selectOneMenu value="#{cursosUsuario.idRegion }" id="cursos">
      <f:selectItems value="#{cursosUsuario.regiones}" />
      </h:selectOneMenu>
      <a4j:commandButton reRender="datos" value="consultar" actionListener="#{cursosUsuario.generaReporte}" />
      </a4j:region>
      <h:outputText value="#{cursosUsuario.showSelectedRoles}" id="datos" />
      </h:form>
      </f:view>

      Bean:
      .................

      private String idRegion; //get and set
      private String showSelectedRoles;

      public void generaReporte(ActionEvent event){

      ValueHolder uic = (ValueHolder) event.getComponent().findComponent("cursos");
      this.showSelectedRoles = (String) uic.getValue();
      ------------------------------------------------------------------------------------------------------
      But when i use multiple selec values
      <f:view>
      <h:form>
      <a4j:region id ="region2">
      <h:selectManyListbox value="#{cursosUsuario.selectedRoles}" id="cursos">
      <f:selectItems value="#{cursosUsuario.regiones}" />
      </h:selectManyListbox>
      <a4j:commandButton reRender="datos" value="consultar" actionListener="#{cursosUsuario.generaReporte}" />
      </a4j:region>
      <h:outputText value="#{cursosUsuario.showSelectedRoles}" id="datos" />
      </h:form>
      </f:view>

      Bean:

      private String[] selectedRoles; //get an set

      public void generaReporte(ActionEvent event){
      -----------------------------------------------------------------
      I Don know how get the multiple selected values:
      ValueHolder uic = (ValueHolder) event.getComponent().findComponent("cursos");
      (?) uic.getValue();???? Array Collection???
      ---------------------------------------------------------------

      thank you, sorry by ny english