2 Replies Latest reply on Dec 27, 2007 6:25 AM by Orsier Adrien

    Page flow issues using jPDL

    Orsier Adrien Newbie

      Hi,


      We're currently trying to build a tool to translate the messages of our site.
      We basically want the translator just to see a simple panel showing him the message, its description and its different translations, with of course a possibility of changing them.
      So the translator see a message, translate it, and hit a 'next' button to continue his work. He can also go backward with a 'back' button.
      Our model is pretty simple, we have a Message entity with a @OneToMany link to an Expression entity, each of these Expression having a @OneToOne to a Language.
      We rely at the moment on a simple list of objects (the messages). We first try to work inside a simple long running conversation, but it was source of many possible error affecting our database, since if the user was hitting the browser's back button instead of our 'back' button, the expression he would then modify would be fetched for the previous message, the one he was on before he hit that browser's back button. So the application couldn't apparently know this button was pushed, and our database integrity was in potential danger.

      So we switch to a jPDL page flow. Everything is working better now, since if the user hits the browser's back button, he's sent outside the tool, so our data can't be affected. Though, if the user wants to get out of the tool by clicking on another links, he would get a 'navigation error' exception, since this case isn't known by my jPDL rules. So the tool isn't fully effective yet.

      We'd like to know first if there's a better way to do it, because we used the JPDL pageflow mainly to avoid the database integrity errors, not because we particularly wanted to.
      If jPDL was a good choice, then how to take into accoung the case of an user clicking on a link outside of the tool? Is there anyway to put a 'wild card' in the jPDL rules to tell it to 'end' the conversation?

      Although I'm not sure it's really necessary, here's my jsf page and my pageflow rules. As you'll see, everything is pretty simple:

       <h:form>
       <rich:panel>
       <f:facet name="header">#{item.name}, #{index+1}/#{totalItems}</f:facet>
       <h:outputText value="#{item.description}"/>
       <ui:repeat value="#{item.getExpressions()}" var="ex">
       <h:inputText value="#{ex.text}"/>
       </ui:repeat>
       <h:commandLink value="previous" action="previous" page-flow="auto-translate"/>
       <h:commandLink action="next" value="next" page-flow="auto-translate" />
       <h:commandLink action="end" value="end" page-flow="auto-translate" />
       </rich:panel>
       </h:form>
      


      <pageflow-definition name="auto-translate">
      
       <start-page name="TranslateItem" view-id="/admin/TranslateItem.xhtml">
       <redirect/>
       <transition name="next" to="TranslateItem">
       <action expression="#{autoTranslator.next()}" />
       </transition>
       <transition name="previous" to="TranslateItem">
       <action expression="#{autoTranslator.previous()}" />
       </transition>
       <transition name="*" to="Admin">
       <action expression="#{autoTranslator.end()}" />
       </transition>
       </start-page>
      
       <page name="Admin" view-id="/admin/admin.xhtml">
       <end-conversation/>
       </page>
      
      </pageflow-definition>
      


      The last transition, with the '*' put here as a wildcard, is there only to show you what we'd like to have.