Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question

Status
Not open for further replies.
Jan 8, 2001
163
US
Hi there. I in the midst of my first jsp application and I'd like a little advice on the scenario I'm facing. In my program I have a user say, "DAVE". I also have a large number of groups that "DAVE" can belong to. (The number of groups changes on daily.)

I have to create a page that will display all of the groups that Dave can be added to. The user can then select multiple groups they wish to add and submit it somehow. In the subsequent page, each group the user selected will then cause a new row to be inserted into the database.

Does anyone have any general (or specific) advice on what the best approach would be to do this? I'm not sure how to approach a situation where the number of groups displayed and selected can change like this.

Thanks,
CrystalVisualBOracle
 
Here is my quick overview of a possible structure.

Login Page:
Ask for username/password
Send Request to Authentication Page

Authentication Page:
Validate User
If Valid, Save User in Session and Redirect Request to Group Page
If Not Valid Redirect Request to Login Page

Group Page:
Determine User from Session and Query the Database for a current list of Groups that User may belong to.
Display List and request User input.
Submit Request to Submission Page.

Submission Page:
Determine User from Session and list of Groups from the Request Object. Save List in Database.
Display Success Page. Wushutwist
 

Group Page:

Determine User from Session and Query the Database for a current list of Groups that User may belong to.
Display List and request User input.
Submit Request to Submission Page.

Submission Page:
Determine User from Session and list of Groups from the Request Object. Save List in Database.
Display Success Page.



Thanks for responding wushutwist. It looks like you and I are on the same track.

I had basically the same scenario in mind. My real issue is in deciding which display type ie/ combo boxes etc will best suit my needs on the group page and how I can pass the selected groups to the submission page.

Up until now I've only ever passed one group at a time via the bean to the submission page to run the update. Now I have to have some sort of box in the Group page which lets the user select any number of groups and then pass those to the Submission page. I don't think a bean will allow me to pass multiple groups effectively. Does that make sense?

If someone has any examples or ideas perhaps you would be willing to share? My guess is that this is not an uncommon issue out there. I just can't find any examples from which to start the ball rolling. Any help would be appreciated!

Thank You!

CrystalVisualBOracle
 
Here is a simple technique that I have used many times, if I do not go into enough detail then let me know.

Group Page:
Display Groups along with a check box (for selection) name the check box a standard name plus the GroupID appended. Example:
<input type=&quot;checkbox&quot; name=&quot;Group1&quot;>
....
<input type=&quot;checkbox&quot; name=&quot;Group5&quot;>

Submission Page:

1) Use getParameters to retrieve an Enumeration of the objects submit by the Group Page. Iterator thru the Enumeration check if the current element starts with &quot;Group&quot;, use the String method startsWith() for this.

2) If the currents element starts with &quot;Group&quot; then get the remaining characters (which would be the Group ID) and add it to a Collection, lets call it groupResults.

3) Get User from Session. Iterator thru the groupResults Collection and add an entry in the Database for each element in groupResults.

It is really pretty straight-forward. Wushutwist
 
Great thanks! I actually went ahead and started doing it just the way you said just before you submitted your entry. I was worried that there may be a better way out there that I hadn't seen yet. I feel better.

Thanks Again,
CrystalVisualBOracle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top