Uploaded image for project: 'Kuali Rice Development'
  1. Kuali Rice Development
  2. KULRICE-9883

Boolean property value is evaluated as string instead of a boolean

    Details

    • Type: Bug Fix
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.3.0-rc1, 2.3
    • Component/s: Development
    • Security Level: Public (Public: Anyone can view)
    • Labels:
      None
    • Rice Module:
      KRAD
    • KRAD Feature Area:
      UIF Script
    • Application Requirement:
      KS My Plan
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Code Review Status:
      Not Required
    • Include in Release Notes?:
      Yes

      Description

      A property which is a boolean has a value that becomes a string within javascript.

      Example:

      A button with a disabled spring expression evaluates properly on load, planExists is false so @

      {#form.planExists EQ false} returns true and the button is disabled. But in the script that sets up the disabled check, the function coerceValue("planExists") returns false as a string so the condition function created will return false since the string "false" does not equal boolean false.

      Tried changing the spring expression to @{#form.planExists EQ 'false'} so that the javascript would be matching strings, but the expression fails for the initial value.

      See XML and generated script below:

      XML:

      <bean id="plan_audit_validate" parent="Uif-PrimaryActionButton" p:actionLabel="Audit Your Plan"
      p:title="Audit Your Plan">
      <property name="disabled" value="@{#form.planExists EQ false}

      "/>
      <property name="actionScript" value="
      validatePlanAudit('plan_hand_off_container','plan_audit_hand_off','reviewPlanAudit','audit',

      {viewId:'PlanAuditHandOff-FormView',pageId:'plan_audit_hand_off'}

      );
      "/>
      </bean>

      Generated Javascript:

      var condition = function()

      {return (coerceValue("planExists") == false);}

      ;
      setupDisabledCheck('planExists', 'plan_audit_validate', 'action', condition, false);

      Possible fix:

      I created a workaround by redefined the coerceValue function and added the following before the return to convert true and false strings to booleans:

      if (value == "true")

      { value = true }

      if (value == "false")

      { value = false }

        Attachments

          Activity

          Hide
          jkneal Jerry Neal (Inactive) added a comment -

          Jessica,

          Since Garett has a fix here this would be very quick to put in for RC1.

          Jerry

          Show
          jkneal Jerry Neal (Inactive) added a comment - Jessica, Since Garett has a fix here this would be very quick to put in for RC1. Jerry
          Hide
          bsmith Brian Smith (Inactive) added a comment - - edited

          coerceValue will now match the strings true or false and return boolean values instead of string values, case-insensitive

          Show
          bsmith Brian Smith (Inactive) added a comment - - edited coerceValue will now match the strings true or false and return boolean values instead of string values, case-insensitive

            People

            • Assignee:
              bsmith Brian Smith (Inactive)
              Reporter:
              garettg Garett Gowens
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: