Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3034 Refactor CustomDatatype and CustomDatatypeHandler to make the interface simpler
  3. TRUNK-3038

FieldGenDatatypeHandler and WebDatatypeHandler should both extend a new interface

    XMLWordPrintable

    Details

    • Complexity:
      High

      Description

      We're removing the render method from CustomDatatypeHandler, because it doesn't belong on that interface. But the idea is important.

      We should introduce a new interface in the web layer that (maybe) extends CustomDatatypeHandler, and (definitely) is extended by both FieldGenDatatypeHandler and WebDatatypeHandler. My initial proposal is something like this:

      interface HtmlDisplayableDatatypeHandler extends CustomDatatypeHandler {
      
          /**
           * Renders an HTML-formatted summary view of the custom value.
           * This method should return quickly, e.g. in case we're rendering thousands of custom values in a table.
           */
          Summary toHtmlSummary(CustomDatatype dt, String valueReference, int suggestedMaxSize);
      
          /**
           * Renders the full view of a custom value, as HTML.
           */
          String toHtml(CustomDatatype dt, String valueReference);
      }
      
      // class Summary is defined in TRUNK-3035
      

      I'm thinking that code which displays these custom values in summary pages would call the toHtmlSummary method, and if the returned summary is not complete, it can display a link to the full view of this value. But the handler implementation doesn't need to worry about including the link in this common case.

        Attachments

          Activity

            People

            Assignee:
            darius Darius Jazayeri [X] (Inactive)
            Reporter:
            darius Darius Jazayeri [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: