13.07.2015 Views

JSF vs ASP.NET, What are their limits? - Research

JSF vs ASP.NET, What are their limits? - Research

JSF vs ASP.NET, What are their limits? - Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

{}else{}}Session [“customer”] = customer;Server.Transfer("Default.aspx");Server.Transfer("LoginError.aspx");Code 4) Authentication and using Session Object to storeCustomer Object.Again you can use Session [“customer”] to retrieve customerobject when needed.Customer customer = Session [“customer”] asCustomer;<strong>JSF</strong> developer can use StateManager to store sate. Again similarto .<strong>NET</strong> you need to give objects to StateManager to save them.In <strong>JSF</strong> any object which is needed to be saved with StateManagershould implement StateHolder or Serializable. In <strong>JSF</strong>, data isstored in two different ways: in component tree or in scopedbeans.import javax.faces.context.FacesContext;public void addInSession(){MySession mySession = new MySession();mySession.setName(getMsg());//getSession(bool), true if we want to//create new session, if want to use old//session then falseFacesContext context =FacesContext.getCurrentInstance();HttpSession session = (HttpSession)context.getExternalContext().getSession(false);session.setAttribute(”sessionObj”,mySession);if (session.getAttribute(”sessionObj”) !=null) {MySession mySavedSession = (MySession)session.getAttribute(”sessionObj”);System.out.println(”HTTP Session: ” +mySavedSession.getName());} else {// do something}}Code 5) Using StateManager to store sate in <strong>JSF</strong>2.9 MVCThe Model Controller View (MVC) is a design pattern forseparation business layer from user interface layer in webapplication projects. It consists of three main components: theModel that manages behavior and data domain, the View thatmanages displaying of information and the Controller thatmanages event handling of application [23].Figure 6) MVC design pattern components (layers).There <strong>are</strong> several benefits of working on MVC pattern. WithMVC, Project manager could manage project much easier. This isbecause of benefits of layering programming and within thisarchitecture there <strong>are</strong> clear distinct tasks that could be assigned todifferent groups. So you have all benefits of layeringprogramming with MVC but for the same reason you havecommon problems of them while working with this architecture.For example within this architecture you have a more complexsystem and more codes <strong>are</strong> needed for finishing your project(comparing to similar projects that don’t use MVC).MVC pattern is implemented by <strong>ASP</strong>.<strong>NET</strong> and <strong>JSF</strong>. Even youcan use your own implementation of MVC. We found that<strong>ASP</strong>.<strong>NET</strong> MVC is a bit easier while with <strong>JSF</strong> more details <strong>are</strong>needed to be studied.Table 3) Table bellow shows the different Items of MVC inboth technologies.Items Different <strong>ASP</strong>.<strong>NET</strong> JSPModel Component Business Logic ServletView Component Aspx files JSP’s pagesControllerOne for each viewis possibleOnecontroller2.10 <strong>JSF</strong> and <strong>ASP</strong>.<strong>NET</strong> FilesBoth technologies use different file types. For a comparison offiles that <strong>are</strong> needed with these tow technologies it may beinteresting to have them all in two tables.File/FolderJsfks/ant/JavaSource/WebContent/WEB-INFTable 4: <strong>JSF</strong> web application project filesDescriptionProject folder that is a project nameA folder that holds ant builds scriptsincluding build.xmlA folder that contains your own Java classesand properties files.A folder that holds the Web application filesused by the application server.A subfolder of WebContent that includesWeb application files that <strong>are</strong> hidden fromweb.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!