File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF REST GET-request troubles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF REST GET-request troubles" Watch "JSF REST GET-request troubles" New topic
Author

JSF REST GET-request troubles

Gregory Androsov
Greenhorn

Joined: Apr 24, 2013
Posts: 5
Hello!
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15647
    
  15

Здравствуйте, 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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gregory Androsov
Greenhorn

Joined: Apr 24, 2013
Posts: 5
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 :)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF REST GET-request troubles
 
Similar Threads
Bean value not maintained in RequestScoped
Passing parameters with h: link
custom converter usage
JEE example with EJB, JSF is not working
JSF navigation problems.