Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6711

Contradictory generating behavior id in AbstractDefaultAjaxBehavior#onBind for stateless behaviors

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 8.6.1
    • Fix Version/s: None
    • Component/s: wicket-core
    • Labels:

      Description

      Behavior class says that behavior is not stateless if it is a request listener:

      public boolean getStatelessHint(Component component) {
         if (this instanceof IRequestListener) {
            // this behavior implements a callback interface, so it cannot be stateless
            return false;
         }
         return true;
      }
      

      In Behaviors "util" class the stable ID is generated for NOT stateless (i.e. stateful) behaviors:

      private void internalAdd(final Behavior behavior) {
          component.data_add(behavior);
          if (behavior.getStatelessHint(component) == false) {
                  getBehaviorId(behavior);
          }
      }
      

      BUT in AbstractDefaultAjaxBehavior#onBind there is a contradictory piece of code, that generates ID for stateless behaviors:

      protected void onBind() {
          final Component component = getComponent();
          
          component.setOutputMarkupId(true);
          
          if (getStatelessHint(component)) {
                  //generate behavior id
                  component.getBehaviorId(this);
          }
      }
      

      The AJAX behaviors are always IRequestListener so they are stateful by default (unless the getStatelessHint is overridden).

      It does not make sense to me... generate ID for stateful behaviors on the one hand in Behaviors and on the other hand for stateless in AbstractDefaultAjaxBehavior.

      I suspect that this could be bug.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              davesman David Rain
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: