4 Replies Latest reply on Mar 8, 2013 5:35 AM by Andreas Panagiotidis

    disable all jsf and richfaces elements within a panel

    bb bb Master

      Hy!

       

      How can I disable all richafces/jsf elements  within a rich:panel/a4j:panel/div/form?

       

      thanks.

        • 1. Re: disable all jsf and richfaces elements within a panel
          Ilya Shaikovsky Master

          the case isn't clear. do them need to became disabled  afte you sending some request before it completed, or on initial rendering till some conditions will be meet or something else? If your goal is to disable all the components by just JS for example - not all RF components has such functionality so please clarify more on the case and describe points which you can't achieve.

          • 2. Re: disable all jsf and richfaces elements within a panel
            bb bb Master

            So my scenario:

            If I click a button, I would like to disabled all elements within an another form on the page via javascript. not at the initial rendering.

            this form contains: a4j:commandlinks, inputs fields.

            • 3. Re: disable all jsf and richfaces elements within a panel
              Ilya Shaikovsky Master

              so you could define handler at button onclick and pass form element there. then in handler you could iterate all the child dom elements and disable buttons and inputs. Then if need to enable after responce - just call the same handler in oncomplete which will revert disable state back.

              • 4. Re: disable all jsf and richfaces elements within a panel
                Andreas Panagiotidis Novice

                Based on the Ilya's answer I give you an example.

                 

                In this one I disable all the components of a popup panel.

                Note that disabling a rich:inplaceInput (UIInplaceInput) doesn't have any effect.

                You may replace it with a h:outputText, or set its editEvent to 'none'. (default editEvent is 'click')

                 

                 

                 

                public void disablePopup(){
                    FacesContext ctx = FacesContext.getCurrentInstance();
                    UIPopupPanel panel = (UIPopupPanel) ctx.getViewRoot().findComponent("my-popup-panel");
                
                    disableAll(panel.getChildren());
                }
                
                public void disableAll(List<UIComponent> components) {
                
                    for (UIComponent component : components) {
                 
                        if (component instanceof UICommandButton && component.getClientId().contains("closePanelButton") ) {
                            continue;
                        }
                        if (component instanceof HtmlInputText) {
                            ((HtmlInputText) component).setDisabled(true);
                        }
                        if (component instanceof UIInplaceInput) {
                            ((UIInplaceInput) component).setEditEvent("none");
                        }
                        if (component instanceof UICommandButton) {
                            ((UICommandButton) component).setDisabled(true);
                        }
                        if (component instanceof UISelect) {
                            ((UISelect) component).setDisabled(true);
                        }
                
                        disableAll(component.getChildren());
                    }
                }