Remove Portlet Session on page refresh - portlet

I am storing a list in a Portlet session. I have to remove the Portlet session on a page refresh because it is displaying the previous value.

Have a look here:
http://portals.apache.org/pluto/portlet-1.0-apidocs/
Get the PortletSession and then call removeAttribute(String name) to remove the attribute from the session.

Related

Redirect in Sharepoint 2010 Event Receiver

I'm looking at some code which has broken the saving of changes of a List item in SP2010. In the constructor of the Event Receiver the HttpContext is being stored as a local variable then in the ItemUpdating at the end a query parameter containing the return url is retrieved and passed the SPUtility.Redirect(...). This has the effect of canceling any changes that were made in the edit form. So following so scenarios I've found online I'm storing the HttpContext as a static class object and redirecting in the ItemUpdated event and edits are now persisted followed by a redirect to where we are expecting.
I have a concern though with storing a specific user's HttpContext as a static on a class which will potentially be hijacked if another user does the same action between the time user 1 sets the context initially and prior to the redirect. User 2 will overwrite the context and there are potential issues.
The only other option I can think of as a quick way out would be to store a static Dictionary where the key is the user id then remove the entry just prior to redirecting so as to not leave stray HttpContext instances leaking.
So looking at the accepted solution from here the first response by servy42 states The fact that it works for a few trivial test cases at first doesn't make it a viable solution. but doesn't suggest a viable solution.
There's another option best approach may be changing Save Button in ribbon such that when clicked, a ECMA script first save your Item, then redirect to other page, or open other page in dialog. suggested further down but is that the only other way to go?
I'm fairly new to SP and just trying to navigate through the wealth of wrong ways of doing things with my limited knowledge, whilst unfortunately being stuck with SP2010.
Any thoughts on how to go about this?
============
Edit: Further info as requested
So there are two sites one say called A which will have a sub site called B. A has a List and adding an item to that list triggers event receivers which creates sub site B and other related stuff. If I modify the B "item" from the SharePoint list of Bs then I don't need to redirect and returning to the list is fine. If I'm looking and a neatly rendered Gantt chart on A listing the Bs the if I edit B after clicking Save we need to come back to A. If I'm on B there's an edit button as well so I want to return to B after editing and clicking save.
So we have the source= appended when we go to the edit screen. From some reading I've done it seems SharePoint will pick that up and redirect. One of the fields on the edit page is the relative url beneath the A site and if that changes then the redirect url will no longer be valid and throw a 404 so we replace the old B sub path with the newly entered value. But we then need code to redirect to the new location.
I am not quite sure whether i understand your requirements correctly. But i will give it a try. Just a quick summary of what i understood (correct me if i am wrong...):
You have a Root Web in a site collection with a list
Each entry in that list corresponds to a subsite which will be created on List Item creation (ER) below the Root Web as a subsite
List items can be edited from both the List in the root web as well as from the subsite it maps to
On editing from the subsite you want to return to the subsite after saving
My approach would be this:
Follow the steps described in this article SP Dialog and List Forms
Open a dialog on the subsite that links to the edit form of the root web.
After saving the user finds himself already where he should be
Hope this helps... Cheers!
Edit: Just read the requirement about changing of url. Create a custom Edit Form which you enhance with some js that passes values back to the origin site -> Parameters in dialogs. You may then react accordingly in the javascript callback and redirect to the new url.

i am not able to keep my wicket form fields blank after browser refresh once they are submitted on the page. my fields are present in a group box

I am not able to keep my wicket form fields blank after browser refresh once they are submitted on the page; my fields are present in a group box.
I have a wicket form with a group box which is having a date picker and text field. If I am entering data and submitting it gives success response. On browser refresh, I want those fields to become empty but they don't.
I tried setting every field to blank after success response as fieldName.setModelValue(new String[]{" "});.
I need this to be done at browser refresh handling without setting it everywhere.
You have (at least) these three options:
1) on success redirect to a fresh instance of the current page, i.e. setResponsePage(getPage().getClass())
2) stay on the current page, but set an "empty" model to the Form. By "empty" I mean whatever "empty" means in your context. Use #setModel() on the form or on the form component. Do not use #setModelValue().
3) Use a stateless page (with StatelessForm) if this is possible

JSF 2 redirect to first page on back button or URL copy paste (no Authentication involved)

I have a JSF 2.0 application that is used for creating accounts using Self Registration. On the first page, there are fields like name, email, uid etc. Typical to any registration, we show the confirmation page, (other custom pages as well in between) and the final success page. Each page is rendered in JSF using the faces-redirect=true so there are 3-4 pages(facelets) in the entire process. In this application, I use a SessionScoped backing bean to show the middle pages/confirmation page/final page etc. After the registration is complete, I clear the SessionScope bean from session and invalidate the session.
The problem is:
The confirmation page/middle page etc. show the User details that the User entered from the first page(using the EL from the backing bean: #sessionBean.firstName etc.). So, if the User enters this URL in the browser directly (host/appName/confirmationPage.xhtml), the page loads with blank values (as the User did not go to the first page directly). Also, after the registration is complete, if the User clicks on the back button blank values show up (no-cache is explicitly set in the filter class, so cache is not used here which is the correct behavior)
How do I force the User to go to the first page if the firstName etc. is not present. i.e. when the User lands up on a page, make sure that User landed on this page only through the first page in this session?
Should a filter class be used? Or should a prerenderview event be used to check for blank values and redirect them to the first page? There is no "User Login" here as there is no authentication. I believe this is a common use-case and I would like to know if there is any best practice in JSF

passing variables into new page tab installations

I would like to build a customized Facebook page tab for other page owners to instal onto their Facebook pages. Each page tab will need to have its own ID in the links that lead out of the page tab in order for us to track that page activity.
For example each page tab will have a list of products that link to the relevant product pages on an external website. Each of those links will have a unique ID parameter to we can track clicks and purchases. [e.g http://www.mydomain.com/products/product123.aspx?userid=12345]
So I need to create the userid variable in the link. Possibly using GET (or Request.QueryString for asp) to receive from the initial page tab installation.
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs
[https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
I thought that this will pass the userid over to the new page tab, but it doesnt seem to work.
If anyone could point me in the right direction i would be very grateful.
Cheers
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs [https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
But you are aware, that appending &app_data=12345 does not mean you will get a GET parameter by the name 'app_data', right …?
The app_data will be passed as a property inside the signed_request parameter – so you’ll have to decode that one, and inside you’ll find your app_data value.
Why does 'each page tab' need to have an ID?
The Page ID should be enough for you to determine which content to show (and it's passed to your app on each page load via the signed_request, and the page ID is also passed back to your app in the callback to the pagetab dialog
You could also request manage_pages Permission from the user to determine the list of pages they administer and if your app is installed on each

struts 2 TokenInterceptor Form Tokens

In my web application, I am using Cookie Based session, and thus that session is being shared among all browser tabs, Is there a way to restrict user to have access of application in one tab at a time with the use of tokens(Token Interceptor)? Opening up in a new tab will invalidate the previous tab pages (i.e all application jsp pages including login page)
In short this is not possible and only solution which come to my mind is force user to use a single instance of your application by writing URLs on the fly use a sessionID.
I am not sure why you need this and what exactly is your use case.If i am correct there is such feature in spring security which help us to keep only one instance per logged in user and all you need to set a property in your spring-security xml file like
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
For details refer to these threads
how-to-differ-sessions-in-browser-tabs
allow-only-one-session-per-user