• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in setting form bean  RSS feed

 
mohsin sheikh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a project as Task Tracking System.One of the entities used in my project are Client and Task.So i build the form bean for Client and Task.
The Client form Bean consists:Client Id,ClientName.The Task form bean consists of TaskId,TaskName,Description,CreateDate,Status etc.The Relation between client and task is of one to many relation.As you all know that with every jsp that contains some form have to be attached with some action form(form bean).I am creating a jsp page that consist the input field as clientName,TaskName,Description,CreateDate,Status.The name of JSP page is CreateTask.jsp and its purpose is to create a task of a client(the task comes from client).My problem is to which form bean should i link this Jsp page.
If i link this page to Task form bean then that bean does not consist client name attribute.Please give me the suggestion of how to solve the above problem.I will be very grateful to you.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you've misunderstood the purpose and function of form beans. A form bean is the Java representation of the data in an HTML page. If you have business entities in your application such as clients and tasks, these should be represented by POJOs (Plain Old Java Objects), not form beans.

When you create a JSP page, you should also create a form bean that has one property for each element on that page. If you choose to do so, you could have a form bean that has a reference to a client POJO, a task POJO, or even a List of task POJOs. The structure of the form bean, however, should be related to the structure of the data as it appears on the page, not as it is in your business model.

The form bean for your page, then, should have whatever properties it needs, whether those properties pertain to a client or a task. Once the page has been submitted, it's then the job of your Action class and whatever business classes it calls to create and maintain the data in a structure that makes sense to your business process.
[ March 14, 2008: Message edited by: Merrill Higginson ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a bit confused but...if there is a relationship between a task and a client, it seems odd that there would be a text field on the task page where people could enter any value. I would expect to select from existing clients or have the client be based on the selected client. If it is a free text field then it seems like your backend processing logic would have to search to see if the client exists and either use that client's id or create a new client. Are you not free to add any fields to your forms? In general the fields on the form should be what is needed to support the page. Your forms do not have to match up exactly with your data model.

- Brent
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!