You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Chan, Jim" <jc...@incognito.com> on 2006/01/10 23:35:49 UTC

Refactoring JSP to JSF (and then possibly to Shale)

I am refactoring my company's JSP website because the code uses only JSP to
control navigation.  You can imagine its pretty ugly.  Anyway, I decided to
use JSF and possibly move to Shale once I've gained a handle on the
framework.  I successfully deployed some of the pages using MyFaces because
it has a simple integration with Tiles.  

Anyone who tried to refactor JSP to JSF will know that it takes some work to
adapt the existing html/JSP code to utilize the JSF tags.  Because I'm under
time constraints, I've really only used JSF tags for controls that need to
be bound the backing beans.  All other html/JSP code was wrapped with
everybody's favorite tag - <f:verbatim>.  There are verbatim tags everywhere
- yikes.  I am hoping I can refactor them out at some later time, but my
biggest dream is to have the JSF specification at the container level so
non-JSF text do not have to be buffered at all.

Anyway, I wanted to know if:

- I am taking a good approach to refactoring the existing webapp?
- Will JSF evolve to a point where <f:verbatim> tag is not needed?

Any input would be appreciated.  Thanks.

Re: Refactoring JSP to JSF (and then possibly to Shale)

Posted by Michael Jouravlev <jm...@gmail.com>.
On 1/10/06, Chan, Jim <jc...@incognito.com> wrote:
>
> I am refactoring my company's JSP website because the code uses
> only JSP to control navigation.  You can imagine its pretty ugly.

No, I can't.

> Anyone who tried to refactor JSP to JSF will know that it takes some work to
> adapt the existing html/JSP code to utilize the JSF tags.  Because I'm under
> time constraints, I've really only used JSF tags for controls that need to
> be bound the backing beans.  All other html/JSP code was wrapped with
> everybody's favorite tag - <f:verbatim>.  There are verbatim tags everywhere
> - yikes.

Yikes, exactly.

> Anyway, I wanted to know if:
>
> - I am taking a good approach to refactoring the existing webapp?
> - Will JSF evolve to a point where <f:verbatim> tag is not needed?
>
> Any input would be appreciated.  Thanks.

If I were you I'd rather clean scriptlet spaghetti mess with JSTL
tags. Especially JSTL1.1 that allows, for instance, to call methods on
beans. Then I would consider my further options. Quite possibly I
would have been pretty happy with JSTL'ed JSP.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Refactoring JSP to JSF (and then possibly to Shale)

Posted by Werner Punz <we...@gmx.at>.
Rick Reumann wrote:

> 
> Actually you bring up one of the reasons I'm not in love JSF at the
> moment. I know most people like the idea of using pre-built or custom
> renderers and get all googly eyed over the nice things you can get
> out-of-the-box from MyFaces or Oracle ADF, but I guess I'm still
> old-school and like the control of building the front end how I want
> with simple JSTL and html.

There is no ideal approach, but in the jsf world probably using
the jsf-html which can be obtained in conjunction with some client side
componentization library
is a viable approach of having full control without having to mess with
verbatim in and out.

You do not have to forget, that JSF is much more than a html mvc tech it
is built as a general purpose library for server side rendered user
interfaces with strong emphasis on componentization.
So if you want to have full control over high level components like
datatable, you simply will only get it to the degree, the component
allows it. But nothing prevents you from adding another library which
can provide the functionality you need explicetly for html or from using
verbatim.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Refactoring JSP to JSF (and then possibly to Shale)

Posted by Rick Reumann <st...@reumann.net>.
Chan, Jim wrote the following on 1/10/2006 5:35 PM:
> I am refactoring my company's JSP website because the code uses only JSP to
> control navigation.  You can imagine its pretty ugly.  Anyway, I decided to
> use JSF and possibly move to Shale once I've gained a handle on the
> framework.  I successfully deployed some of the pages using MyFaces because
> it has a simple integration with Tiles.  
> 
> Anyone who tried to refactor JSP to JSF will know that it takes some work to
> adapt the existing html/JSP code to utilize the JSF tags.  Because I'm under
> time constraints, I've really only used JSF tags for controls that need to
> be bound the backing beans.  All other html/JSP code was wrapped with
> everybody's favorite tag - <f:verbatim>.  There are verbatim tags everywhere
> - yikes.  I am hoping I can refactor them out at some later time, but my
> biggest dream is to have the JSF specification at the container level so
> non-JSF text do not have to be buffered at all.
> 
> Anyway, I wanted to know if:
> 
> - I am taking a good approach to refactoring the existing webapp?
> - Will JSF evolve to a point where <f:verbatim> tag is not needed?

