Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 5.4
    • Component/s: tapestry-core
    • Labels:

      Description

      The Zone component's beginRender event handler method has 2 successive unnecessary boolean conditions:

          void beginRender(MarkupWriter writer)
          {
              clientId = resources.isBound("id") ? idParameter : javascriptSupport.allocateClientId(resources);
      
              Element e = writer.element(elementName,
                      "id", clientId,
                      "data-container-type", "zone");
      
              resources.renderInformalParameters(writer);
      
              insideForm = formSupport != null;
      
              if (insideForm) // <<<<<<<<<<<<<<<<<<<<
              {
                  JSONObject parameters = new JSONObject(RequestConstants.FORM_CLIENTID_PARAMETER, formSupport.getClientId(),
                          RequestConstants.FORM_COMPONENTID_PARAMETER, formSupport.getFormComponentId());
      
                  e.attribute("data-zone-parameters",
                          parameters.toString(compactJSON));
              }
      
              if (insideForm) // <<<<<<<<<<<<<<<<<<<<
              {
                  hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules);
      
                  actionSink = new ComponentActionSink(logger, clientDataEncoder);
      
                  environment.push(FormSupport.class, new FormSupportAdapter(formSupport)
                  {
                      @Override
                      public <T> void store(T component, ComponentAction<T> action)
                      {
                          actionSink.store(component, action);
                      }
      
                      @Override
                      public <T> void storeCancel(T component, ComponentAction<T> action)
                      {
                          actionSink.storeCancel(component, action);
                      }
      
                      @Override
                      public <T> void storeAndExecute(T component, ComponentAction<T> action)
                      {
                          store(component, action);
      
                          action.execute(component);
                      }
      
                  });
              }
      
              heartbeat.begin();
          }
      

      These 2 blocks could have been merged instead of having to check the boolean value twice

        Attachments

          Activity

            People

            • Assignee:
              jkemnade Jochen Kemnade
              Reporter:
              mgelbana Muhammad Gelbana
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: