Jeevan Dongre
Jeevan Dongre

Reputation: 4647

How do generate dynamic web page with in the same web application

I thought of re-framing this question once again, to make it clear. Thanks a lot the comments. I am developing a web application in which I am making use of widgets.

Take a real use case scenario, suppose USER-A logins into the my web app and he uses some widgets say A,B and C widgets. He places Widget A in the center, WIDGET-B on to the top right hand side and WIDGET-C on to the left hand side of the page.

USER_B logins into my system and uses the some widgets and places the widgets in different positions since widgets are made draggable and resizable. When the user publishes the page the widget should appear exactly in the same position exactly in the same position where he/she placed.

We are using Jquery HTML5 at the front end and servlet and my sql at the back end.

Upvotes: 0

Views: 272

Answers (2)

djna
djna

Reputation: 55937

Forget about users, just consider retrieving any dynamic content. You've got some arbitrary URL

http://mysite.com/some/path/or/other

or possibly with some parameters

http://mysite.com/some/path/or/other?thing=somevalue

When the browser hits that URL some code of your will run, and you have access to the URL. Depending upon the tools you are using you may even have the parts of the URL broken out for you into some useful variables, if not you can extract the bits you care about.

String interestingBit; // somehow gets set to "other"
String thing; // somehow gets set "somevalue"

Now you can write some code to go fetch data from a file or a database,

databaseRetrieve( interstingBit, thing);

once again nice frameworks may make all this really easy. Then it's just a matter of presenting the data. So dealing with user-specific content can follow this approach. You've got to deal with other issues such as deciding how to structure the repository of content and managing the security, but as I understand your question you were asking about the interpretion of the URL.

Editedin response to clarified question:

Seems like you're developing "personalisation" function that is often provided by "Portal" products and frameworks. The key point is that you have a per-user set of preferences, which control what content is displayed and where it is displayed. There are many such products, I work for IBM so I know about WebSphere Portal and Lotus Mashups, to name but two.

So to implement this you need:

  1. To base the page composition and layout on data retrieved dynamically, say from a database. For this you need to figure out what to stash in the database (say a list of widget names, their sizes and position, and perhaps their styles and configuration too.) and the how to render a page from that information. I don't know JQuery, but you may have to create a bit of code to do this, not really difficult, but some work.
  2. How to select a particular instance from the database based on the user's id and the page they select. Typically the user asks for http://mysite.com/sport and your app knows the user's id from authentication information established earlier in the session and passed around via cookies. In the case of Java EE this is just available in the servlet API.
  3. How to capture the user's edits into something you can save in your repository.

Upvotes: 1

cromestant
cromestant

Reputation: 660

Wow, you need to take a look at your question and possibly clarify it a bit. There are many things in action here, first you talk about personal user spaces, this is very common practice, you need to look into routing requests ( for instance I'd look into rails for zombies tutorial to see how to do this in ROR). You also need to define what you are using to develop this: PHP, java, asp etc... your question is lacking a lot of details that make it impossible to answer correctly or usefully.

Finally you need to show us what you have done so far, because its absolutely impossible to see from your question. Show us some code, give us more specifications as to what you have done , how and what tools you are using.

It seems you are starting with this, so you can start by looking at MVC design pattern, and web frameworks that help you implement this. Routing is the term used to define how the requests are mapped to your application.

Edit:

For your widgets its just a matter of storing the positions foe each user and each widget in some efficient way, then loading it upon login, and using your libraries to re-set the positions on the elements. You have to decide where to store it, but most logical approach is server side ( use a DB table or an attribute per widget to store this). Upon login, get the values and return them to the library (either ajax response, or setting js variables etc.. there are many ways).

Upvotes: 1

Related Questions