Actually you bring up one of the reasons I'm not in love JSF at the 
moment. I know most people like the idea of using pre-built or custom 
renderers and get all googly eyed over the nice things you can get 
out-of-the-box from MyFaces or Oracle ADF, but I guess I'm still 
old-school and like the control of building the front end how I want 
with simple JSTL and html. From my brief time with JSF I felt sort of 
constrained having to use the DataTable (I think that's what it was 
called:) to iterate over stuff for display purposes etc. Not saying the 
concept of renderers is bad at all and I guess a set of common controls 
is pretty cool. I just know from experience that pre-built stuff always 
ends up having to be tweaked to meet some crazy business requirement I 
end up having to deal with. At least when I'm working with straight html 
(and the annoying dhtml stuff) I can create everything how I want.

By the way, when you say the site 'only uses JSP' do you mean no Struts 
or other framework is involved? In other words just JSP submitting to a 
servlet and then redirecting/forwarding to another JSP?

I'm more comfortable with Struts so of course I'd feel better taking 
that approach. You could even clean up all your navigation issues using 
Struts and reuse a lot of your old code - including the front end stuff. 
This way you can start small and then implement more and more struts 
pieces as you see fit. For example I'm assuming you are just doing 
typical request.getParameter stuff in your Servlets. Well you could 
still use Struts to go to an Action(a Servlet) and basically put your 
same exact old Servlet code in there. You could in theory clean up all 
your navigation woes without having to change that much of your existing 
code. This actually goes again to something that I do like about Struts 
- it is not too far removed from the ServletAPI. You can still mess 
around with typical Request and Session stuff in your Action classes 
just like you could in any other Servlet (others of course would see 
this as a weakness - ie difficult to unit test Actions etc and they have 
valid points there). JSF, at least from what I've seen, is much further 
removed from the basic ServletAPI so in your case under time constraints 
I'm thinking you'd have more work to do migrating it to JSF. I guess a 
lot also depends on how much existing code you want to reuse and your 
existing architecture. If you plan to rewrite a lot of stuff anyway, and 
you are comfortable with JSF, then go for it.

If you do go the JSF route, I'd appreciate knowing how your experience 
migrating the app went.

-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Refactoring JSP to JSF (and then possibly to Shale)

Posted by Craig McClanahan <cr...@apache.org>.
On 1/10/06, Chan, Jim <jc...@incognito.com> wrote:
>
> - I am taking a good approach to refactoring the existing webapp?


You might be using <f:verbatim> a little more than absolutely necessary.  It
should only be *required* if you are inside a JSF component like
<h:panelGrid> or <h:panelGroup> (or inside a <h:dataTable>), where you have
intermixed child components and markup *inside* a container component.  For
other useds, you should not require them.  Just as an example, if you were
to compose a table output by writing raw <table>, <tr>, and <td> elements,
with JSF components inside the <td>s, no verbatim tags should be required.

As Gary will point out, JSF gives you an opportunity to dump JSP if you
want, too :-).  Using Clay you can write your entire page in pure HTML, with
jsfid attributes to tie in component definitions for the dynamic part.  Not
a <f:verbatim> tag in sight.

- Will JSF evolve to a point where <f:verbatim> tag is not needed?


Substantial progress was made in JSF 1.2, which is nearing completion.



Any input would be appreciated.  Thanks.
>
> Craig

Re: Refactoring JSP to JSF (and then possibly to Shale)

Posted by Werner Punz <we...@gmx.at>.
Chan, Jim wrote:
> I am refactoring my company's JSP website because the code uses only JSP to
> control navigation.  You can imagine its pretty ugly.  Anyway, I decided to
> use JSF and possibly move to Shale once I've gained a handle on the
> framework.  I successfully deployed some of the pages using MyFaces because
> it has a simple integration with Tiles.  
> 
> Anyone who tried to refactor JSP to JSF will know that it takes some work to
> adapt the existing html/JSP code to utilize the JSF tags.  Because I'm under
> time constraints, I've really only used JSF tags for controls that need to
> be bound the backing beans.  All other html/JSP code was wrapped with
> everybody's favorite tag - <f:verbatim>.  There are verbatim tags everywhere
> - yikes.  I am hoping I can refactor them out at some later time, but my
> biggest dream is to have the JSF specification at the container level so
> non-JSF text do not have to be buffered at all.
> 
> Anyway, I wanted to know if:
> 
> - I am taking a good approach to refactoring the existing webapp?
> - Will JSF evolve to a point where <f:verbatim> tag is not needed?
> 
> Any input would be appreciated.  Thanks.
> 
Hi Jim, to get rid of the verbatim tags use following:

http://jsftutorials.net/htmLib/

works pretty well except for div to my knowlege, but div can be added
from tomahwak.

facelets might be problematic though with this approach since there are
probably no faclet definitions for the htmLib.

The main problems you will face are following:
a) be able to make a clear mvc separation, this is a problem unavoidable
by moving to any mvc framework, no matter being it jsf or struts or
whatever.

b) the id handling, due to the auto id alteration of jsf, myfaces has
the ability of forceid, that might work out for you pretty well.

I would recommend not to force things, neither in struts nor in jsf,
move over slowly and keep the old system intact as time permits, after
3-4 pages you will know about the timeframe and actual problems.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org