When I open two browsers and enter details parallely, the values are getting mixed. The values in one browser are populated in the other browser... We are using JSF framework and the managed beans are in session scope (having them in request scope is not possible in our case)... In a nutshell, the values are shared across the browsers... How to avoid this? Any clue?
If you "open two browsers" means you open two windows of same browser then everything is correct - you can get just one session per browser (for firefox there is plug-in which allow to avoid this limitation).
But if you use really two different browsers than in this case seams you save all data in application scope or you have a problem with you container.
You need to put the bean in request or view scope instead. Storing request/view based data in a session scoped bean is a bad idea, as you've encountered yourself.
I think the view scope would help a lot, given the fact that you mentioned that the request scope is "not possible" (it actually is, it only requires preloading the right data so that JSF can take the right actions accordingly).
Related
I have a bigger SAPUI5 application with multiple pages.
If user navigates through all these pages, they will reside in memory of course.
Now I have the problem that some of these pages have a complex context with several bindings to an ODataModel. That leads to the problem that a .refresh() call on the underlying ODataModel take some time.
Because: all known bindings will be reloaded (also from pages not currently shown)
Now I am searching for a better solution to refresh the ODataModel.
The refresh must be done because sometimes a client action triggers the server to updates multiple data (in different models!).
Further information (Edit)
I am using multiple ODataModels in my application and they are created in the Component.js (as suggested in the Best practice chapter of the SDK documentation).
Navigating through the pages will increase the cached data in the ODataModel.
Calling a .refresh() seems to reload all cached data (still used or not).
According to the first reply it is possible to refresh one binding but how to refresh all bindings of a given view/page with multiple models?
Would it be the right way to set multiple instances of the ODataModel for each view? And just call the .refresh() method there? But also on this scenario the locally cached data will increase over time?
Any ideas welcome :)
You can access the binding of a specific UI control and call refresh there. This should just process this specific binding.
My first hint would be to use the v2 OData Model (sap.ui.model.odata.v2.ODataModel), as it uses the Batch Mode by default.
Moreover, when it performs updates, it refreshes all bindings of entities that have been updated automatically so you should not need to refresh the whole model at all.
For me it worked to just re-bind that binding on a specific element in the view as I did earlier to create it at all.
We had an update-problem after another update call had side effects on the information in question, but a refresh on the binding of the elemnt itself did not solve that. I guess there were no local changes to that path in the model, so there was nothing to refresh. But on server-side there where updates the model/Cache didn't know about. Rebinding made my day, and also only the one necessary call to the servcie was made.
I am running into weird problems when using window scope in IceFaces 3.3. When I put debug statements on constructor and destroy method (using pre-destroy annotation), I am seeing that the same bean is being created and destroyed and re-created when a single user navigates between pages. I checked the access logs on the tomcat server and it shows that the user is using a compatible browser like IE8 and is not opening any new tabs other than navigating between the pages.
What is the lifecycle of a window scoped bean. What triggers a window scope bean to be destroyed?
This behavior does not happen consistently on the same browsers. It happens for some users using IE8 while not others. But most of the cases where the bean is re-created seem to be the cases where the user is behind some kind of proxy. Would the proxy be causing such a behavior? but then again the users session remains valid i.e. the session which keep tracks the name of the user etc., stays the same between pages.
How can this behavior be solved. Is window scope unreliable?
Yes, it's unreliable and perhaps doesn't serve the purpose of window scoping. You need to implement your own custom scope and not the icefaces predefined #{window}. The class org.icefaces.application.WindowScopeManager should give you some hints as to why you are seeing the behavior.
I have a Resource Handler that needs to access lower level beans that work in conversation scope. Our application allows multiple login sessions on different browser tabs working within the same browser session by keeping the login details at this scope - so a database access (my Resource Handler) needs the login for the Conversation that referenced it.
I've tried just expecting it to work, even using ExternalContext.encodeRedirectUrl() to try to make Faces include whatever it needs.
I've tried explicitly putting the ?cid parameter onto my request path so I am accessing
/myapp/javax.faces.resource/thumbnail_3963075518712822225212162218.png.xhtml?ln=com.myapp.attachment&cid=1
No Conversation appears in the Resource Handler.
Further if I try to test for this using Conversation.isTransient() I get a
javax.enterprise.context.ContextNotActiveException: Conversation Context not active when method called on conversation Transient conversation
(Yet I thought Conversation is always meant to be active, and the stack trace for the above does include the org.jboss.weld.servlet.ConversationPropagationFilter!
I'm hoping this is not to do with the bug https://issues.jboss.org/browse/JBSEAM-3689 - for which the workaround is "Do not use conversations!"
Is there better?
Thanks
- Richard
Take a look at Seam Faces and see if you can get things to work the way you want. JSF has next to no compatibility with CDI in the JSF 2.0 and 2.1 specs. We're working hard with the lead for JSF to make it better for JSF 2.2, sorry for any inconveniences.
Mad idea - write an XHTML page with a Restore View event handler that manually renders the resource and calls Complete() on the FacesContext. Ugh! But XHTML pages do get conversations.
I have done what is perhaps suggested in the bug report. I've found a way of solving the problem not using Conversation Scope. In my case I have a ThreadLocal that, if present, provides alternate information to the component that access Conversation Scoped data.
Take a look at Apache Myfaces CODI,
Conversation management is superb with their extensions
I have this idea for a project. Associated with any web page, i want to create notes that will be saved locally in a database, the notes will be reloaded automatically from that database the next time i visit the same page.
Creating the note is easy, but i'm looking for how to link the notes to the web page url and how to keep aware of the active web page. Any idea?
(Note: i have come to this searching on the internet: http://webkit.org/demos/sticky-notes/ - this is part of WebKit Open source projects) - this is about what i'm looking for.
Thank.
Browserdependent probably. You'll have to have a plugin for every browser type.
IE might be doable via the COM interface, but that probably would require starting IE via a way you control. So that probably will have to be a plugin too.
For browser independence, there are quite a few challenges in this one. One way would be to implement a proxy server and watch for text/html content....this will work for most of the general cases, but not every case. Handling frames for instance... which resource is the "parent" and which is the "child"? Which one contains the sticky note? I think you would have to inject some client side javascript to keep track of things, and that might break some websites.
protonotes.com is a web service version of this. Not sure how they do it though.
Actually, Daniel H hit the nail on the head mate: http://www.protonotes.com
It does exactly as you want, in fact it gives you two options to store your data, the first is hosted, the second is your own mySQL db - protonotes pipes the data from the tack-on style notes to your own db, if you prefer. This means that you're not the only person who can see the notes - access is granted by a unique 'group' key.
I've just deployed protonotes as our main online review tool for two reasons, we can save our own data, and it lacks some features which I generally label "dubious" anyway.
It's simplicity is great, the only thing I'm aware of that could cause a prob is that it dumps a bunch of stuff in the global namespace - if that's a potential problem for you.
d
Ok, I'm a newbie to ASP.NET web apps... and web apps in general. I'm just doing a bit of a play app for an internal tool at work.
given this tutorial...
http://www.asp.net/learn/mvc-videos/video-395.aspx
The example basically has a global tasklist.
So if I wanted to do the same thing, but now I want to maintain tasks for projects. So I now select a project and I get the task list for that project. How do I keep the context of what project I have selected as I interact with the tasks? Do I encode it into the link somehow? or do you keep it in some kind of session data? or some other way?
As it sounds like you are having multiple projects with a number of tasks each, it would be best practise to let the project be set in the URL. This would require a route such as "/projects/{project}/tasks". It follows the RESTful URL principle (i.e. the URL describes the content).
Using session state will not work if a user possibly have different projects open in multiple browser windows. Let's say I am logging into your system and a selecting two projects opening in two tabs. First the session is set to the project of the first opened tab, but as soon the second tab has loaded, the session will be overwritten to this project. If I then do anything in the first tab, it will be recorded for the second project.
I use:
Session state for state that should last for multiple requests, e.g. when using wizards. I'd be careful not to put too much data here though as it can lead to scalability problems.
TempData for scenarios where you only want the state to be available for the next request (e.g. when you are redirecting to another action and you want that action to have access to the state, but you don't want it to hang around after that)
Hidden form fields [input type="hidden"] for state that pertains to the form data and that I want the the controller to know about, but I don't want that data displayed. Also can be used to push state to the client so as not to overburden server resources.
ok, From what I can tell, the best option seems to be to save it into the Session data
RESTful URLs, hidden fields, and session cookies are your friends.