aspose file tools*
The moose likes JSP and the fly likes Seating arrangement application in JSP/Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Seating arrangement application in JSP/Struts" Watch "Seating arrangement application in JSP/Struts" New topic
Author

Seating arrangement application in JSP/Struts

Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
My requirement is to modify an application which can replicate the floor plan of an office building, and indicate exactly who is sitting where in the office using JSP/Struts.

The existing application has the floor plan hard coded into the JSP, which means a lot of stuff has to change if the floor plan itself changes or if the same application has to be extended to different types of floors.

My manager wants the floor to be generated visually "on-the-fly". What he said he meant by this is that somehow, the space where the floor plan will be shown has to be divided into a grid (i.e. something like the squares of a chessboard...X number of rows and columns). Now, the manager will supply coordinates into a database (in MS Access mostly) (i.e. row 1, column 0 has a cubicle...row 2, column 1 has a printing room etc.). Each of the elements constituting the floor (the cubicle, printing room and other elements have their own pictures which will fit into one "square" on the grid. In case they take up more space, I am allowed to populate the same picture into as many squares as required to represent the space that element takes up...this will be configured into the database as well).

The application is supposed to read this information off the database and populate the grid in the web page accordingly, so that it is rendered dynamically and he can configure coordinates in a similar fashion for different floors.

How do I go about dividing the space on the web page into a grid and populating this from the database (which will hold the coordinates and the id of the element. for example,one row of this database will be 0,1,"T392" which will mean row 0, column 1 of the grid on the web page should contain the element whose ID is T392...it could be a cubicle or anything else in the floor. If it is a cubicle for example, I have to populate that "square" with the picture of a cubicle).

Is it fine if the grid cannot resize itself to account for different types of floors. Only, the area in which the grid has to be displayed has to be fixed (say 400*400 pixels), with scrollbar functionality if the space has been exceeded.

Thanks a ton to anyone who can give me hints and guide me to doing this!
[ December 17, 2007: Message edited by: Ben Souther ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
It's good to let us know exactly where you're stuck ... reading the database, holding the model in memory, generating HTML?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Where I'm stuck is the implementation of this idea...

I don't have any idea of how to divide the space where the floor plan is going to be shown into a grid with cells, and match the identity of the cells with the values supplied in the database. For example, if the database has an entry like 1,1,T192, I must be able to divide the space where I'm going to show the floor plan into a grid such that I can slot the element described by this row in the database into its correct position (1,1 could mean 1st row and 1st column, but I'm asking for generic suggestions on how to get this done...). I will query another table to get what T192 means, so that's not a problem.
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
What would also be really cool is if I could generate the HTML table on-the-fly and populate it with the elements described in the database by using their respective pictures.

What I want to know is how I can divide the space in which I'm going to show the floor plan into a grid such that I can match the position of the element in this grid with the values supplied in the database.

Thanks again for your help!
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Why not just create an HTML table. You can use 1 pt borders with 0 padding and 0 cell spacing. Then you will have your grid. You can fix the widths of everything since the table should be the same size. You would just leave squares blank that don't have anything in them. You could also have them give wall coordinates and you could put a wall picture, a.k.a. a line, for it. There are so many things you can do with this. You could make it as smart or as dumb as you want. Your possibilities are endless.

One thing I might consider is creating a program that allows them to see the grid laid out and let them drag and drop the images into the grid. Then you could have your program write the database file any way you want and then you will be setting the read/write schemes which gives you all the control for the data flow. Plus, this will be much more fun and easy for the guys trying to enter the floor plans. Who wants to type coordinates into a DB by hand?

Just some thoughts to consider
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Sridhar Venkataraman check your Private Messages.
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Hey,

I sent a reply to your Gmail account. I'm not short of ideas when it comes to the presentation of the stuff.

What I don't know is how I can read-off coordinates (positions) from a database and somehow slot the corresponding pictures of the floor elements into their correct places on the web application. I'm talking about co-ordinates in the most general sense (they can be row-column positions, maps or anything of the like).

One seemingly simple idea is to use a HTML table, but how do I navigate through it to place the pictures after reading positions from a database?

I'm seeking a simple (even if it is not very refined) solution to this. Some sample code will be of great help as well [a table, a picture, and slotting that picture into a specific row-column intersect on a HTML table i.e.].

Thanks for your time and attention again. Appreciate it.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
I'll give you an outline of how I would code this. There won't be any functional code, but this is the flow I would go with.

I would have a DB file for each layout. Give it a number or name or something but whatever it is, it has to be unique to the design, not to the file. Your db file would be laid out like this.....



and the value in picture would be the path to the picture that corresponds to the cooridnates.

Then the web app would do an SQL statement and grab the cooridinates by their layout number. It would be very quick and snappy. You then take the resultset and save it to a list of beans.

After you have the bean you would use JSTL to iterate through the list of beans and grab the value that you want.

I can't do any sample code right now, but I might be able to do something when I go home tonite. What is your time frame for this project?
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
I have a week to do this. The DB layout is fine, the grabbing of the coordinates is fine, getting the appropriate picture is fine.

But how about slotting it into the right area onto the space where I'm going to display it? How can I slot 1,1 into its appropriate place on the grid?

I need a simple way to do this. Would love to get some help in the form of sample code. Thanks a ton.
 
 
subject: Seating arrangement application in JSP/Struts