Craig R. McClanahan wrote: >I will have time to expand on this at length over the weekend ... but the >things I described in my JavaOne BOF on Struts 1.1 last March look like >they're going to come true (which is good news for Struts folks). > In the meantime, here's a short summary of JSF:
Faces is essentially Struts with a Component UI model. Components are server-side Java objects that implement client-side controls such as HTML textfields, buttons, forms, etc. Components are sort of like Swing components that speak HTTP and are fitted with an HTML (or WAP, or whatever else you want) look and feel. Faces compenents can be fitted with renderers, event handlers, and validators. Faces comes with a standard set of HTML components and a corresonding JSP tag library (like Struts html tags) that let you use those components. Faces also manages the lifecycle of your web application with a controller servlet, very similar to Struts. You can associate renders and event-handlers to server-side components. That means you can write your own custom components for the markup language of your choice. For example, you could implement a component that renders a calendar in HTML or a component that renders a simple WAP form. You can also associate validators with a component. Validators validate a component's input. Another way to think of Faces is this: Take the Struts html tags and rewrite them so that instead of producing html directly, the tags delegate to a component that produces HTML. And you can plug your own custom components into those tags for a different markup language (although you'll want to change the html prefix to something else, like faces). Finally, you can create a new tag and a corresponding component to implement something wild like a WAP calendar. Faces overlaps to a great extent with Struts, although for the EA release, it implements that overlapping functionality much more inelegantly than Struts. For example: 1. If you want a form bean, you've got to create it yourself with <jsp:useBean> in a JSP page. [gasp!] 2. You must manually specify the component field that a control stores its value in, instead of letting the framework take care of it with reflection. Ugh. 3. You specify validators, not in a config file, but for each control in a JSP page. 4. There are no actions: you handle all of your application's controller code in one method (processEvent) in a Java class called the Application Handler. Unless this changes in subsequent releases, your controller logic with Faces will be much more difficult to maintain than it is with Struts. 5. The tag names are quite verbose compared to Struts html tags. For example, here's how you might declare a form that contains a textfield with Faces: <%-- Create the form bean --%> <jsp:useBean id='loginFormBean' class='LoginFormBean' scope='session'/> <faces:usefaces> <faces:form id='simpleForm' formName='simpleForm'> <table> <tr> <td>Name:</td> <td> <%-- Create an HTML input element, specifying the associated model property and two validators --> <faces:textentry_input id='name' modelReference='loginFormBean.name'> <faces:validator className ='javax.faces.validator.RequiredValidator/> <faces:validator className ='javax.faces.validator.LengthValidator/> </faces:textentry_input> </td> </tr> <tr> <td>Password:</td> <td> <faces:textentry_secret id='password' modelReference='loginFormBean.password'/> </td> </tr> </table> <p><faces:command_button id='submit' commandName='Log In'/> </faces:form> </faces:usefaces> Unless you can somehow plug Face's component model into Struts, I don't see much of an integration strategy. We'll have to let Craig enlighten us on that. david > >Craig > >On 6 Sep 2002, Bryan Field-Elliot wrote: > > > >>Date: 06 Sep 2002 12:33:37 -0600 >>From: Bryan Field-Elliot <[EMAIL PROTECTED]> >>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> >>To: Struts-User <[EMAIL PROTECTED]> >>Subject: Struts <--> JSF roadmap >> >>I was wondering if there are others out there who have read the >>(preliminary) JSF (Java Server Faces) drafts, tutorials, etc., with >>opinions on how they relate to Struts? >> >>With Craig the spec lead on JSF, and Craig also being a primary mover >>(as well as original inventor) of Struts, I am hoping he will come >>forward with some real opinions on the matter, such as, where are the >>areas of overlap between the two? I believe there may be overlap in >>validation area, as well as in the general "controller framework" >>mechanism, though I'm not sure yet. >> >>Might there be anything like a "long-term roadmap" for Struts with some >>mention of JSF, and best practices for using the two together? >> >>Opinions appreciated, >> >>Bryan >> >> >> >> > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > >