3 Replies Latest reply on Oct 27, 2008 5:13 AM by ilya_shaikovsky

    How to enable form field on click using ajax4jsf or rich fac

    valatharv

      Hi,

      I have form field (h:inputText) which is disabled when the page loads.

      Is there nice way just to enable h:inputText when user clicks "Edit This" link(it can be button also).

      I don't want to use Javascript.........

      <s:link value="Edit This" id="edit">

      <s:decorate template="layout/edit.xhtml">
      <h:inputText id="name" required="true" value="Test enable" disabled="true"/>
      </s:decorate>

        • 1. Re: How to enable form field on click using ajax4jsf or rich
          nbelaevski

          Sure. Bind "disabled" attribute to model and re-render h:inputText using a4j:commandLink

          • 2. Re: How to enable form field on click using ajax4jsf or rich
            valatharv

            Thanks for replying....

            "Sure. Bind "disabled" attribute to model and re-render h:inputText using a4j:commandLink"

            I am new to this, please suggest for "Bind "disabled" attribute to model " any sample....

            • 3. Re: How to enable form field on click using ajax4jsf or rich
              ilya_shaikovsky

              this sample I've just written for another topic with toogle state changes. It should be also usefull for you.


              page

               <h:form>
               <h:panelGrid columns="3" width="100%" columnClasses="tpanels,tpanels,tpanels">
               <rich:simpleTogglePanel switchType="ajax" label="Ajax Switch Type" height="90px" opened="#{userBean.opened}" id="ajax">
               This type allows to perform the partial view update instead of the
               whole page reloading. You also can reRender other components
               while the panel content is toggled.
               </rich:simpleTogglePanel>
               </h:panelGrid>
               <a4j:commandButton reRender="ajax" action="#{userBean.switchPanel}"></a4j:commandButton>
               </h:form>
              


              java
               public boolean isOpened() {
               return opened;
               }
              
               public void setOpened(boolean opened) {
               this.opened = opened;
               }
              
               public void switchPanel() {
               setOpened(!isOpened());
               }