1 2 Previous Next 28 Replies Latest reply on Sep 7, 2007 8:19 AM by Vincent Latombe

    Problems using ajax validation in seam-gen

    Vincent Latombe Newbie

      Using Seam 2 BETA1,

      I'm facing an issue with the a:support tag in edit page of Seam-gen generated application. If I edit some required field, then hit the Save button directly, I get "The conversation ended, timed out or was processing another request" Faces message, and my changes are not committed.

      The issue comes from the fact that when I hit the Save button, the onblur event from a:support fires at the same time and it breaks the save process. If I click outside the edited field, and then click the save button it works.

      I don't really know whose fault is it (a4j or Seam) but anyway there is a problem and I have no clue how to solve it (except from removing this ajax validation)

        • 1. Re: Problems using ajax validation in seam-gen
          Damian Harvey Master

          The ajax4jsf forum http://www.jboss.com/index.html?module=bb&op=viewforum&f=259 is a better place for this but post your a:support tag so we can see the attributes that you are using. bypassUpdates="true" is probably a good candidate for you depending on what you are trying to do.

          Cheers,

          Damian

          • 2. Re: Problems using ajax validation in seam-gen
            Vincent Latombe Newbie

            my a:support looks like this
            <a:support event="onblur" bypassUpdates="true" reRender="nomDecoration"/>

            I get the problem on base Seam-gen application. Just edit some field and submit without any click outside of the field before. You should get the message.

            • 3. Re: Problems using ajax validation in seam-gen
              Damian Harvey Master

              I see what you mean. I get this as well and mine are set to event="onchange".

              • 4. Re: Problems using ajax validation in seam-gen
                Pete Muir Master

                Please file a JIRA issue for this.

                • 6. Re: Problems using ajax validation in seam-gen
                  Damian Harvey Master

                  As mentioned in the JIRA this is the code (added to any old page) that will cause ajax4jsf to reset the conversation resulting in a "The conversation ended, timed out or was processing another request" error.

                  I realise that this sort of problem is better suited to the ajax4jsf forum but wanted to keep continuity with JIRA.

                  Bean:

                  @Name("calcBean")
                  public class CalcBean {
                  
                   private Integer first = new Integer(0);
                   private Integer second = new Integer(0);
                   private Integer third = new Integer(0);
                  
                   public Integer getFirst() {
                   return first;
                   }
                   public void setFirst(Integer first) {
                   this.first = first;
                   }
                   public Integer getSecond() {
                   return second;
                   }
                   public void setSecond(Integer second) {
                   this.second = second;
                   }
                   public Integer getThird() {
                   return third;
                   }
                   public void setThird(Integer third) {
                   this.third = third;
                   }
                   public Integer getTotal() {
                   return this.first + this.second + this.third;
                   }
                  }
                  

                  Page (put these on any page):
                   <s:decorate id="firstDecoration" template="layout/edit.xhtml">
                   <ui:define name="label">First</ui:define>
                   <h:inputText id="first"
                   required="true"
                   value="#{personHome.first}">
                   <a:support event="onblur" reRender="firstDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="secondDecoration" template="layout/edit.xhtml">
                   <ui:define name="label">Second</ui:define>
                   <h:inputText id="second"
                   required="true"
                   value="#{personHome.second}">
                   <a:support event="onblur" reRender="secondDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="thirdDecoration" template="layout/edit.xhtml">
                   <ui:define name="label">Third</ui:define>
                   <h:inputText id="third"
                   required="true"
                   value="#{personHome.third}">
                   <a:support event="onblur" reRender="thirdDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                   </h:inputText>
                   </s:decorate>
                  
                   <s:div id="total">
                   Total: <h:outputText value="#{personHome.total}"/>
                   </s:div>
                  


                  Enter some values in the first, second and third and then tab over them and back again. Ajax4JSF will be overwhelmed and will kill the page (or at least generate the error mentioned above).

                  Regards,

                  Damian.



                  • 7. Re: Problems using ajax validation in seam-gen
                    Pete Muir Master

                    I still can't reproduce this.

                    I made the getTotal() method this:

                    public Integer getTotal() {
                     for (int i = 0; i < 100000000; i++)
                     {
                     int j = i / 10 + 10;
                     }
                     log.info("printing total");
                     return this.first + this.second + this.third;
                     }


                    to simulate very heavy load inside the getTotal method, entered some values and sat there with my finger on tab for a while. I get this printed out:

                    18:04:12,993 INFO [CalcBean] printing total
                    18:04:13,630 INFO [CalcBean] printing total
                    18:04:26,813 INFO [CalcBean] printing total
                    18:04:29,843 INFO [CalcBean] printing total
                    18:04:30,448 INFO [CalcBean] printing total
                    18:04:31,257 INFO [CalcBean] printing total
                    18:04:31,319 INFO [CalcBean] printing total
                    18:04:31,826 INFO [CalcBean] printing total
                    18:04:31,846 INFO [CalcBean] printing total
                    18:04:31,909 INFO [CalcBean] printing total
                    18:04:31,940 INFO [CalcBean] printing total
                    18:04:31,982 INFO [CalcBean] printing total
                    18:04:31,984 INFO [CalcBean] printing total
                    18:04:32,108 INFO [CalcBean] printing total
                    18:04:32,175 INFO [CalcBean] printing total
                    18:04:32,246 INFO [CalcBean] printing total
                    18:04:32,434 INFO [CalcBean] printing total
                    18:04:32,545 INFO [CalcBean] printing total
                    18:04:32,566 INFO [CalcBean] printing total
                    18:04:32,602 INFO [CalcBean] printing total
                    18:04:32,613 INFO [CalcBean] printing total
                    18:04:32,619 INFO [CalcBean] printing total
                    18:04:34,024 INFO [CalcBean] printing total
                    18:04:34,062 INFO [CalcBean] printing total


                    So, as you can see the function does take a non-trivial amount of time to process but a4j/seam does handle the load. What version of ajax4jsf? I'm using the one in Seam CVS (1.1.1)

                    • 8. Re: Problems using ajax validation in seam-gen
                      Tim Newbie

                      is there a <rich:panel> or any panel that these <a:support> are inside? It can make a difference as other post had mentioned.

                      • 9. Re: Problems using ajax validation in seam-gen
                        Damian Harvey Master

                        Pete,

                        Can you please post your XHTML?

                        I'm using a very recent Seam nightly build (jboss-seam-CVS.2007-08-30_14-35-23) which has ajax4jsf1.1.1

                        Cheers,

                        Damian.

                        • 10. Re: Problems using ajax validation in seam-gen
                          Pete Muir Master

                           

                          <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                           xmlns:s="http://jboss.com/products/seam/taglib"
                           xmlns:ui="http://java.sun.com/jsf/facelets"
                           xmlns:f="http://java.sun.com/jsf/core"
                           xmlns:h="http://java.sun.com/jsf/html"
                           xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                           xmlns:a="https://ajax4jsf.dev.java.net/ajax"
                           template="layout/template.xhtml">
                          
                          <ui:define name="body">
                          
                           <h:messages globalOnly="true" styleClass="message"/>
                          
                           <h:form>
                          
                           <s:decorate id="firstDecoration" template="layout/edit.xhtml">
                           <ui:define name="label">First</ui:define>
                           <h:inputText id="first"
                           required="true"
                           value="#{calcBean.first}">
                           <a:support event="onblur" reRender="firstDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                           </h:inputText>
                           </s:decorate>
                          
                           <s:decorate id="secondDecoration" template="layout/edit.xhtml">
                           <ui:define name="label">Second</ui:define>
                           <h:inputText id="second"
                           required="true"
                           value="#{calcBean.second}">
                           <a:support event="onblur" reRender="secondDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                           </h:inputText>
                           </s:decorate>
                          
                           <s:decorate id="thirdDecoration" template="layout/edit.xhtml">
                           <ui:define name="label">Third</ui:define>
                           <h:inputText id="third"
                           required="true"
                           value="#{calcBean.third}">
                           <a:support event="onblur" reRender="thirdDecoration, total" eventsQueue="calc" ignoreDupResponses="true"/>
                           </h:inputText>
                           </s:decorate>
                          
                           <s:div id="total">
                           Total: <h:outputText value="#{calcBean.total}"/>
                           </s:div>
                          
                          </h:form>
                          
                          </ui:define>
                          </ui:composition>


                          As index.xhtml in seam-gen project.

                          • 11. Re: Problems using ajax validation in seam-gen
                            Damian Harvey Master

                            Pete,

                            Add a page.xml with a <begin-conversation join="true"/>. 100% failure rate. Or at least it is for me.

                            I used your for loop and it doesn't even make it past 2 tab stops. If I take out the conversation it handles it fine.

                            Cheers,

                            Damian.

                            • 12. Re: Problems using ajax validation in seam-gen
                              Vincent Latombe Newbie

                              I get the same result as Damian. There must be something wrong inside the handling of conversation

                              • 13. Re: Problems using ajax validation in seam-gen
                                Vincent Latombe Newbie

                                The problem seems to lie in org.jboss.seam.core.Manager, method restoreAndLockConversation.
                                The first call locks the conversation, the next ones can't lock it and are redirected to an error. Conversation should allow concurrent access, or at least wait for unlock instead of going to error handling

                                • 14. Re: Problems using ajax validation in seam-gen
                                  Vincent Latombe Newbie

                                  In ConversationEntry :
                                  I tried to replace

                                  return lock.tryLock( Manager.instance().getConcurrentRequestTimeout(), TimeUnit.MILLISECONDS );

                                  with
                                  lock.lock();
                                  return true;
                                  


                                  Which replacing the failing lock with a waiting lock. With the example from above with the loop, the flooding seems to work also it makes the page a little dizzy (because all calls to getTotal get executed serially). But in normal operation it works perfectly.

                                  1 2 Previous Next