JSF

Saturday, October 24, 2009

JSF identification
JSF framework to build interFaces user for web application. Built to base on concepts that introduced by Struts and divide with profit a architecture genuinely separate layer presentation from business logic and a interFaces user standards component the ware similar to Swing widget.
Under this detail description hows framework Faces work






such as those which we see, JSF has also clear separation between layer component Model, View, and Controlller. same like Struts, JSF has a Controlller servlet frontage that is FacesServlet that to get request from client and then run action that wanted that guided by framework. Another similarity both of them uses action handler apart from Controller servlet frontage. Bevertheless handle Faces this is a little differ from Struts.
Faces and Struts has aim same related to layer View. Here, Struts only prepare a set libray tag that added in part on function standards HTMLunction. On the contrary, Faces prepare set self from components along with a set library to show these components as tag and a result component render that translate UI component be HTML.


Controller
Layer Controller from Faces that consist of Controller servlet (FacesServlet), a set of configuration file XML and a set action handler.

FacesServlet
FacesServlet responsible to get request from client and run operation that need to produce response. This operation belongs to prepare UI components that wanted for request, update component status, call action handler that wanted (if there), and UI components result render that be part from response.
FacesServlet provided for us by framework JSF, and only want configuration in a development descriptor application before ready for used.
Under this cut that for us how configure FacesServlet for our application.









action handlers
Explained previous that Faces use action handler independent from Controller servlet frontage, same like Struts. Bevertheless, Faces do this function differently.
In Faces, there two manners makes action handler. First with make one a method JavaBean to act as action handler, and second with make a class instans implementation interFaces ActionListener.

application method
a method that must has a UI component to act as action handler be called method application. Then, in part View, we shall see to how cordage finished. meanwhile, there are some rule that wanted to make a method application:
-method must public declaration
-method must without parameter
-kind return method must be a String

Under this a method may be can we use to handle a event as result from user that try to logging:














One of the profit from kind action handling this decrease quantity object developers beeds to -maintain. Method this can in every JavaBean that known by framework, although usually detectable in bean that used as backing Model for page form certain. In example on, loginname and password properties in backing Model.
String that returned by method application give information FacesServlet where next seen by user. String has reasonable names, sometimes called outcome; outcome this adjusted with regulations navigation that inscribed in configuration file.
One important matter to is registerred manner that goed by us in laid object into scope session in framework JSF. In Struts, because handling object action form that given a instans HttpServletRequest, be easy to get a copy from scope session that represent object httpsession. any way, bo matter to action handler in Faces. inste, object in framework Faces get access profit to context external (web container, portlets, etc) use a instans from object Facescontext.











after get object Facescontext, we get portfolio representation object in scope session with call getExternalContex(). getSessionMap().


ActionListener

Manner other implementation action handler in JSF make a class implementation interFaces ActionListener. This interFaces spells out a method single:

public void processaction(actionevent event)

object actionevent letted pass as parameter in method that prepare access implementation class to component that caused by event. This matter similar to how does manner object event work in Swing programming.
Under this a implementation example ActionListener that used to logging user action.









up to in this time, better use method application to act as action handler. First, they can be laided in class same where act as backing Model a form, and matter like that has easier access to user prepares data. second, be backing Model admits developers to classify together a data and method that in one class, make more make -maintain. Third, method application will can to return outcome give information FacesServlet display that will displayed furthermore. ActionListener can not, thereby only can bring user return to original page after handling a event.
ActionListener appropriate choice, bevertheless if you want ability general refactor that you can use to return across multiple action sources.
If we see coming, maked to has a method application with a or more ActionListener to work as handler to action certain. Best matter to is done then get best from both: has a method application to do special handling to action, and then has ActionListener that do general aim function.

Faces-config. XML
This matter acts as principal configuration file to layer Controller from framework JSF. as against the colleague friend in framework Struts, he not full configuration inputs for navigation rules, will like also to JavaBean that be identified by framework.

Model
Framework JSF doesn't decide to return every class or component developers is obligated to accustomed to describe every class implementation business logic from application. Any way, in Faces be wanted to has class that will keep UI status component in every page. This class called backing those elements Model.

This class not class when looked at carefully under perspective from Model architecture 2. Any way, when only think UI components, the mentioned can be understood to call class these part from Model, especially if we are to compare it with MVC implementation from component class UI Swing. Remember, in Swing that is rendering layer called View, component status Model and action handler part Controller.

Although they are called part from Model, several things necessary be payed that must be taken in developments from this class like them must not influence kernel function from your application (actually Model). Very good to remember that these components meants to keep status for UI component and may be explain operation base that accessing data stored where can act as method application. They are not meant to do heavy process or every process absolutely that can be used to return in other application.
Make a backing Model for containing page UI JSF component very easy. Same the easy like to make a JavaBean with properties that every component in a page. In this case, they are similar to object actionform in framework Struts, with exception that is them unnecessary to extended every class base that provided by framework.

7 komentar:

Ocim said...

Thanks for the info, js is very infort file in design web

akhatam said...

Wah penting nih kayaknya...!!! bagus sobat.. Terus berkarya...

Firex Santos said...

thnks for many info sob... btw... download terus gratisan di blog we.... semuanya premium download.... keep download...

lusiedulink said...

thanks for sharing the information wega, i am waiting for the next articles

solopunya said...

thx dude, nice post whega

udin said...

nice info sob sukses ya

jaya said...

good article.... thank infonya

Post a Comment

Note: Only a member of this blog may post a comment.