2 Replies Latest reply on Jul 1, 2010 11:12 PM by Harsh Jain

    Problem in AJAX

    Harsh Jain Newbie

      I want to make a registraiton form for which there is a branch and a section field

      I want to make a form such that if I select a branch that the corresponding section of that branch should be displayed but not all the sections .

      I want to write ajax code for that
      But dont know how to use ajax

      Please guide me for the same

      Or provide me with code

      Thank you

        • 1. Re: Problem in AJAX
          Sean Tozer Newbie

          The RichFaces library, included in Seam, handles a lot of AJAX-y functionality for you.

          To make a form like what you're talking about, it's really very simple. Make a checkbox that's bound to a backing beam value, and have that box update the relevant output section.

          <h:selectBooleanCheckbox value="#{backingBean.checked}" >
              <a4j:support event="onchange" reRender="otherPanel" />

          And then have some other panel that contains the corresponding section:

          <a4j:outputPanel id="otherPanel" rendered="#{backingBean.checked}">

          Now the other panel will be built only when the checkbox is checked. No problem.

          • 2. Re: Problem in AJAX
            Harsh Jain Newbie

            Here is my code snippet.. But its not working properly.

            I have used two drop down menus

            <h:outputLabel for="branch">Branch </h:outputLabel>   
            <h:selectOneMenu id="branch" value="#{stud.masterBranch}" >
            <s:selectItems var="branches" value="#{branchList}" noSelectionLabel="[Please Select]" label="#{branches.name}"/>
            <s:convertEntity />
            <a4j:support event="onchange" reRender="section" />
            <a4j:outputPanel id="section" rendered="#{stud.masterBranch}" >
            <h:outputLabel for="section">Section</h:outputLabel>
            <h:selectOneMenu  value="#{stud.masterSection}" >
            <s:selectItems var="sections" value="#{sectionList}" noSelectionLabel="[Please Select]" label="#{sections.section}"/>
            <s:convertEntity />

            Is there any problem tn this code?
            I know there must be mistakes in it Please suggest the correct code

            Thanks .

            From where should I start reading ajax?