4 Replies Latest reply on Dec 11, 2008 4:47 PM by deanhiller2000

    table DataModel, inputText, and AJAX examples?

    deanhiller2000

      Does anyone have an example with a dataTable that has inputText fields that need to be filled in where you can add rows with an add button and delete with a remove button all done in ajax.


      We have been trying to get this to work for two days now and if my remove button has ajaxSingle=false, it works great except that validation fails on not filled in rows and so click remove does not work until I fill in all the fields(even when trying to remove an empty field..you have to fill it in before you can click remove).


      Then if I use ajaxSingle=true, I can remove any row, but it does not read back from the dataModel properly.  If I have row a, b, c, d, and I click remove b, it changes to a, b, d.  then if I click refresh, it display a, c, d and shows that b was correctly deleted but the framework did not read properly from the model for some reason. 


      It has something to do with the html we suspect but can't figure it out......(is there any way to have ajaxSingle=false but skip validations on a submit?)....



      <s:div id="variables">
      
           <s:div rendered="#{variables.size==0}">
                Currently, this question has no input fields.<br/>
                Please click Add an Input Field to add one.
           </s:div>
           <h:dataTable id="variablesTable" border="1" value="#{variables}"
                     var="field" rendered="#{variables.size>0}">                                        
                <h:column>
                     <f:facet name="header">Label</f:facet>
                     <s:decorate id="labelDecorate" template="fieldTemplate.xhtml">
                          <h:inputText id="label" value="#{field.label}" required="true">
                      </h:inputText>                                             
                  </s:decorate>
                </h:column>
                <h:column>
                     <f:facet name="header">Stored as</f:facet>
                     <s:decorate id="nameDecorate" template="fieldTemplate.xhtml">
                          <h:inputText id="name" value="#{field.name}" required="true">
                          </h:inputText>                                   
                     </s:decorate>
                </h:column>
                <h:column>
                     <f:facet name="header">Actions</f:facet>
                     <a:commandLink id="removeField" value="Remove"
                     action="#{editScript.removeVariable(field)}" reRender="variables" 
                     
                      />
                </h:column>
           </h:dataTable>     
      </s:div>
      
      
      <a:commandButton id="addField" value="Add an Input Field"
           action="#{editScript.addVariable()}" reRender="variables" 
           ajaxSingle="true" bypassUpdates="false" />
      
      </a:region>
      






        • 1. Re: table DataModel, inputText, and AJAX examples?
          gbilodeau

          Have you had any success in achieving this?  We're facing a similar issue.  For the moment, we have resorted to creating a view bean that duplicates the edited object and its list of dependent objects.  The add and remove buttons update the view bean list.  It all works fine, but the domain object attributes and their validation annotations are duplicated, plus the view and domain object need to be synchronized manually.


          Thanks,
          GB


          • 2. Re: table DataModel, inputText, and AJAX examples?
            deanhiller2000

            We resorted to no ajax to make the problem simpler so we never solved this.....sorry.


            some days I miss GWT and other I love seam.....they both seem to have their strengths and weaknesses and here GWT shines with no problems at all where other places seam shines.

            • 3. Re: table DataModel, inputText, and AJAX examples?
              luke.poldo.mailinator.com

              We resorted to no ajax to make the problem simpler so we never solved this.....sorry.

              sorry dean, but I can't see anything shines in a WEB framework that don't let you do ajax...

              • 4. Re: table DataModel, inputText, and AJAX examples?
                deanhiller2000

                I disagree there, even though GWT is all AJAX, Seam has
                the advantage of extremely clear separation of presentation
                and business logic(ie. css is the styling) where in GWT,
                it is more like a swing application.  Here Seam
                shines.  GWT shines in making ajax cake compared with seam.


                Each has their own strengths in weaknesses. I have this love/hate
                relationship with both frameworks.


                If you want something that looks and feels like a desktop
                applicatoin in a borwser, USE GWT.  If you want separation
                of presentation and logic, USE SEAM.