Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-14018

Move ClientValidationUtils processAndApplyContraints processing of client side constraints (when the data is part of a JSON object) to KRAD's JsonStringEscapeDirective for Freemarker

    Details

    • Type: Task Task
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.1
    • Fix Version/s: None
    • Component/s: Development
    • Security Level: Public (Public: Anyone can view)
    • Labels:
    • Similar issues:
      KULRICE-9694Implement both local and ajax requested Json data generation for datatables (RichTable)
      KULRICE-12622KRAD Demo: Client side validation for search criteria
      KULRICE-4708Support for client side field validation
      KULRICE-7339Adhoc routing for completion - client side validation
      KULRICE-12235KRAD - Client side validations do not work within a dialog
      KULRICE-11729Selectively disable client side validation on KRAD collections
      KULRICE-9108Implement support for loading of both OJB and JPA versions of KRAD client-side mappings
      KULRICE-10353Inline processing of FreeMarker templates
      KULRICE-4724Client side table sorting, paging
      KULRICE-11734Remove newlines and return characters from render output for json paging
    • Rice Team:
      Framework
    • Rice Module:
      KRAD
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Code Review Status:
      Not Required
    • Include in Release Notes?:
      Yes
    • Story Points:
      1

      Description

      In order to fix issue https://jira.kuali.org/browse/KULRICE-13988 that causes a JSON data browser error, I added code to escape a period since it is illegal to use in JSON (it turned out not to be the single quotes). This piece of code is implemented in the ClientValidationUtils's processAndAppplyConstraints (called in InputFieldBase's finalize) when there are valid client-side constraints to apply to the field, and there is a JSON template set on the form (template to use when returning the createDataTables request's response as JSON). This escaping of the period needs to move (that means the work done part of issue https://jira.kuali.org/browse/KULRICE-13988 undone) to KRAD's JsonStringEscapeDirective's inner class JsonEscapingFilterWriter's write method. As a first shot I tried the following lines to the very beginning of the write method but got a console error which needs investigated further and is also where I left off:

      public void write(char[] cbuf, int off, int len) throws IOException

      { String bufStr = new String(cbuf).replaceAll("\\.", "\\\\u002e"); cbuf = bufStr.toCharArray(); // We need to allocate a buffer big enough to hold the escapes too, which take up extra chars int needsEscapingCount = 0; // count up how many chars needing escapes are in the buffer // ... rest of the code is the same }

        Activity

        Hide
        Claus Niesen added a comment -

        From Nisha:
        I am attaching the patch file for JIRA 14018, but it is not a complete working copy (I get a JS console error which needs investigating). However, with that being said I think that JSON specific escapes should be done here given the FreeMarker template directive is the recommended approach. Also, my temporary fix also was to replace all “.” With “\u0027” (of course properly escaped in JAVA), which is what should occur since the dot is not an allowed in JSON. Note, Kristina’s recommended fix about the single quotes turned out not to be the problem (this is cause while the single quote is not valid in JSON, the JAVA Jackson Library allows it and therefore leaves it up to the browser to complain if at all, which Chrome accepts it just fine; however, this is not true of the dot notation – the browser does complain and therefore the JS error).

        Show
        Claus Niesen added a comment - From Nisha: I am attaching the patch file for JIRA 14018, but it is not a complete working copy (I get a JS console error which needs investigating). However, with that being said I think that JSON specific escapes should be done here given the FreeMarker template directive is the recommended approach. Also, my temporary fix also was to replace all “.” With “\u0027” (of course properly escaped in JAVA), which is what should occur since the dot is not an allowed in JSON. Note, Kristina’s recommended fix about the single quotes turned out not to be the problem (this is cause while the single quote is not valid in JSON, the JAVA Jackson Library allows it and therefore leaves it up to the browser to complain if at all, which Chrome accepts it just fine; however, this is not true of the dot notation – the browser does complain and therefore the JS error).

          People

          • Assignee:
            Unassigned
            Reporter:
            Nisha Gupta (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Structure Helper Panel