This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I'm developing a expense authorisantion tool.The expenses can be under various heads like administration,operations,travel etc. most of these have a few common fields that have to be captured.the rest of them are specific to the type like travel may capture airline details etc. i have to dynamically show the screens to capture these information based on the expense type selected.that means i cannot have a formbean that will have get/set methods based on travel etc(simply because the fields to be captured itself is configurable).how do i go about this.
i have decided to have a baseform with facility to capture all possible information.and then use only the relevant ones to display those screens itself with if clauses in the jsp(the fields to be displayed will be stored in the database for a particular expense type). is this a good approach?.is it feasible?. There are around 15 expense types that an employee could raise a request for.
if there are any drawbacks in the approach that i have thought of then what are they?. can anybody let me know all pros and cons of this approach and a better approach if there is any. Regards, Chetan
Welcome to JavaRanch. We don't have many rules here, but we do have a naming policy which we try to strictly enforce. Specifically, you must have a first (familiar) name or initial followed by a last (family) name. Initials are not acceptable in place of last names. Please re-read this document and edit your display name in order to comply. Thanks in advance, and we look forward to seeing you around the Ranch.
When you have configurable fields, I find that it's useful to have a field in the form bean that is based on a Properties or Map object as in the following example:
In your JSP, the code would look like: <html:text property="value(xyz)"/> where xyz is the key within the Properties object. This way you can programmatically manipulate the Properties object any way you want without having to write specific getters and setters for each field.
Regarding your second question, I would think that rather than having a single form for all the pages, a more Object Oriented approach might be to build an abstract base form, and write subclasses of it (one for travel, one for meals, etc.) to use as your actual forms for each jsp page. This way, you have the common fields in every form, but each form has what it needs and no more.
thank you for showing some way forward.I have a reason for going in for one single form rather that using inheritance etc methodology. The reason is there is an admin role for this web appln and he/she can configure fields(add/delete) from an available list.This will then be stored in the database. Like for instance the admin may think airline detials may not be required and he will strike it off.This should then immediately be reflected when the next user logs on.His travel expense form should not show up airline details field. This being the case I can't write my form class beforehand and have it extended from my base form.I can't even have prewritten form classes for any expense types(pls correct me if i'm wrong) I have no clue whatsoever about how to approach this.
Can you tell me how this can be achieved.
Joined: Nov 09, 2000
Since I'm sure you must have simply missed it, I'm going to have to once again direct your attention to my previous post in this thread. If this is not taken care of, it's very likely that your account will be disabled and these threads will be closed. Thanks again.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com