JSF & Struts

After reading several articles about JSF and Struts,
where opinions concur and also differ,
I would like to get an opinion from this list regarding starting a new project.
If I start a new project, should I even bother to
consider Struts, or should I just use JSF?
Most of the comments that I've seen are about recommendations for migrating Struts to JSF (specially the
html part). How about starting a brand new project?
Will it be OK if I only use JSF? Will there be
a lot of work if I start with JSF and later decide
to replace some of the pieces with Struts?
I'd appreciate some comments.
gs

I think any project started today with implementation schedule early next year should be focused on Struts (like Jonathan said earlier). If you are in the exploritory stages of an implementation that will probably finaly deliver in '05 then I'd say JSF is the way to go. My reasoning is based on the industry support that was apparent at JavaOne and all the buzz. Most, if not all, J2EE servers will have JSF by sometime in '04 and I susspect that by late '05 many execs will be wondering why they allowed Struts to be used...
Not that there is anything wrong with Struts. Its great and has a lot of mind share (books, knowledge base etc), its really cool, and fun to work with, it does a reasonable job of separating the view from the model etc. Its good stuff. But since out of the box app servers will support JSF, Struts will be less and less important from an enterprise perspective. I susspect that this will really happen in full force when JSF becomes part of the J2EE spec (just speculation on my part, but it seems reasonable given the 'http://java.sun.com/j2ee/javaserverfaces' url :-).
This is of course only my $0.02 worth...
TTFN,
-bd-
http://bill.dudney.net/roller/page/bill

