I'm currently just exploring JSF 2 in the JEE 6 stack.
I find quite a bit of limitations with JSF and the way ManagedBeans are used is very counter-intuitive / odd:
It seems that, in order to execute an action event, you have to use <h:commandLink>
tag. Thats all well if I was for example, posting form data. However in this case, all I wanted to do was to simply view a book using the url e.g.: viewBook?id=2
. If i was using spring, it would have been easy:
@Controller
public class BookController {
@RequestMapping("/viewBook")
public String viewBook(@RequestParam("id") Long id, Model model) {
// all the method params(id, model) are provided by spring
BookDTO book = bookService.load(id);
model.addAttribute("book", book);
return "BookView";
}
}
However using JSF, I have to:
<h:form>
<h:commandLink value="#{bookController.viewBook}">
<f:param name="id" value="#{book.id}"/>
</h:commandLink>
</h:form>
and the backing bean:
@ManagedBean
public class BookController {
private BookDTO book;
public String viewBook() {
Long id = Long.parseLong(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValueMap().get("id"));
book = bookService.load(id);
return "BookView";
}
// ...
}
Question is: Is there a framework for JSF2 that provides what spring MVC does?
Another question is: What does JSF provide that couldn't easily be achieved using Spring ?
In my view, the whole JSF / Facelet etc technology is overly complex, over-engineered and counter-intuitive. I hold the same view on EJBs btw.
These views are formed after having explored JEE6, by writing a small JEE web application.
Thanks.