5 Replies Latest reply on Mar 31, 2010 7:30 AM by ilya_shaikovsky

    Limit Rich:pickList

    lgweb

      Is there any way to limit one (<rich:pickList ..>) to be selected only one of the options or all options?
      any help is welcome.
      Thank you.

        • 1. Re: Limit Rich:pickList
          ilya_shaikovsky

          pickList actually is selectManu component. But you could limit selection by attaching validator.

          • 2. Re: Limit Rich:pickList
            lgweb

            But how to capture the amount of items that are available for
            selection.

            • 3. Re: Limit Rich:pickList
              lgweb

              See my incomplete Validator:

               


                  @Override
                  public void validate(FacesContext fd, UIComponent uiComponent, Object itensSelecionados)
                          throws ValidatorException {       
                      List<String> selecoes =(List<String>)itensSelecionados;
                      HtmlPickList  pc =  (HtmlPickList) uiComponent.findComponent("selAcessoRestrito");
                      pc.getSize();
                      System.out.println("Child size()"+pc.getChildren().get(0).getChildCount());   
                      System.out.println("size....:"+pc.getSize());
                  }

              why get list.size() ??

              • 4. Re: Limit Rich:pickList
                lgweb

                Thanks ilya, this problem is solved see:

                 

                 

                @Override
                    public void validate(FacesContext fc, UIComponent uiComponent, Object itensSelecionados)
                            throws ValidatorException {       
                        List<String> selecoes =(List<String>)itensSelecionados;       
                        MBRelatorio controller = (MBRelatorio)fc.getExternalContext().getRequestMap()
                        .get("mBRelatorio");
                        int listSize = controller.getListaAreaGestora().size();
                        if(selecoes !=null){
                            if( selecoes.size() < listSize  && selecoes.size() > 1 ){
                                throw new ValidatorException(MessageFactory.getMessage(
                                        QUANTIDADE_SELECOES_INVALIDA, MessageFactory.getLabel(
                                                fc, uiComponent)));
                               
                            }
                        }
                   
                       
                    }

                • 5. Re: Limit Rich:pickList
                  ilya_shaikovsky

                  assumed answered