Similar Messages

  • JSF / Struts - I can't see attributes of my form.

    Hi,
    i've a problem with JSF. I'm using struts in my projects and I need to use a JSF component. So, i integrated JSF & Struts using struts-faces.jar. I converted my jsp file and I succeeded to fill combos but when I submitted form I can't get attributes of my form in action. ( i can see but all of them are null)
    Anybody help me?
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="/WEB-INF/struts-faces.tld" prefix="s"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="http://www.ibm.com/jsf/rte" prefix="r"%>
    <script>
         function gonder() {
              if ( confirm('E-Postay&#305; göndermek istedi&#287;inizden emin misiniz?') ) {
                   document.forms[0].action = "/Admin/admin/testMail.do?method=kurumUygulamaGonder";
                   //alert("document.forms[0].elements['_id0:konu'].value : " + document.forms[0].elements['_id0:konu'].value);
                   document.forms[0].submit();
    </script>
    <f:view>
         <body>
         <hx:scriptCollector id="scriptCollector1">
              <s:form action="/admin/testMail" >
                   <jsp:include page="/common/header_center.jsp" />
                   <center>
                   <fieldset style="width: 80%">
                        <table border="0" align="center" id="oddEvenTable" width="98%">
                             <tbody>
                                  <tr class="listOddEven">
                                       <td><h:outputText value="Kurum" /></td>
                                       <td><br>
                                            <h:selectManyListbox styleClass="selectManyListbox"
                                       id="kurumlar" value="#{mailForm.kurumlar}" size="7">
                                       <f:selectItems
                                            value="#{selectitems.requestScope.kurumList.kurumAdi.kurumAdi.toArray}" id="selectItems0" />
                                  </h:selectManyListbox>
                                       </td>
                                       <td></td>
                                       <td><h:outputText value="Uygulama" /></td>
                                       <td>
                                            <h:selectManyListbox styleClass="selectManyListbox"
                                       id="uygulamalar" value="#{mailForm.uygulamalar}" size="7">
                                       <f:selectItems
                                            value="#{selectitems.requestScope.uygulamaList.uygulamaAdi.uygulamaAdi.toArray}"
                                            id="selectItems1" />
                                  </h:selectManyListbox>                         
                                       </td>
                                  </tr>
                                  <tr class="listOddEven">
                                       <td><h:outputText value="Konu" /></td>
                                       <td colspan="4"><h:inputText id="konu" size="118" value="#{mailForm.konu}"/></td>
                                  </tr>
                                  <tr class="listOddEven">
                                       <td><h:outputText value="&#304;çerik" /></td>
                                       <td align="center" colspan="4"><r:inputRichText width="702"
                                            height="352" id="content" value="#{mailForm.content}"></r:inputRichText>
                                       </td>
                                  </tr>
                                  <tr class="listOddEven">
                                       <td colspan="5" align="center" valign="middle">
                                       <hx:commandExButton
                                                 type="button" value="Gönder" styleClass="commandExButton"
                                                 id="btnKriterlereGoreAra" onclick="gonder()">
                                            </hx:commandExButton>
                                       </td>
                                  </tr>
                             </tbody>
                        </table>
                   </fieldset>
                   </center>
              </s:form>
    </f:view>

    Settings>Mail, Contacts, Calendars>Show
    http://i1224.photobucket.com/albums/ee374/Diavonex/382b7c7505f26ac775b54ce257655 5b4.jpg

  • J2EE MVC模式JSF与Struts的异同

    J2EE MVC模式JSF与Struts的异同
    Struts和JSF/Tapestry都属于表现层框架,这两种分属不同性质的框架,后者是一种事件驱动型的组件模型,而Struts只是单纯的MVC模式框架,老外总是急吼吼说事件驱动型就比MVC模式框架好,何以见得,我们下面进行详细分析比较一下到底是怎么回事?
      首先事件是指从客户端页面(浏览器)由用户操作触发的事件,Struts使用Action来接受浏览器表单提交的事件,这里使用了Command模式,每个继承Action的子类都必须实现一个方法execute。
      在struts中,实际是一个表单Form对应一个Action类(或DispatchAction),换一句话说:在Struts中实际是一个表单只能对应一个事件,struts这种事件方式称为application event,application event和component event相比是一种粗粒度的事件。
      struts重要的表单对象ActionForm是一种对象,它代表了一种应用,这个对象中至少包含几个字段,这些字段是Jsp页面表单中的input字段,因为一个表单对应一个事件,所以,当我们需要将事件粒度细化到表单中这些字段时,也就是说,一个字段对应一个事件时,单纯使用Struts就不太可能,当然通过结合JavaScript也是可以转弯实现的。
      而这种情况使用JSF就可以方便实现,
    <h:inputText id="userId" value="#{login.userId}">
      <f:valueChangeListener type="logindemo.UserLoginChanged" />
    </h:inputText>
      #{login.userId}表示从名为login的JavaBean的getUserId获得的结果,这个功能使用struts也可以实现,name="login" property="userId"
      关键是第二行,这里表示如果userId的值改变并且确定提交后,将触发调用类UserLoginChanged的processValueChanged(...)方法。
      JSF可以为组件提供两种事件:Value Changed和 Action. 前者我们已经在上节见识过用处,后者就相当于struts中表单提交Action机制,它的JSF写法如下:
    <h:commandButton id="login" commandName="login">
      <f:actionListener type=”logindemo.LoginActionListener” />
    </h:commandButton>
      从代码可以看出,这两种事件是通过Listerner这样观察者模式贴在具体组件字段上的,而Struts此类事件是原始的一种表单提交Submit触发机制。如果说前者比较语言化(编程语言习惯做法类似Swing编程);后者是属于WEB化,因为它是来自Html表单,如果你起步是从Perl/PHP开始,反而容易接受Struts这种风格。
      基本配置
      Struts和JSF都是一种框架,JSF必须需要两种包JSF核心包、JSTL包(标签库),此外,JSF还将使用到Apache项目的一些commons包,这些Apache包只要部署在你的服务器中既可。
      JSF包下载地址:http://java.sun.com/j2ee/javaserverfaces/download.html选择其中Reference Implementation。
      JSTL包下载在http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
      所以,从JSF的驱动包组成看,其开源基因也占据很大的比重,JSF是一个SUN伙伴们工业标准和开源之间的一个混血儿。
      上述两个地址下载的jar合并在一起就是JSF所需要的全部驱动包了。与Struts的驱动包一样,这些驱动包必须位于Web项目的WEB-INF/lib,和Struts一样的是也必须在web.xml中有如下配置:
    <web-app>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
    </web-app>
      这里和Struts的web.xml配置何其相似,简直一模一样。
      正如Struts的struts-config.xml一样,JSF也有类似的faces-config.xml配置文件:
    <faces-config>
      <navigation-rule>
        <from-view-id>/index.jsp</from-view-id>
        <navigation-case>
          <from-outcome>login</from-outcome>
          <to-view-id>/welcome.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>
      <managed-bean>
        <managed-bean-name>user</managed-bean-name>
        <managed-bean-class>com.corejsf.UserBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>
      在Struts-config.xml中有ActionForm Action以及Jsp之间的流程关系,在faces-config.xml中,也有这样的流程,我们具体解释一下Navigation:
      在index.jsp中有一个事件:
    <h:commandButton label="Login" action="login" />
      action的值必须匹配form-outcome值,上述Navigation配置表示:如果在index.jsp中有一个login事件,那么事件触发后下一个页面将是welcome.jsp
      JSF有一个独立的事件发生和页面导航的流程安排,这个思路比struts要非常清晰。
      managed-bean类似Struts的ActionForm,正如可以在struts-config.xml中定义ActionForm的scope一样,这里也定义了managed-bean的scope为session。
      但是如果你只以为JSF的managed-bean就这点功能就错了,JSF融入了新的Ioc模式/依赖性注射等技术。
    Ioc模式
      对于Userbean这样一个managed-bean,其代码如下:
    public class UserBean {
      private String name;
      private String password;
      // PROPERTY: name
      public String getName() { return name; }
      public void setName(String newValue) { name = newValue; }
      // PROPERTY: password
      public String getPassword() { return password; }
      public void setPassword(String newValue) { password = newValue; }
    <managed-bean>
      <managed-bean-name>user</managed-bean-name>
      <managed-bean-class>com.corejsf.UserBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
        <property-name>name</property-name>
        <value>me</value>
      </managed-property>
      <managed-property>
        <property-name>password</property-name>
        <value>secret</value>
      </managed-property>
    </managed-bean>
      faces-config.xml这段配置其实是将"me"赋值给name,将secret赋值给password,这是采取Ioc模式中的Setter注射方式。
      Backing Beans
      对于一个web form,我们可以使用一个bean包含其涉及的所有组件,这个bean就称为Backing Bean, Backing Bean的优点是:一个单个类可以封装相关一系列功能的数据和逻辑。
      说白了,就是一个Javabean里包含其他Javabean,互相调用,属于Facade模式或Adapter模式。
      对于一个Backing Beans来说,其中包含了几个managed-bean,managed-bean一定是有scope的,那么这其中的几个managed-beans如何配置它们的scope呢?
    <managed-bean>
      <managed-property>
        <property-name>visit</property-name>
        <value>#{sessionScope.visit}</value>
      </managed-property>
      这里配置了一个Backing Beans中有一个setVisit方法,将这个visit赋值为session中的visit,这样以后在程序中我们只管访问visit对象,从中获取我们希望的数据(如用户登陆注册信息),而visit是保存在session还是application或request只需要配置既可。
      UI界面
      JSF和Struts一样,除了JavaBeans类之外,还有页面表现元素,都是是使用标签完成的,Struts也提供了struts-faces.tld标签库向JSF过渡。
      使用Struts标签库编程复杂页面时,一个最大问题是会大量使用logic标签,这个logic如同if语句,一旦写起来,搞的JSP页面象俄罗斯方块一样,但是使用JSF标签就简洁优美:
    <jia:navigatorItem name="inbox" label="InBox"
      icon="/images/inbox.gif"
      action="inbox"
      disabled="#{!authenticationBean.inboxAuthorized}"/>
      如果authenticationBean中inboxAuthorized返回是假,那么这一行标签就不用显示,多干净利索!
      先写到这里,我会继续对JSF深入比较下去,如果研究过Jdon框架的人,可能会发现,Jdon框架的jdonframework.xml中service配置和managed-bean一样都使用了依赖注射,看来对Javabean的依赖注射已经迅速地成为一种新技术象征,如果你还不了解Ioc模式,赶紧补课。

    JSF在很大程度上类似Struts,而不是类似Tapestry,可以说是一种Struts 2.0,都是采取标签库+组件的形式,只是JSF的组件概念没有象Struts那样必须继承ActionForm的限制;JSF在事件粒度上要细腻,不象Struts那样,一个表单一个事件,JSF可以细化到表单中的每个字段上。
      JSF只有在组件和事件机制这个概念上类似Tapestry,但是不似Tapestry那样是一个完全组件的框架,所以,如果你做一个对页面要求灵活度相当高的系统,选用Tapestry是第一考虑。
      Struts/JSF则适合在一般的数据页面录入的系统中,对于Struts和JSF的选用,我目前个人观点是:如果你是一个新的系统,可以直接从JSF开始;如果你已经使用Struts,不必转换,如果需要切换,可以将JSF和Tapestry一起考虑。
      另外,JSF/Tapestry不只是支持Html,也支持多种客户端语言如WML或XUI等。
      这三者之间关系:如果说Struts是左派;那Tapestry则是右派;而JSF则是中间派,中庸主义是SUN联盟的一贯策略。

  • No support (wizard) for JSF & struts portlets

    I can create portlets (JSR 286 & Oracle PDK-Java) in JDevelopers. However I feel the wizard is not mature. I can only create one kind of portlet (JSR 286) using JDeveloper if we consider only standards based portlet - this portlet is called Java portlet in WebLogic. Can't create JSP, URL etc protlets, even no support (wizard) for JSF & struts portlets...
    Is there anyway to enable these features?
    Thanks.

    Check below link if useful
    http://docs.oracle.com/cd/E17904_01/portal.1111/e10238/pdg_java_adv.htm#CHDFAHEC
    http://docs.oracle.com/cd/E12524_01/webcenter.1013/e12434/jpsdg_java_adv.htm#CHDFAHEC
    Edited by: ngsankar on Jun 6, 2012 10:56 AM

  • JSF Struts Integration Action lost on submit

    Hi All
    I've been tearing my hair out with this one for half a day. I am producing a web app using struts and jsf in conjunction. I have succesfully used the integration library on several pages, so I know the framework is in place. However for the following page I can produce valuechange events and process them on a javascript submit, and perform a quick return render, but when I press the submit button, the action is not forwarded through to struts action.
    The jsp page :
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <%@ taglib prefix="s" uri="http://struts.apache.org/tags-faces" %>
    <f:view>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <s:html>
    <head>
    <s:base/>
    <title>selectplot.jsp</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    </head>
    <body>
    <s:form action="/redirectSelectSite">
    <table border="0">
    <tr>
    <td>Site Code</td>
    <td><h:selectOneMenu id="siteSelect" value="#{SelectPlotForm.sitecode}" valueChangeListener="#{SelectPlotForm.processSiteChange}" onchange="this.form.submit();">
    <f:selectItems id="siteSelectItem" value="#{SelectPlotForm.sites}" />
    </h:selectOneMenu>
    </td>
    </tr>
    <tr>
    <td>Plot Number</td>
    <td><h:selectOneMenu id="plotSelect" value="#{SelectPlotForm.plotno}" >
    <f:selectItems id="plotSelectItem" value="#{SelectPlotForm.plots}" />
    </h:selectOneMenu>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center"><h:commandButton id="submit" type="SUBMIT" value="Continue"/></td>
    </tr>
    </table>
    <s:errors/>
    </s:form>
    </body>
    </s:html>
    </f:view>Backing Bean:
    public class SelectPlotForm extends ActionForm {
    // Omitted unwanted detail.
    * @param event
    * @throws AbortProcessingException
    public void processSiteChange(ValueChangeEvent event)
    throws AbortProcessingException {
    if (null != event.getNewValue()) {
    sitecode = ((String)event.getNewValue());
    // Get the list of plots for the new sitecode.
    this.setPlots(ChoicesInterface.getPlotsList(sitecode));
    // Do a quick render response
    FacesContext.getCurrentInstance().renderResponse();
    }struts-config.xml extract
    <action attribute="SelectPlotForm" name="SelectPlotForm" path="/redirectSelectSite" scope="session"
    type="com.millwood.struts.action.RedirectSelectPlot"
    validate="false" input="/selectPlot.faces" >
    <forward name="success" path="/printchoices.faces" />
    </action>and finally the struts action file :
    package com.millwood.struts.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.config.ForwardConfig;
    import com.millwood.Choices.Web.SelectPlotForm;
    * Redirects the user of the selectPlot page to the appropriate action.
    * @author James Salt
    * @since 0.1
    public class RedirectSelectPlot extends Action {
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) {
    SelectPlotForm scf = (SelectPlotForm) form;
    // Construct the foward entity on the fly.
    ForwardConfig fc = new ForwardConfig();
    fc.setName("result");
    fc.setPath(scf.getActionurl()+ ".do?plotno=" + scf.getPlotno() + "&sitecode="+ scf.getSitecode());
    mapping.addForwardConfig(fc);
    return (mapping.findForward("result"));
    }Sorry about the massive posting but I thought it better to provide all the information relevant as currently I am at a bit of a loss.
    I have placed debug points at all the accessible parts of code, but non are triggered, so it must be being bounced in the ActionListener either in Struts or Faces before it tries to get the action.
    Any help would be really, really appreciated.
    Yours thankfully,
    james salt

    Change you action from:
    <s:form action="/redirectSelectSite">
    To:
    <s:form action="/redirectSelectSite.do">
    So that your request gets processed by the Srtuts Controller. Assuming you have *.do mapped to your struts controller in web.xml.

  • Portal Development using JSF & Struts

    Can some one explain about the feasibility of developing portals using JSF and Struts? What are the advantages and disadvantages of doing so? Is it a right decision to develop portal servers using these?

    Yes I am familiar with all those links. Let me break down scenario and ask specific questions.
    Server version: Netweaver 7.0 (2004s) SP18
    1. Created External Library DC (i.e. ebuslib)
             - added 3rd party JARS (e.g. hibernate, Spring)
             - created two public parts - one for compilation, one for assembly (deploy)
             - activated activity
    2. Create J2EE Server Component - Library DC (i.e. ebuslib2)
              - added "ebuslib" assembly PP as Used DC (build only)
    3. Built "ebuslib2"
              - can see jars in the resulting sda file.
              - activated activity
              - confirmed on J2EE engine deployed library containing the jars.
    Scenarios
    A. EP Project DC
               - needs access to 3rd party jars
               - QUESTION: What do I need to reference? The External Library DC or the J2EE Server Component Library DC?
                             - I read that you should reference the J2EE Server Component BUT the jars are not available in the PP of that DC.
                             - One developer one talked to referenced the compilation PP of the External Library DC (i.e. "ebuslib").
                                     - this seemed to work but then I wondered how the project finds the JAR at runtime?
    QUESTION: Does SAP load all the classes that have been deployed via the J2EE Server Component Library DC method and hence those JARs are globally available at runtime hence no need to reference them during development except for compilation? What if > 1 J2EE library contain the same jar or same API but different versions (e.g. Hibernate 2 vs 3).
    Thanks for any clarifications. I want to understand the underlying technology and how it works. I have seen alot of information out there but some of it is confusing and conflicting.
    Dean Cyril Wood

  • JSF - Struts Integration

    Hi,
    At my work place we r trying to integrate JSF and Struts. After doing some research we found out that Struts-Faces is d way we can achieve d same. But d problem is that struts-faces is not available...........
    Wat we need 2 know, are there any other alternatives and from where do we get d struts-faces package.........
    Thanks a lot in advance.

    Change you action from:
    <s:form action="/redirectSelectSite">
    To:
    <s:form action="/redirectSelectSite.do">
    So that your request gets processed by the Srtuts Controller. Assuming you have *.do mapped to your struts controller in web.xml.

  • JSF event handling - JSF/struts/tiles

    Has somebody had any luck integrating these technologies
    and having events for JSF work?
    Gisella

    I just came back from the Thanksgiving holiday.
    I followed the IBM tutorial and got the stuff to
    work. But I have JSF events that work fine when
    they were used in a framework with JSF only. Once I put
    Struts and Tiles, the events were not caught all the time;
    only some times. I traced the code and maybe
    because of Tiles, the Render Response Phase from JSF did not take place.
    "Ordinary Guy", when you said that you had an action listener hooked to a command button, I assume you refer
    to a JSF action listener. Right?
    Gisella

  • Struts/JSF - struts-faces.jar

    I searched the jakarta source and binary
    sites and don't see this library anymore.
    (Unless I go to the contrib dir where the source code is file
    by file).
    Where can I find struts-faces-0.4.zip and its source code (bundled)
    so I can debug my errors?
    Thanks,
    gs

    http://archive.apache.org/dist/jakarta/struts/old/release/struts-faces/

  • Why should i use JSF rather than Struts?

    What makes JSF useful than Struts? In my project I am using like
    <h:commandButton action="#{loginbean.execute}" actionListener="#{loginbean.handleEvent}" ..../>
    In the above commandButton as you can see that i am not exposing the beanName. However i am exposing the beanMethod which are execute and handleEvent. Is there any other way to hide the name of the method because
    From what i understand is Presentation Layer should be shielded from whatever is going on in the backend. So, this doesn't do good right?
    Please suggest.
    How does Component and Renderers help. I am using encodeEnd() method in Renderer to render what the input or the output should look like. Do we need to switch to JSF from Struts just because of this... I don't see how and why components and renderers could help me..

    srikanthradix wrote:
    What makes JSF useful than Struts? In my project I am using like
    <h:commandButton action="#{loginbean.execute}" actionListener="#{loginbean.handleEvent}" ..../>
    In the above commandButton as you can see that i am not exposing the beanName. However i am exposing the beanMethod which are execute and handleEvent. Is there any other way to hide the name of the method because
    From what i understand is Presentation Layer should be shielded from whatever is going on in the backend.You can use "binding" and define everything in Java code if you want. You can rename your method to reflect what you want to see in the front end if you want. You can use JSFTemplating to use handlers which can be mapped to any name you want to see and do not have to match the method name of the java class (although I suspect this is the opposite direction from what you are suggesting you want).
    EL in jsf (i.e. #{bean.login}) is meant to do the mapping in JSF pages rather than externalize this in a separate file and force the page developer to edit multiple files for simple tasks. Although in some cases navigation is broken out into a separate file (i.e. faces-config.xml file using the default NavigationHandler navigation rules), this can also be done inline. It's a different way of doing development and has its pros and cons (easier, but mixes up presentation and controller somewhat). That said... JSF is very flexible, it CAN externalize any of this information, it just requires you to provide a different ViewHandler information that allows you to enter the data the way you like to see it (imo, you won't realize any benefit from the separation, though -- I used to think it was worth doing but have changed my opinion).
    So, this doesn't do good right?Perhaps in theory... but in practice, I don't think it really has a drawback. One caveat, I like how I implemented event handling in JSFTemplating as opposed to action/actionListener attributes which are not configurable and are more opaque than I prefer. My parameterized handlers allow for better code-reuse, but arguably mix up presentation and controller code even more (depending on how they're used).
    Please suggest.
    How does Component and Renderers help. I am using encodeEnd() method in Renderer to render what the input or the output should look like. Do we need to switch to JSF from Struts just because of this... I don't see how and why components and renderers could help me..The idea of a component helps tremendously as someone else can create a component for you and you can benefit from it. There are many great component sets available on the market (for free and for purchase). For example: Woodstock (which has drag/drop support inside NetBeans), RichFaces, IceFaces, Tomahawk, Scales, etc.
    Renderers allow you to cleanly separate the presentation of a component with the data of the component. You can then switch out the presentation to support multiple markups (i.e. client devices). In addition, JSF's rich lifecycle provide logical places for certain types of operations to occur, the renderers participate in this so that they are performing their tasks at a well defined time. And finally, many different components may re-use the same renderer, or a single component may use one of several renderers. The separation of data and display (model and view) makes this very clean.
    JSF is not Struts. If you expect it to be struts, you may be disappointed (or if you expect struts to be JSF, you'll be disappointed). JSF has a lot to offer (as does struts), you have to decide what is important to you and your organization. Some things to consider wrt to JSF: very strong vendor support; many large set of components to choose from; multiple standards-based tools to choose from; very flexible (most parts of the framework are pluggable); active growing development community; component-based model which encapsulates complexity for things like Ajax, pagination, and other things (often complicated in a non-component architecture); good integration with other frameworks.
    I don't know if this makes your decision any easier, but hopefully it helps clarify how you should be viewing JSF & Struts.
    Good luck!
    Ken Paulsen
    https://jsftemplating.dev.java.net

  • The Old Questions: JSF vs. Struts

    Hi there,
    I know this is not new to most of you, and I also read all the postings here and on the Struts website to JSF vs. Struts or better: JSF & Struts.
    In one posting I read that one should consider using JSF for projects in the long run, and use Struts now. Isn't that a very clear recommendation for JSF, and: doesn't that mean that Struts + Integration Library for JSF is not THE solution?
    Considering Struts 2.0, it is expected that JSF and Struts work together nicely and still the View (JSF) will be clearly separated from the Controller and Struts will maintain a strong emphasis on the Controller component.
    Would you agree that Struts 1.1 + Integration Library seems to be a kind of intermediary soltuin to the Struts 2.0 real integration with JSF till Struts 2.0 will come out, one should concentrate more on JSF alone?
    Tough, I know. I would appreciate all your answers.
    cu
    SVEN

    Would you agree that Struts 1.1 + Integration Library
    seems to be a kind of intermediary soltuin to the
    Struts 2.0 real integration with JSF till Struts 2.0
    will come out, one should concentrate more on JSF
    alone?My answer is based on what it is that you want to do. If you are building a product today, then I'd have to recommend that you focus on Struts alone rather then JSF or a hybrid of Struts and JSF.
    Struts is production stable, JSF is not.
    If you are learning a technology for the future, then you are probably correct in mastering JSF alone, and then learning how to integrate with Struts as that strategy matures.

  • JSF or Struts

    Hi,
    We have a web application designed using MVC framework. Besides a web view, we now need to support mobile users using WML.
    We are considering JSF and struts (customising struts to handle WML client).
    I have read that JSF supports disparate clients efficiently using RenderKits.
    Can anyone suggest whether JSF has an easy to use WML RenderKit. How does a renderkit work? Is there any good documentation online?
    Is there a Renderkit for WML readily avaialble or will I have to make one? I know there was a link posted in one of the questions in this forum, but it is a dead link.
    Thanks in advance,
    Harsha

    JSF is better than Sturts. ("Until now there is no sucess story on JSF.")
    Becoz, Struts inventor has been hired by SunMicroSystems to work with JSF. The same guy mentioned in an interview, that struts developement will be stopped in future.
    Also..,
    Until now there is no sucess story on JSF. Only time can decide which is best.
    My suggestion is, better spend your time in learning more jsp and servlets specifications, XML/XSLT, JMS, Webservices rather JSF/Struts.
    All these frameworks like JSF/Sturts will depends on your project requirement. There is a nice book and online document in this website about design patterns. Read those things if you have time. You will get good idea.
    Well.., this is all my personal opinions.

  • JSF, JPF, Struts, SDO小探

    一直对这几个概念不是非常清楚,一直对学习JPF心存疑虑。这几天,花了一点时间,大致上看了一下这几个东西的文档,有了一点收获,和大家探讨一下。
    Struts:不用多说,大家都非常熟悉了。
    Service Data Object(SDO)是JSR235讨论的一种简化数据访问的结构。在Web应用中,可以使数据源对开发人员透明。
    J2EE标准的Java Server Faces(JSF),BEA的JPF,都是基于Struts的,那么有一些什么区别呢?
    JSF更多的是关注于页面的表现,很多结构和Struts非常相似。事实上,JSF的操刀者正是Struts的作者。可以在JSF中非常明显地看到,设计思路是在Struts上的提高和完善。比如,在Struts中,ActionForm事实上就是一个Bean,储存了数据。在JSF中,直接引入了Managed-Bean的概念,这些储存有数据的Bean可以直接放到页面上,这些Bean由程序员完成,美工只是直接把BEAN拖放到页面上,这样,进一步分割了Model和View,简化了开发过程,更加便于协作开发。
    BEA的JPF更多地注重页面和数据的绑定。事实上,绝大多数的动态Web页都涉及到数据的读取和存储,JPF封装了大量的数据绑定功能,也简化了这一类的开发。
    从IBM的红皮书上可以看到,现在IBM的所有涉及到JSF的例子,都用了WDO(WebSphere Data Object)。我的理解,这是SDO的一种。事实上,SDO还只
    是处于JSR状态下,IBM实现了部分的SDO规范的功能。在IBM的例子中,可以看到,通过JSF和WDO/SDO,页面可以很容易地绑定数据,显示数据。
    这一点,和BEA的JPF有异曲同工之妙。巧合的是,JSR235 SDO规范专家组的领头人正是BEA和IBM。
    由此,我得出如如下的结论:
    1、JPF是基于Struts的,将来会基于JSF
    2、JPF和Struts/JSF不是一个层面的东西,JPF是比后两者更高级的框架
    3、JPF在某种程度上,是BEA的SDO实现,将来的SDO正是规范中,必将有JPF的影子
    4、虽然IBM现在在热推JSF,但是其红皮书中承认,JSF目前还是非常新的技术,并不完善,还有待于得到广泛的支持。Apache正在开发JSF-Struts库,
    以便于Struts到JSF的迁移。所以,现在不必急追JSF,有了扎实的Struts知识,迁移到JSF不会太困难
    5、学习JPF是安全的,(这和我以前的观点不同,以前对于JPF了解不深刻,向BEA致歉),将来的SDO会有JPF的影子。
    欢迎大家讨论。

    都劳动高人了,荣幸荣幸。
    在JPF刚出现的时候,就得知BEA非正式地提供了可以迁移到Tomcat的工具。凭借BEA的实力,我毫不怀疑,将来的Java Control和JPF等,都可以顺利地移植到Tomcat或者WAS上运行,甚至连运行库都不需要,直接翻译成标准的Servlet代码。这是完全可行的。
    我前面所说的都是从程序员开发的角度谈,不涉及运行时兼容的问题。Beehive把Workshop Runtime开源了,大家都可以来研究了,非常有利于Workshop的推广。但是,并不是开源的东西一定可以成为标准,承认吗?Tapestry也很不错,也是开源的,但是偏偏Struts最为市场接受,成为了事实上的标准。
    我们是不是不能排除这样一种可能,Beehive开源了,也在一定程度上被广泛接受了,但是就是没有成为标准。成为标准的是JSF+SDO,假设这样。那么,作为程序员,我就有风险了。我花了时间精力,学习了Workshop Framework,也很精通Java Controls了。我毫不怀疑,我写的程序,可以被deploy到任何J2EE兼容的App Server上去。
    另一方面,移植的过程是很复杂的,谁都不能保证移植的程序100%可运行。但是客户的平台是多样化的,出于以后维护的考虑,比如客户是小公司,一直运行Tomcat,他的维护工程师只懂JSP/Servlet/Struts,不懂JPF,那么为了维护,他也希望我用他懂得技术开发。即使我的JPF应用顺利部署到他的Tomcat上,他对今后他将面对的维护也会有畏惧。我总不能强迫他学JPF吧。
    而且客户,都有一种惯性。用惯了.NET的,你向他推荐J2EE都很困难;同理,如果向他推荐非常先进的JPF,客户未必接受。
    我,作为程序员,有交流的问题。比如说,JSP/Servlet,只要是J2EE程序员,大家都懂。无论在Team内部,还是到dev2dev,developerWorks, TSS上,大家都用同样的语言,JSP/Servlet规范和相关的术语。同样的道理,Struts由于是事实上的标准,也是可以被无障碍交流的,大家都懂ActionForm, ActionServlet。但是,只要Workshop一天没有成为标准,就有可能成为一种外语。我在BBS上跟人讲,NetUI:XXXX,不是人人都懂,我讲JCS,JPF,别人就未必懂。我只能到dev2dev,找你Hilaser请教。
    其实,我认为,标准的含义对我而言,就是方便与人交流。UML语言诞生的初衷也是为了交流。虽然,大家都知道,JPF的底层就是Struts,但是偏偏封装后,名字改了,虽然都是巧克力,但是你说它叫“朱古力”,可我只知道他叫“巧克力”怎么办?那就要求我必须同时懂得Struts和JPF,自己给自己翻译了。或者用工具,把JPF转换成Struts,然后拿着机器生成的Struts代码和人讨论?
    谈到这里,所有问题的根出现了,那就是
    * BEA是否有足够的实力,把自己的专有技术推广成标准 ? *
    是要所有的人都接受,成为标准;而不仅仅是开源。
    这里有太多的非技术因素。且不说BEA的股价,庞然大物如IBM或者Oracle的态度。作为客户,他是否愿意押宝在BEA身上,明确BEA的JPF等技术就是将来的J2EE规范呢?恐怕比较难。即使庞大如IBM,客户也不会下这种赌注。客户一般都喜欢用成熟的技术。EJB2.0的规范出现是在哪一年?看看EJB2.0开始广泛运用又是在哪一年?
    这也是,WebLogic这么多年来备受青睐的原因,因为他的技术最标准。所以,我的建议是,在JPF明确成为事实上的标准前,还是持观望态度比较合适。因为JPF和基于J2EE规范的不同Implementation不同,JPF的API是独特的,事实上一个程序员如果只精通JPF,而不懂Struts和JPF的关系的话,那他就真的被绑在BEA上了。对于Struts、JSP/Servlet群来说,他是一个外星人。那么用漂亮的Workshop开发JPF的人,又有多少会想到去了解底层的Struts呢?
    其实,BEA为什么要重新搞一套特殊的API呢?Struts的不足,可以在保留Struts API的基础上,进行扩展,没有必要全部改头换面。保留Struts API的TAG要省多少事啊,再加上BEA的扩展,不一样可以吗。为什么全部换掉呢?
    JPF的技术真的不错,但是,我只了解大致原理,我不去看具体的语法API,我等它成为标准。

  • Multipages Form: JSF or Struts?

    Hi! :) I'm italian so sorry in advance for my poor english! :P
    I would like to know, as your experience, if, to create multipage forms, is more simple using Struts or Java Server Faces (jsf)....
    In my opinion jsf is more simple becouse i cuold use one JavaBean only, and the different jsp pages could refer to that bean (scope request or other also?)...while using struts I must create an ActionForm, and so on...making more laborious job.
    I don't have much experience with this 2 frameworks...so in your opinion which is the most simple to this kind of forms?
    Thanks in advance! :)

    JSF is better than Sturts. ("Until now there is no sucess story on JSF.")
    Becoz, Struts inventor has been hired by SunMicroSystems to work with JSF. The same guy mentioned in an interview, that struts developement will be stopped in future.
    Also..,
    Until now there is no sucess story on JSF. Only time can decide which is best.
    My suggestion is, better spend your time in learning more jsp and servlets specifications, XML/XSLT, JMS, Webservices rather JSF/Struts.
    All these frameworks like JSF/Sturts will depends on your project requirement. There is a nice book and online document in this website about design patterns. Read those things if you have time. You will get good idea.
    Well.., this is all my personal opinions.

  • JSF versus Struts

    Hi, I'm researching JSF and Struts and they look identical. Seems like the developers of JSF just took Struts and changed the wording. What I mean is:
    struts-config.xml became faces-config.xml
    ActionMappings and Actions became NavigationCases and NavigationRules
    FormBeans became ManagedBeans
    MessageResources became MessageBundle
    ActionServlet became FacesServlet (in web.xml)
    Both have validators and converters.
    So am i missing something?
    Also, are there any performance benchmarks that JSF/Struts add to response times?
    Thanks,
    Mike

    I tried out JSF on some small projects and it worked out OK. However, when I tried using JSF on a major project, I got burned. I ended up converting all my JSF work to Struts.
    Before I say what I didn't like about JSF, let me say what I do like. I like how easy it was to associate a button or a link with a method. I like how easy it is to validate input. I liked how easy it is to show or hide components based on boolean expressions. When it comes to these things, I was able to develop code a bit faster with JSF than with Struts.
    However, the negatives were so great that I eventually abandon JSF...
    (1) If you have a graphic artist that creates prototypes using static HTML, converting those prototypes to actual working pages is MUCH easier with Struts tags than with JSF tags. The problem with JSF tags is that you cannot always mix JSF with standard HTML. This is especially true if you are using Tiles. You may end up having to completely rewrite the static HTML tags to their JSF equivalent. This is simply more trouble than it is worth. (There are JSF tag libraries available that act like standard HTML tags, but I found the tags to be buggy and the code simply very cluttered.)
    (2) Creating tables much more complicated that a textbook example can end up being more trouble than it's worth. For example, if you want to create a table where some rows are sub-headers (rows that span all columns and contain a sub-title), then you will end up having to create a custom renderer and a custom tag library. There is a learning curve involved with this. (Even if you are an expert in writing these, you still have extra code that needs to be written.) With Struts, the same thing can be accomplished with some simple logic tags.
    (3) Sometimes, all I really wanted was to iterate through a list of values. JSF does not come with a simple iterate tag. You can loop through your data with a JSTL tag or you can use a datatable or you can create your own tags, but that is extra work. Even if you choose to do any of these, you still cannot reliably mix standard HTML tags with JSF tags.
    (4) Everything in JSF is submitted as a POST. Sometimes, I really needed to use a GET. You can use GETs in JSF, but I found using them to be less than straightforward.
    My advise: If you are building a web app, use a framework that plays well with HTML. (Ultimately, your web app is generating HTML anyway.) If you are building a stand-alone app, use Swing or some language other than Java. If you need your code to run as both, then JSF might be a solution.
    I really wanted JSF to work for me, but I ended up being disappointed.

Maybe you are looking for