[Yanel-dev] Introducing a WebViewable interface

Josias Thöny josias.thoeny at wyona.com
Thu Feb 15 15:44:16 CET 2007


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.
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?

> 
> 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?

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
> 




More information about the Yanel-development mailing list