[Yanel-dev] Introducing a WebViewable interface

Josias Thöny josias.thoeny at wyona.com
Fri Feb 16 23:59:32 CET 2007


Michael Wechner wrote:
> Josias Thöny wrote:
> 
>> Michael Wechner wrote:
>>
>>> Hi
>>>
>>> I am currently working on the integration of a toolbar. One condition 
>>> is that one knows the mime-type of a response, because
>>> the toolbar only makes sense for requesst which have (x)html as a 
>>> response. Hence it's important to ask a resource for the mime-type
>>> before the actual response is actually being generated.
>>>
>>> In other situations this should also be the case for other HTTP 
>>> header fields, e.g. size, because the header should be set before the 
>>> response body is being streamed.
>>>
>>> With the current Viewable interfaces and the View class, this is not 
>>> really being forced and I think it's design mistake which I caused ;-)
>>
>>
>> How would you enforce that?
>> IIUC you are talking about a getMimeType() method. This method could 
>> either be in the View interface (as it is now), or in the Viewable 
>> interface. In either case the only way I see to force the resource to 
>> actually set the mime-type is by adding a contract in javadoc, like 
>> e.g. "The resource MUST always set a valid mime-type". Then the 
>> servlet could throw an exception if a resource doesn't set a mime-type.
> 
> 
> exactly
> 
>> I guess we could add such a contract to the the getMimeType() method 
>> in the View interface.
>> BTW, would it make sense to move the getSize() method from the 
>> ViewableV2 interface to the View interface?
> 
> 
> Well, I think we should deprecate the View class and move the 
> getMimeType into the Viewable interface.
> 
> The reason for this is to allow "streaming", i.e. the resource can 
> directly write into the response instead of creating an object like 
> "View" first with a buffered InputStream

If the resource is writing directly into the response, it will be 
difficult for the servlet to manipulate the response.
IIUC your idea was that the servlet adds the toolbar by inserting some 
code into the response. I don't quite see how those two things would fit 
together.

About the toolbar, it might be a good idea to discuss the different 
options (embed into html vs. frame) first because it's something that 
won't be easy to change later on.

have a nice weekend,
josias

> 
>>
>>>
>>> So I think we should either change the ViewableV2 interface (which 
>>> hasn't be released yet) or introduce a new interface which takes care 
>>> of the issues described above.
>>
>>
>> How would the changed interface (or a new interface) look like?
> 
> 
> the changed interface would contain "getMimeType()", whereas I haven't 
> though concretely about the WebViewable interface.
> 
> Cheers
> 
> Michi
> 
>>
>> Josias
>>
>>>
>>> Another distinction we might want to make is between "web-viewable" 
>>> and "viewable" in a more general sense.
>>>
>>> Hence I think it would make sense to introduce a WebViewable interface.
>>>
>>> WDYT?
>>>
>>> Cheers
>>>
>>> Michael
>>>
>>
>>
>> _______________________________________________
>> Yanel-development mailing list
>> Yanel-development at wyona.com
>> http://wyona.com/cgi-bin/mailman/listinfo/yanel-development
>>
> 
> 




More information about the Yanel-development mailing list