I have a project that involves conducting and managing online polls. I have a database set up, and a login/sign up page. After logging in, users are directed to the main page, in my case, "index.jsp". On this main page, I want all the current active polls to be displayed (max 5).
My idea was to have a button, i.e. "Create a new poll", and upon clicking it, the user is redirected to a form where they can create a poll (question and choices) using text fields. Upon clicking submit, the newly created poll should be added on the main page, the "index.jsp" page. And here is where I am stuck. Is it possible to modify and update a page while its running? And if so, how? As in, if a new poll is created, the next user that logs in should be able to see the poll displayed on the main page.
I am using a mix of .jsp, .html files and servlets.
Also, is this a reasonable approach? I thought also about polls being separate from each other. As in, if user goes to */pollno=1, it is able to access poll number one, and so on.
Related
We have this XPages application that has one master page (say M.xsp) and several sub-pages, all in separate iframes on the master page (loaded as A.xsp, B.xsp and C.xsp in separate tabs). The application runs fine, generally speaking. Each sub-page shouldn't interfere with the other pages, and as far as I know, it doesn't. Some page-dependent data is stored in viewScope variables, but for the most important parts we developed Managed Beans, with their data mostly in view-scope too.
Now, what we see is the following:
on page A, we do several clicks and some AJAX calls occur to fetch data from the server
we switch to page B, we do 3 AJAX requests for data to the server
we switch back to page A, we do one click to fetch some data again, and a beforePageLoad event occurs! Needless to say, the page is still loaded.
on the same page A, we do a new click to fetch different data, and beforePageLoad is triggered again!
viewScope is lost, my page-dependent bean is lost, very strange.
We checked, but changing the amount of memory dedicated to XPages didn't change anything.
XPages 9.0.1, browser-only.
Can someone please explain this behaviour: how come beforePageLoad is repeatedly executed? How can we prevent it?
Thanks!!
Twas indeed related to the max number of pages in memory. Every time an item in a list on page B was clicked, a sub-page (B1) was loaded in yet another iframe, using a URL with the item as parameter. Many clicks in the list forced many pages to load, causing all other pages disappear from memory. So when we moved back to page A and triggered some partial refresh there, it was as if the the page was new to the runtime environment.
I rewrote the sub-page B2 to stay in memory, and do a partial refresh itself when the list value changes. Quite a lot faster, and no unnecessary page drops.
I am a DBA, not a web developer. I am trying to build a complex website with Joomla. The user page needs to be interactive without refresh. I am not sure I am using the right words, but here goes.
Assume a user is logged in and a session is started - and we have that data along with the users IP address.
The database is crunching things from other users too, just like this one. As the database works, it generates information to be displayed on EACH users screen in real-time, without the user clicking, without screen refresh, and without the web-page code polling the server at intervals. In fact the user may click a different action from their screen simultaneously, so the user screen cannot be sitting waiting for a reply or polling at predefined intervals. It is basically receiving and transmitting "virutally" at the same time. If this is possible to do, a single piece of code would work and results could be deciphered for the right screen entry point (several boxes).
What can be used to do this? Thanks, Bruce
off cource its possible. make ajax call to link like
"index.php?controller=myController"
and in myController set header of either xml or json and prepare response of AJAX there. and at end of code write $app->close(); to avoide rendering of other modules and content
I have an application where an absolutely normal link (like below).. when clicked, calls the action class twice. And this behaviour happens only in IE. In Firefox, when i click on the same link, it calls the action class only once.
Load
This is an older application and im using Struts 1.3 and Tiles.
Any idea why this is happening and/or how it can be troubleshooted?
It could be that IE is preloading prefetching the link.
To verify this, log the time when the request is received. Load the page, wait ~10 seconds, and click the link. If the difference between the log entries is ~10 seconds, it's a prefetch.
The idea is the browser preloads links the user is likely to click, so the result can be server immediately form the browser cache.
HTML5 makes this explicit by defining rel="prefetch". This attribute and value can be set on a, area, and link tags.
Check your page for <link rel="prefetch" href="url" /> or <link rel="next" href="url" /> in the HEAD element. Also, check your A tags for rel attributed as well.
MicroSoft claims to officially support this in IE 11.
All of this is intended to make pages appear more responsive to the user. Where this can fall apart is when the page being retrieved is not cacheable. This will cause the page to be fetched again when the user clicks it. This can be improved by taking steps to make sure the result cacheable. Set appropriate cache headers. There is a Private cache control for content that is intended for a single recipient. It's only stored in private caches, typically the user's browser.
Additionally, your page may not be considered cacheable if it does not provide a Content-length header.
In java, when we establish a connection to a given URL and then open a stream to read from it, what happens when the content of the website changes halfway through reading?
For instance, our cursor was pointing to at line 1000, which was supposed contain a chapter title, but now the page has something completely different at line 1000, or perhaps the content is no longer as big as 1000 lines?
What happens if a given website updates its content every 1-2 secs, with e.g. stock changes, which might include only stocks that ticked in the last 1 sec (content grows and shrinks)?
The behaviour of what actually happens depends entirely on the web server itself and is outside the control of the client.
Most web servers will send and entire, complete document all at once, as if it were a "snapshot" in time of some particular document state.
IMHO the http server will send the content available when the client asks for a resource.
Example:
The clients asks for the index.html page GET /index.html
The server sends the entire page in one session.
The client parses the page and finds that it points to a css file, so it asks for the file.. etc..
So you can't get the first part of a HTML page then a second part of another version, as the server serves the entire page at once.
Dynamic pages have usually static layout and the data is updated using ajax.
A good design solution when a form is submitted, what should be the behavior of "back" and then "forward" browser button.
Similar question is what should happen when a user logout an application the then click "forward" browser button?
I will be glad to hear some scenarios for the mentioned situations.
Thanks.
Edit - should be good to share and my point of view :-)
My personal opinion is after logout the user should be not able to enter the application without go through the login page.
For the submit scenario - after submitted and back browser button , the user should be able to return to the form but with NO containing data.
One common pattern is Post/Redirect/Get. Under that pattern, the result of the post is a bookmarkable (and back/forward navigable) page. The Back button has one of it usual meanings of "I didn't mean to go here, take me back where I was" like hitting ESC in most Windows dialogs, and the Forward button means "I didn't mean to hit the back button, I wanted that page after all." This pattern isn't going to work for everyone; it makes the most sense when each page (including the response to a form submit) represents some conceptual entity that you'd want to bookmark.
As for the logout scenario, most apps check whether you're logged in no matter what page is specified in the URL, and redirect to the login form if you're not logged in. (You don't have to code that on every page; the check is usually a Valve or something.) A nice feature is to remember where the user was trying to go and take them there upon sucessful login.
Your question is more about design than technology, so GWT doesn't really change the picture, except to note that the GWT history mechanism is intended to mimic the behavior of static pages connected by links, which the post/redirect/get pattern does also.
It is very common to use state machines to keep the user(session) and request state. If you have such a state machine then you know that user is trying a wrong transition. Depending on the user state and the wrong transition you can forward the user to a page. For example if the user tries to go to a page which needs to be logged in but she/he has already logged out, you can send her/him to a login page but you can provide user name and only ask for the password.
To add this functionality you can write your own code by hard-coding the state machine in your code or you can use one of the available libraries. For example,
Spring Web Flow provides this functionality for Spring framework.