This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm newbie in JSF. Also I'm from Russia and my English is bad. So I hope you'll forgive me if I write stupidities.
I use richfaces 4.3 and Eclipse Juno as my enviroment. I'm trying to use get-post as I've red in book of David Herry.
So I've wrote been-class
I've wrote xhtml View
I've added breakpoint on getWorkZone() and setWorkZone() methods. When my page opens this view, getter is called (I don't sure it is right, but it is so). But when I click link, setter is NOT called. So I don't know where I made mistake. And if I made it.
Здравствуйте, Gregory! Welcome to the JavaRanch! Here you will find many people who are bad at English. Many of them are American.
I think your biggest problem with JSF is the same problem that most people have when they first begin JSF.
JSF is based on the paradigm known as Inversion of Control, or IoC.
In "normal" programming, the programs go out and find things and do things to what they found. In IoC, the things come to the programs, instead.
For example, a JSF View (xhtml) should properly be a template for how the client's screen will be laid out. It should be declarations, therefore not contain parameters or logic, except for limited logic that manages the View format, such as the "rendered" attribute.
All of the logic and data to support the View should be in the Model (backing bean, which is Managed Bean). JSF does not have you code Controllers, since the Controllers are built into the JSF framework itself. The FacesServlet is the master controller.
The backing bean has 2 primary functionalities. 1) As a data repository. 2) As a collection of action methods. It is possible to have only 1 of these 2 functions.
As a data repository, the backing bean is a POJO JavaBean object. In this functionality, the property set/get methods are used by the IoC framework to store and retrieve property values. These methods should do little or no business logic, since they may be invoked an unpredictable number of times for a single HTTP request/response cycle and therefore side-effects or heavy computational requirements would be bad.
As a collection of action methods, the backing bean contains one or more methods which accept no parameters and return either a String (navigation destination URL) or null. The reason for no parameters is that all parameters are already internal properties of the backing bean and therefore do not need to be passed in. The JSF lifecycle ensures that the bean properties have already been set with the latest valid values from the View as it was submitted, because the JSF IoC has injected them via the bean's property "set" methods.
The other trap that people new to JSF are likely to fall into is excessive use of Listener methods and control binding. There is a lot of outdated documentation on the Internet with examples using these features. In common use, Listeners are comparatively rare, and binding much, much rarer. The time to use them is when a simpler POJO solution cannot work. Since JSF was designed to do as much as possible using POJO techniques, that should be the exception, not the rule.
An IDE is no substitute for an Intelligent Developer.
Joined: Apr 24, 2013
Thank you, Tim!
A lot of useful information, but I asked another thing. Or I don't understand you fully.
So problem was that setter wasn't called, but it was made.
So I've resolved it by replayceing metadate-block from View to main.xhtml like so
But, unfortunally, it works not so I wanted. It refreshes all page not using ajax. So I'm searching for another solving :)