Tapestry
  1. Tapestry
  2. TAPESTRY-2504

Unspecified ajax stream response encoding

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.13
    • Fix Version/s: 5.0.14
    • Component/s: Core Components
    • Labels:
      None
    • Environment:
      windows, java 1.5

      Description

      Automcomplete response does not properly create data stream

      Class org.apache.tapestry5.util.TextStreamResponse:
      public InputStream getStream() throws IOException

      { return new ByteArrayInputStream(text.getBytes()); }

      should be:

      public InputStream getStream() throws IOException

      { byte[] bytes = text.getBytes(charset); return new ByteArrayInputStream(bytes); }

      charset : class field which holds valid charset:

      1. MissingCharsetPatch.patch
        3 kB
        Krzysztof Krzeminski
      2. MissingCharsetBetter.patch
        5 kB
        Krzysztof Krzeminski

        Issue Links

          Activity

          Hide
          Howard M. Lewis Ship added a comment -

          TAPESTRY-2543 is now more explicit that the application-wide charset is used for all JSON and markup output.

          Show
          Howard M. Lewis Ship added a comment - TAPESTRY-2543 is now more explicit that the application-wide charset is used for all JSON and markup output.
          Hide
          Krzysztof Krzeminski added a comment -

          This way seems to complex for tapestry framework users.

          I suggest to provide 3 constructors:

          TextStreamResponse(String contentType, String text) - compatibility with existing clients
          TextStreamResponse(String contentType, String charset, String text) - gives way to specify response encoding
          TextStreamResponse(MetaDataLocator locator, ComponentResources resources, String text) - for mixin and component developers

          See attachent: MissingCharsetBetter.patch contains solution

          Show
          Krzysztof Krzeminski added a comment - This way seems to complex for tapestry framework users. I suggest to provide 3 constructors: TextStreamResponse(String contentType, String text) - compatibility with existing clients TextStreamResponse(String contentType, String charset, String text) - gives way to specify response encoding TextStreamResponse(MetaDataLocator locator, ComponentResources resources, String text) - for mixin and component developers See attachent: MissingCharsetBetter.patch contains solution
          Hide
          Igor Drobiazko added a comment -

          Thanks for the patch. I was also thinking about to use the MetaDataLocator service inside TextStreamResponse.

          public TextStreamResponse(MetaDataLocator locator, ComponentResources resources, String text)

          { this.contentType = locator.findMeta(MetaDataConstants.RESPONSE_CONTENT_TYPE, resources, String.class); this.encoding = locator.findMeta(MetaDataConstants.RESPONSE_ENCODING, resources, String.class); this.text = text; }

          This way we can reuse the metadata provided by a component in the containment hierarchy.

          Comments are welcome, please.

          Show
          Igor Drobiazko added a comment - Thanks for the patch. I was also thinking about to use the MetaDataLocator service inside TextStreamResponse. public TextStreamResponse(MetaDataLocator locator, ComponentResources resources, String text) { this.contentType = locator.findMeta(MetaDataConstants.RESPONSE_CONTENT_TYPE, resources, String.class); this.encoding = locator.findMeta(MetaDataConstants.RESPONSE_ENCODING, resources, String.class); this.text = text; } This way we can reuse the metadata provided by a component in the containment hierarchy. Comments are welcome, please.
          Hide
          Krzysztof Krzeminski added a comment -

          problem solution

          Show
          Krzysztof Krzeminski added a comment - problem solution

            People

            • Assignee:
              Howard M. Lewis Ship
              Reporter:
              Krzysztof Krzeminski
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development