-1

I'm taking over a project which is based on Java Server Faces (project created circa 2009, so JSF 1.0?). I haven't worked out how JSF handles the front controller logic, i.e. how the Faces servlet determines which Java class to forward a GET or POST to. For example, Spring MVC has the "@Request" annotation. How does JSF do it?

This is a very useful link, but didn't answer my question specifically. I wanted know how JSF tied a GET or POST to Java class. It turned out that it's the "action" item in the ice:commandButton, e.g.

        <ice:form id="footForm">
            <ice:commandButton id="cancelButton" value="Cancel" action="#{ProductMB.cancel}"></ice:commandButton>
            <ice:commandButton id="saveButton" value="Save" action="#{ProductMB.save}" disabled="#{ProductMB.notAllRequiredFieldsEntered}"></ice:commandButton>
        </ice:form>
Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213
  • 1
    JSF isn't a request-based framework; it's a component-based framework. A Facelets page may refer to several backing-beans, though in my project most pages are designed to refer to only one. In your Facelets pages, look for lines of code like `value=#{personBean.person}`. `personBean` will be the name of some bean, possibly `PersonBean.java`, and `person` will be a property of that bean. Really though you're better off checking out some tutorials, as you have a lot to learn. – DavidS Sep 14 '15 at 16:47
  • possible duplicate of [What components are MVC in JSF MVC framework?](http://stackoverflow.com/questions/5104094/what-components-are-mvc-in-jsf-mvc-framework) – DavidS Sep 14 '15 at 16:48
  • I hope it's not JSF 1.0. JSF 2.0 was released in 2009, and from what I hear it's much easier to work with. – DavidS Sep 14 '15 at 16:51
  • 1
    Stop. You're going in the wrong direction. Pause the current project, go get a decent JSF book and take time apart to go through it. Here's your starting point for JSF resources: http://stackoverflow.com/tags/jsf/info Then, after having practiced intensively with JSF code based on lessons learnt from the book, continue the project. Otherwise, it will become a disaster. – BalusC Sep 15 '15 at 06:12

1 Answers1

0

The out of the box model for JSF is a bit different than what you are used to with spring mvc. The request handlers are usually mapped to the jsp files under the /webapp directory, so the /webapp/home.xhtml file is served under /yourwebapp/home.jsf

The JSF pages typically pull their dependencies from a managed bean context using the expression language. These beans are either declared in a faces-config.xml application configuration file (which looks a lot like a spring config file). If that's the case, you'll be able to see where all the managed beans live. Otherwise, they'll be declared via the @ManagedBean annotation on the managed bean classes themselves.

I think there are many other flavors of JSF, but this tutorial should give you start on the way the vanilla version works:

http://www.tutorialspoint.com/jsf/jsf_first_application.htm

Robert Moskal
  • 21,737
  • 8
  • 62
  • 86