I was actually thinking that I would just use the JSP to code the page
and then use jspc to compile it to a java source, and then use it just
like a regular renderer.

That is, put my encode and decode methods inside scriptlet
declarations.  Lately, my custom components have lots of HTML, but not
much decoding.  So, maintanence gets very difficult since its harder
to read responsewriter code than it is to read JSP code.


On Mon, 17 Jan 2005 08:59:05 -0800, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> Creating a single JSF component that uses RequestDispatcher.include()
> inside would make it easy to use a JSP page as a "renderer" --
> probably 50 lines of code to do this.  But you are going to run into a
> couple of challenges:
> 
> * Real renderers tend to have lots of conditional logic
>  in them.  For example, even something as simple as
>  <h:outputText> has conditional logic to render each of
>  the pass-through attributes (onfocus, onblur, ...).  Such
>  logic is pretty concise in Java, but very verbose in
>  JSP (you'd need tons of <c:if> statements, or a bunch
>  of custom tags.
> 
> * Using the rendering APIs (ResponseWriter) makes it
>  easy to create well formed XHTML output, with proper
>  quoting and escaping on attribute values.  Using JSP
>  directly means you have to deal with this all yourself.
> 
> * Using a JSP takes care of the *encoding* half of what
>  renderers do, but not the *decoding* half.  For input
>  components, you're still going to need a Java class
>  to deal with those things, and now you've got the logic
>  for a single renderer split into multiple source files,
>  instead of all in one place.
> 
> * Using the ResponseWriter APIs has an additional benefit
>  if you use components inside a JSF-aware GUI design tool --
>  the tool can take the output of a complex component (like
>  <h:dataTable> and match up the various parts of the emitted
>  output to the child component that was sthe source of each
>  part.  You'd give up that linkage if you used a JSP for the
>  complex component.
> 
> In principle, using JSP for a renderer sounds like a great idea.  In
> practice, you should try building one (like I did) -- and you'll see
> that the results are pretty ugly.
> 
> Craig
> 
> 
> On Mon, 17 Jan 2005 08:30:53 -0600, Heath Borders
> <[EMAIL PROTECTED]> wrote:
> > The most annoying thing for me about writing custom renderers is the
> > way that you have to write all the HTML code inside of ResponseWriter
> > method calls.  This is similar to the problem that JSPs solved with
> > Servlets.  Is it possible, then, to use the "extends" page directive
> > on a JSP to have the JSP compile into JSF renderer java code?
> >
> > I'm sure this would renderer development and maintainence a LOT easier.
> >
> > --
> > -Heath Borders-Wing
> > [EMAIL PROTECTED]
> >
> 


-- 
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to