Hi guys. I have a question about ResponseWriter. Where are the methods that perform the actual work located? I'm wanting to thoroughly understand how it works, and I see examples all the time of folks using ResponseWriter and using it's methods and what not, but it is an abstract class and all of the most useful methods are declared abstract as well. So where is the implementation and how are all these folks using it in their components when the methods are just empty abstract method declarations with no implementation?
I know that there must be some sort of implementation somewhere for stuff like: abstract void startElement ( ) and abstract void writeAttribute ( ). These methods do more than just transmit characters verbatum like the write method in the Writer class that it extends, but I find no implementation for them nor do I find anything in the using statements that would provide the implementation.
So please, can someone tell me where the code is that does the heavy lifting and how it comes about being called when someone uses javax.faces.context.ResponseWriter...otherwise I have to assume that it's all bogus and happens by "magic".
BTW...This is a real question, not an April Fools joke. Really, where is the class that implements the abstract methods in ResponseWriter?
ResponseWriter is one of the core components of the JSF HTML renderer, and it provides services that permit JSF HTML renderers to generate output for eventual routing to the outputwriter that's located in the HTTPServletResponse object.
Bear in mind that JSF is designed to be able to render to more than just HTML. Using a suitable set of renderers, JSF can also emit WAP, PDF's and more esoteric types of output as well. In order to make these renderers function as "plug-in" components, they use abstract interfaces so that the specific implementations can be swapped in and out at need.
The actual source code for all of the core JSF classes is browseable online, so I recommend you google for it. You'll get the best results if you search on the fully-qualified classname, including the ".java" extension. You should also be able to find JavaDocs as well.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Mar 09, 2009
Thank you Tim. I guess my problem is as much a 'java' question as it is a 'faces' question. I'm familiar with using interfaces to type a variable or object to enable injecting a subclass into that variable or object. I've just been having a hard time figuring out how the implementation of the abstract ResponseWriter makes it's way into the custom component code that I see other folks writing.
I actually have downloaded the whole Mojarra source package and have been pulling through it. I did find the implementation of the abstract methods in "com\sun\faces\renderkit\html_basic" as HtmlResponseWriter. I've also been pulling through the PrimeFaces component library looking at how it was put together. I've been trying to get an indepth understanding of JavaServer Faces component libraries and I picked PrimeFaces as an object of study since it was lightest weight, least confusing looking library that I could find.... judging by just a short going over of different library's code bases.
He breaks all of his components down into 3 classes: 'Component' , 'ComponentRenderer, 'ComponentTag'. I see in all the 'ComponentRenderer' classes the import statement for ResponseWriter but I have been having trouble finding the direct connect between the abstract declaration and the actual implimentation of the methods belonging to ResponseWriter.
My best guess is that when extending UIComponent as an ancestor through UIPanel or UIOutput you are getting the implementation via the inherited RendererType since HTML_BASIC is it's default renderkit. All of his component classes simply decorate the default renderkit...which is what makes PrimeFaces light weight and less confusing.
I'm just rambling here, but if anything I've said is misguided please point it out to me.