11 Replies Latest reply on Dec 23, 2009 10:19 AM by Nick Belaevski

    Assotiation of smart Queue and ajax Status with Ajax compone

    Ilya Shaikovsky Master

      Points that we need to achieve in the result:

      allow the user to define default statuses and queues for ajax components which covers most cases and not requires additional definitions on ajax components.

      Allow the user to split his ajax components into logical groups (validators, submits, etc..) and define different common statuses/queues for them.

      Move the options which actually belongs to queue/status into them and not to duplicate at ajax action components

      To unify the association ways as much as possible.

      Queue
      Current queue definition way seems good enough to continue with it in further versions:

      Common Queue defined for application globally.
      Common Queue defined for view
      Common Queue defined for form
      separate Queue defined at component level

      The main point of redesign there is to move the queue related options from ajax components attributes set.
      So the best way of moving the parameters out of the components is to define the queue/attributes for common queue for separate component not with an attributes but with child behavior tag:
      Declaration for placing the button request to common queue but redefining some parameters:

      <a4j:commandButton..>
       <a4j:attachQueue requestDelay="1000" ignoreDupResponses="true">
      <a4j:commandButton>
      

      Declaration for placing the button request to some named queue also with redefining some parameters:
      <a4j:commandButton..>
       <a4j:attachQueue requestDelay="1000" ignoreDupResponses="true" queueId="customQueue">
      <a4j:commandButton>
      


      Status
      With the status component we had some different situation:

      We have no attributes at Ajax components which related to status except the status to associate with.
      Definition separate statuses for some logical groups of the components placed at one form is more often use-case than for queue. So we have to simplify the redefinition of a status for a number of components as much as possible.

      Common statuses definition:
      1) Common for view.
      2) common for form
      Both should be defined without id/name the same as for queue.

      And for separate statuses definition we have next options:

      Option 1
      Taking into consideration the initial points - seems we have no need to define the status association with the behavior as we do it for queue. So leaving an attribute statusId at Ajax components should be enough and it will produce less page code for such redefinitions.
      <h:inputText>
       <a4j:ajaxValidator.. statusId="validationStatus"/>
      </h:inputText>
      <a4j:commandButton.. statusId="storingStatus"/>
      <a4j:commandButton.. statusId="revertStatus"/>
      


      Option 2
      To use the behavior as describe for queue association.
      <h:inputText>
       <a4j:ajaxValidator.. >
       <a4j:attachStatus statusId="foo"...>
       </a4j:ajaxValidator>
      </h:inputText>
      <a4j:commandButton..>
       <a4j:attachStatus statusId="foo">
      </a4j:commandButton>


      Differences between two options looks simple:
      In the second case all the code of association the status with a component moved to separate behavior but the end-developer code grows(to define only one property). But with the first approach which looks simpler for users our components still need to have mechanisms to register itself at the queue.

      I prefer the way with an attribute in order to make declaration simpler.