Help coderanch get a
new server
by contributing to the fundraiser

Rafael Fontoura

Greenhorn
+ Follow
since Nov 06, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rafael Fontoura

Well, since I started to work with Struts 1 long time ago, I leared that the Action class (don't remember the full qualified name of Struts base class) were the C of MVC design pattern. After that, about 2 or 3 years after that (4 or 5 years ago) I found a substitute to it using JSF: the Managed Bean (MB), that time called backing bean.

Since I've been reading the posts on this forum I saw people naming the packages of the MBs or the MBs with 'controller' suffix and think this were OK, until members of this forum correcting people saying that today the MB has a few or nothing to do with controller, and it is a model (M of MVC). After reading a few articles of MVC, the main thing that makes me believe on this is that when the model changes, the view see this change whithout controller intercepting these communication, and the model classes I write don't do this, but the MB I write does.

Here's an excerpt taken from Head First Design Patterns book explaining the roles of MVC components:
- VIEW - gives you a presentation of the model. The view usually gets the state and data it needs to display directly from the model.
- CONTROLLER - takes user input and figures out what it means to the model.
- MODEL - holds the data, state and application logic. The model is the oblivious to the view and controller although it provides an interface to manipulate and retrieve its state and it can send notifications of state changes to observers.


On the next web system I'm gonna work I want to split the classes and components on the following way:
- xhtml pages - has presentation components and reference to managed beans
- view beans - not a managed bean, just a POJO, keep instance classes used on xhtml pages, like lists, entity beans (I'm using JPA to map DBMS tables to Java) and help attributes and classes
- service classes - holds the business logic, do the validation after the user interacts with the page and communicate with classes that manage the entities (DAOs), retrieving data and sending data do persist on DBMS.
- managed beans - @ManagedBean annotated, has reference to the view beans and the service classes, being the first Java class to receive the action fired by the user, sending content to the service classes (retrieved by the view bean). Here the managed bean would do almost nothing but changing the application flow: it decides when to call a service class, to return to a page (return String = xhtml, presentation view) or to send content processed by a Report tool to the page (a PDF created by JasperReports, for example)

The way I write managed beans makes it more 'controller' than 'model' to me. After viewing this page, which explains that there's many kind of managed beans (model, backing bean, support, utillity), I became a bit confused.

The real question I want to be answered is: the Managed Bean will always be a non-controller component or it depends on the context?

Thanks in advance and sorry for my bad english.
12 years ago
JSF
Well, I don't know if Eclipse WTP comes with a JSF tool pallete. I know that JBoss Tools plugin cames with it if you want to try. Here is the installation instructions.
12 years ago
JSF

mehmet osman wrote:
Anyway, i want to use an entity bean and a controller separetely in JSF 2.0 just like in Struts2 but i am not sure it is possible here.



Well, it's possible like Tim said. If I was making a decision, I use the managed bean as a controller. If you don't plan to split controller and business logic, do it like Tim said: put the controller (managed bean) doing the business logic to manage the model and controlling the application flow. If you choose to split, the managed bean can be used as the controller only, choosing the direction to follow (go to a page, business logic class, retrieve or persist data, show message to user).

I think using a managed bean as an entity bean is awkward, too. Are you using a DBMS to persist data? If yes, can't you use JPA or Hibernate? You could use @javax.persistence.EntityBean to map a relational database table to your entity bean.

mehmet osman wrote:By the way could anyone point me to the direction of a good jsf2 book ?


I recently bought the book Core JavaServer Faces 3rd. Edition. Read it a little and seems to be a very good book.
12 years ago
JSF
Roby, the same answer gived by Tim on this post is valid to this one. In resume, JS files runs on client side.
12 years ago
JSF
Please, I think you should post this type of question on the Java Forum (any basic forum if it exists), because this has nothing to do with JSF. If you need any tutorial on Java, we could help you.
12 years ago
JSF
Well, there's JBoss Tools. Didn't use it much to know if it's a good plugin, but it has visual components to drag and visualize XHTML RichFaces components.
12 years ago
JSF
Well, don't know what's the real problem, but I saw few problems here:

1. Your JSF Servlet mapping points to /faces/*, but none of your page files matches this pattern.
2. Unless you're using JSF 1.x, the file type to use for pages is .xhtml. You write on XHTML files, but the browser/internal requests are for ".jsf files".

I recommend you read some tutorials like www.coreservlets.com/JSF-Tutorial/jsf2/ (if you're using JSF 2.0).
12 years ago
JSF
Good afternoon.

And how about deployment descriptors? Did Struts 2 enhanced the way to tie the input form (if it exists), Action classes, validation framework by, for example, using annotations instead of struts-config.xml?

Thanks
16 years ago
Reading the SCWCD FAQ is a good start: http://faq.javaranch.com/java/ScwcdFaq. From my experience and from others, most of the SCWCD's use the book Head First Servlet & JSP, from O'Reilly. It's complete.
[ March 24, 2008: Message edited by: Rafael Fontoura ]
Today I've passed on SCWCD 5 with a 89% score. After read the HFSJ 1.4 three times, I suggest that reading it two times is sufficient to pass the exam and it will let you have the maximum use.

I read it 3 times because I stoped to study after reading it 2 times (without doing any mock exam). After that, doing the book's final mock exam, doing JavaRanch's mock exam twice and a harder mock test from Anand Chawla, I feel confident to take the exam.

Another suggestion: never go take the exam at mondays... my brain today is slow and slack..., and it difficult me to answer the questions. A good day would be wednesday or thursday.