Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-672

Using a FieldLabel component after a checkbox modifies the checkbox's value

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Tapestry 4.0-beta-8, jdk 5.0

      Description

      I don't know if this is related to TAPESTRY-517, but here it goes.

      Having a FieldLabel after a checkbox in a form is causing two "setValue()" calls during form rewind.
      For example, I have the following property in a page:

      private boolean inspectorEnabled;

      public boolean isInspectorEnabled()

      { return this.inspectorEnabled; }

      public void setInspectorEnabled(boolean inspectorEnabled)

      { Thread.dumpStack(); this.inspectorEnabled = inspectorEnabled; }

      (added a dumpStack() for debugging).

      In the HTML, i put a checkbox, and after that, a FieldLabel:

      <input jwcid="inspectorEnabled@Checkbox" value="ognl:inspectorEnabled" />
       
      <label jwcid="@FieldLabel" field="component:inspectorEnabled"
      displayName="Enable Tapestry Inspector" />

      When i go to the page, check the box and submit my form, its value continues as false. After some debugging, I tried removing the FieldLabel from the HTML:

      <input jwcid="inspectorEnabled@Checkbox" value="ognl:inspectorEnabled" />
       
      <label>Enable Tapestry Inspector</label>

      Now, the checkbox works again.
      I tried printing some stack traces for each case. In the successful one, setInspectorEnabled() is called only once during form rewind, as it should:

      java.lang.Exception: Stack trace
      at java.lang.Thread.dumpStack(Thread.java:1158)
      at com.dtqsoftware.sigep.web.pages.sistema.Parametros.setInspectorEnabled(Parametros.java:72)
      at com.dtqsoftware.sigep.web.pages.sistema.Parametros.pageBeginRender(Parametros.java:107)
      at org.apache.tapestry.AbstractPage.firePageBeginRender(AbstractPage.java:478)
      at org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:268)
      at org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:368)
      at org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:71)
      at $ResponseRenderer_1069b6ddb8a.renderResponse($ResponseRenderer_1069b6ddb8a.java)
      at org.apache.tapestry.engine.PageService.service(PageService.java:69)
      at $IEngineService_1069b6ddbf5.service($IEngineService_1069b6ddbf5.java)
      at org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:65)
      at org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:248)
      at org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60)
      at $WebRequestServicer_1069b6ddbce.service($WebRequestServicer_1069b6ddbce.java)
      at org.apache.tapestry.services.impl.DisableCachingFilter.service(DisableCachingFilter.java:48)
      at $WebRequestServicerFilter_1069b6ddbd0.service($WebRequestServicerFilter_1069b6ddbd0.java)
      at $WebRequestServicer_1069b6ddbd2.service($WebRequestServicer_1069b6ddbd2.java)
      at $WebRequestServicer_1069b6ddbca.service($WebRequestServicer_1069b6ddbca.java)

      ....

      In the broken case, this setInspectorEnabled() method is called twice in form rewind. One for the checkbox, one for the fieldLabel:

      First, the checkbox calls setInspectorEnabled(true):

      Stack trace
      at java.lang.Thread.dumpStack(Thread.java:1158)
      at com.dtqsoftware.sigep.web.pages.sistema.Parametros.setInspectorEnabled(Parametros.java:72)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:491)
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:785)
      at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:937)
      at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:76)
      at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:132)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629)
      at ognl.ASTProperty.setValueBody(ASTProperty.java:105)
      at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
      at ognl.SimpleNode.setValue(SimpleNode.java:246)
      at ognl.Ognl.setValue(Ognl.java:476)
      at org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.writeCompiled(ExpressionEvaluatorImpl.java:121)
      at $ExpressionEvaluator_1069b6ddc7a.writeCompiled($ExpressionEvaluator_1069b6ddc7a.java)
      at org.apache.tapestry.binding.ExpressionBinding.setObject(ExpressionBinding.java:172)
      at $Checkbox_312.setValue($Checkbox_312.java)
      at org.apache.tapestry.form.Checkbox.rewindFormComponent(Checkbox.java:70)
      at org.apache.tapestry.form.AbstractFormComponent.renderComponent(AbstractFormComponent.java:115)
      at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
      at org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
      at org.apache.tapestry.form.FormSupportImpl.rewind(FormSupportImpl.java:542)
      at org.apache.tapestry.form.Form.renderComponent(Form.java:226)
      at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
      at org.apache.tapestry.form.Form.rewind(Form.java:327)
      at org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:441)
      at org.apache.tapestry.form.Form.trigger(Form.java:338)
      at org.apache.tapestry.engine.DirectService.triggerComponent(DirectService.java:144)
      at org.apache.tapestry.engine.DirectService.service(DirectService.java:130)
      at $IEngineService_1069b6ddbf3.service($IEngineService_1069b6ddbf3.java)

      Then, right after that, FieldLabel's preRenderField() call makes the checkbox call setInspectorEnabled(false) (marked with ****):

      Stack trace
      at java.lang.Thread.dumpStack(Thread.java:1158)
      at com.dtqsoftware.sigep.web.pages.sistema.Parametros.setInspectorEnabled(Parametros.java:72)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:491)
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:785)
      at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:937)
      at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:76)
      at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:132)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629)
      at ognl.ASTProperty.setValueBody(ASTProperty.java:105)
      at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
      at ognl.SimpleNode.setValue(SimpleNode.java:246)
      at ognl.Ognl.setValue(Ognl.java:476)
      at org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.writeCompiled(ExpressionEvaluatorImpl.java:121)
      at $ExpressionEvaluator_1069b6ddc7a.writeCompiled($ExpressionEvaluator_1069b6ddc7a.java)
      at org.apache.tapestry.binding.ExpressionBinding.setObject(ExpressionBinding.java:172)
      at $Checkbox_312.setValue($Checkbox_312.java)
      at org.apache.tapestry.form.Checkbox.rewindFormComponent(Checkbox.java:70)
      at org.apache.tapestry.form.AbstractFormComponent.renderComponent(AbstractFormComponent.java:115)
      at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
      at org.apache.tapestry.form.FormSupportImpl.prerenderField(FormSupportImpl.java:683)

            • at org.apache.tapestry.form.Form.prerenderField(Form.java:411)
            • at org.apache.tapestry.valid.FieldLabel.renderComponent(FieldLabel.java:49)
              at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
              at org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
              at org.apache.tapestry.form.FormSupportImpl.rewind(FormSupportImpl.java:542)
              at org.apache.tapestry.form.Form.renderComponent(Form.java:226)
              at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
              at org.apache.tapestry.form.Form.rewind(Form.java:327)
              at org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:441)
              at org.apache.tapestry.form.Form.trigger(Form.java:338)
              at org.apache.tapestry.engine.DirectService.triggerComponent(DirectService.java:144)
              at org.apache.tapestry.engine.DirectService.service(DirectService.java:130)

      I guess there's a problem with this pre-rendering, that causes the checkbox to be nullified when using an associated FieldLabel.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lquijano Leonardo Quijano Vincenzi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: