Struts and Jsf/tapestry both belong to the presentation layer framework, which is a different kind of framework, the latter is an event-driven component model, and struts is just a simple MVC pattern framework, and we analyze the comparison in detail below.
The first event is an event that is triggered from a client page (browser) by a user action, and struts uses the action to accept events from the browser form submission, where command mode is used, and the subclass of each inherited action must implement a method execute.
In struts, it's actually a form form that corresponds to an action class (or Dispatchaction), in other words: a form in struts is actually a single event, and struts is called Application event, Application event and component events are a coarse-grained occurrence.
Struts important Form Object Actionform is an object that represents an application that contains at least several fields that are input fields in the JSP page form because one form corresponds to an event, so When we need to detail the event granularity to these fields in the form, that is, when a field corresponds to an event, it is not possible to simply use struts, and of course it can be done by combining JavaScript.
This is a situation that can be easily implemented using JSF,
<f:valueChangeListener type="logindemo.UserLoginChanged" />
#{login.userid} represents the results obtained from the GetUserID of JavaBean named Login, which can also be implemented using struts, name= "login" property= "UserId"
The key is the second line, which means that if the value of the UserID changes and the commit is determined, the invocation of the processvaluechanged (...) of the class userloginchanged is triggered. Method.
JSF can provide two kinds of events for a component: Value changed and Action. The former, which we have seen in the last section, is equivalent to the form submission action mechanism in struts, and its JSF is written as follows:
<f:actionListener type=”logindemo.LoginActionListener” />
As you can see from the code, these two events are posted on a specific component field by Listerner, and struts such an event is a primitive form submission submit trigger mechanism. If the former is more linguistically (programming language idioms are like swing programming), the latter is web based because it comes from an HTML form, and if you start with perl/php, it's easy to accept the style of struts.
Basic Configuration
Both struts and JSF are a framework, JSF must require two packages of JSF core packages, JSTL packages (tag libraries), and JSF will also use some commons packages to the Apache project, which can be deployed only on your server.
JSF package Download Address: http://java.sun.com/j2ee/javaserverfaces/download.html Select which reference implementation.
Jstl package Download in http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
So, in terms of the JSF driver package, the Open-source gene is also a big part of the mix, and JSF is a half-breed between Sun partners ' industrial standards and open source.
These two addresses downloaded jars together are all the driver packages that JSF needs. Like struts's driver packages, these drivers must be in the web-inf/lib of the Web project, and as with struts, they must be configured in Web.xml as follows:
<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>
This is exactly the same as the web.xml configuration of struts.