2 Replies Latest reply on Jul 31, 2008 10:15 AM by rwijeyra

    Dynamic Form combined with Ajax

    rwijeyra

      Hi everybody

      I'm having a problem with my view. I'm implementing a wizard in a modalpanel.

      That wizard displays a form with several different input fields (mostly textboxes, selectboxes) the form fields are generated based on a structure as follows

      A List of Codes, a Code has a List of Parameters and can contain Subcodes with Parameters (and so on)
      A Parameter is desribed by a pattern, based on that i display a selectbox, normal textbox or sometimes a textbox with a control button.

      <c:WS_Code>
       <c:Changeable>false</c:Changeable>
       <c:Description>...</c:Description>
       <c:Name>DES</c:Name>
       <c:Parameters xmlns:d=".....">
       <d:WS_Parameter>
       <d:Changeable>false</d:Changeable>
       <d:Name />
       <d:Pattern>REGEXP:.{0,6}</d:Pattern>
       <d:Value>M3905</d:Value>
       </d:WS_Parameter>
       </c:Parameters>
       <c:SubCodes />
      </c:WS_Code>
      <c:WS_Code>
       <c:Changeable>true</c:Changeable>
       <c:Description>...</c:Description>
       <c:Name>KEY ACD</c:Name>
       <c:Parameters xmlns:d=".....">
       <d:WS_Parameter>
       <d:Changeable>true</d:Changeable>
       <d:Name />
       <d:Pattern>LIST:0,5,7,8</d:Pattern>
       <d:Value>0</d:Value>
       </d:WS_Parameter>
       <d:WS_Parameter>
       <d:Changeable>true</d:Changeable>
       <d:Name />
       <d:Pattern>REGEXP:[0-9]+</d:Pattern>
       <d:Value />
       </d:WS_Parameter>
       <d:WS_Parameter>
       <d:Changeable>true</d:Changeable>
       <d:Name />
       <d:Pattern>REGEXP:[-]?[0-9]*</d:Pattern>
       <d:Value>0</d:Value>
       </d:WS_Parameter>
       <d:WS_Parameter>
       <d:Changeable>true</d:Changeable>
       <d:Name />
       <d:Pattern>FREEDN</d:Pattern>
       <d:Value />
       </d:WS_Parameter>
       </c:Parameters>
       <c:SubCodes />
      </c:WS_Code>


      in the view i can access the list of codes, i get from an session bean (i'm using jboss seam). i have two <ui:repeat> blocks to get to the parameters. and since i was not able to have something recursive in the view, i'm presenting the hierarchical structure as a flat list of codes.

      <ui:repeat value="#{configPattern.codesNonHierarchical}" var="code">
      <h:outputText value="#{code.description}" />
       <s:validateAll>
       <ui:repeat value="#{code.parameters}" var="parameter">
       <h:panelGroup rendered="#{parameter.changeable}">
      
       <!-- used if parameter is a dn -->
       <h:panelGroup rendered="#{parameter.isParameterDN()}">
       <h:inputText id="phone_phoneNumber" value="#{parameter.value}" />
       <a4j:commandButton value="get free dn"
       action="#{dnTnHandler.getFreeDn(parameter)}" immediate="true"
       limitToList="true" reRender="#{dialogHtmlId}" />
       </h:panelGroup>
       </h:panelGroup>
       </ui:repeat>
       </s:validateAll>
      </ui:repeat>
      


      so now comes the question. i simply want, that when i click on the button a method of a sessionbean is called. in that method i need to access the current value of the textfield next to it ( #{parameter.value} ) ... and according to that input i want to set a different context in the textfield.

      example. in the textfield somebody types 5000, when i click on the button the method of the sessionbean will get the next available number (could be 5005) and that number should be put in the textbox.

      the model update can happen later, when i click on the "next" button of the wizard, so i set the immediate param of the button to true.

      i think i'm trying to do this way too complicated at the moment. and besides that it doesn't work ;) i just can't see an easy way to access the value property of the textbox from the session bean, so that the textbox will reload it

      would be glad for some help

      thx
      ranil

        • 1. Re: Dynamic Form combined with Ajax
          rwijeyra

          hmmm, i just had the idea of using a suggestion box instead of the button (would still prefer the button solution though)

          with the suggestionbox i have the problem, that it seems the suggestionAction method is never called. no matter what i type in the textfield

          <h:inputText value="#{parameter.value}" id="getNextDNFieldId" />
          <rich:suggestionbox for="getNextDNFieldId" suggestionAction="#{dnTnHandler.nextFreeDn}" var="object">
           <h:column>
           <h:outputText value="#{messages.next_free_dn}" />
           </h:column>
           <h:column>
           <h:outputText value="#{object}" />
           </h:column>
          </rich:suggestionbox>


          • 2. Re: Dynamic Form combined with Ajax
            rwijeyra

            nobody got a clue? or is my question unclear?