go to the most recent state on clicking the back button - django

Im building a website using django. On my display page, I have a list of items (with the name results), and I have filters which filter "results" and get another list "filtered" on the display page using an ajax call.
Now when I go to some other page, and then click the back button, I get back to the page with the filters selected, but the results are not filtered (I would want the "filters" list rather than the "results" list on going back). How do I get to the most recent state after using the back button? Basically, everything done using javascript and the subsequent actions get flushed.
Can anyone help me with this. Thanks.

Browser history behavior gets complex, but one technique I've used is to embed the state in the hash. That will make the browser treat each different hash value as a different page in the history, and also lets you do things like bookmark a particular filter selection state. I used jquery, along these lines:
$(function() {
if (window.location.hash) {
// parse the hash and update your filter settings, then get the content and display it
};
function update_hash() {
// calculate the hash based on your filter
window.location.hash = new_hash;
};
};
Then bind update_hash as an event handler for changes.

Related

Document has been modified or corrupted since signed! (data)

I'm working in HCL Notes application. I have developed a summary view to show calculated figures to the user. Then the user clicks one of the action buttons and I open a detailed view, but for that view I setup Selection Formula on the fly so that it shows the records filtered specific to that button conditions. It was working almost fine for a few days, but now most of the time it shows some previously shown (filtered) data no matter what button the user has clicked. Means it doesn't set the Selection Formula of the view and shows the view with the old formula and it won't get back to normal condition even if they restart Notes application.
When the user is stuck in this particular condition, and they peep through the status bar it shows this message:
Document has been modified or corrupted since signed! (data).
The necessary code-snippet is as below:
*Set dtlView = db.GetView("Report_Dtl")
dtlView.SelectionFormula =formula
Call dtlView.Refresh()*
where formula is the dynamically built formula. Looks like the line
dtlView.SelectionFormula =formula
is unable to update the selection formula and then the line below generates the above error message:
Call uidb.OpenView(dtlView.Name,,False, False)
Please help!
Thanks
For "on the fly" modification of the view selection formula your user need "Designer"- access to the database, and that is never a good idea. The help document to the function you are using is explicitly stating that this is not a good idea (emphasise of mine):
This is not a good way to display a selected set of documents for a specific user. When you use this property to change the view selection, it applies to all users of the view.
There are problems with using this method to make a view display a new selection of documents for an end user:
Do not give end-users Designer access to an application.
If it is a shared view, users will interfere with each other's searches.
The NotesĀ® client caches design information, and there's no way to tell it to update its cache (except for outlines). Exiting and re-entering the application usually works, but it's hard to programmatically ensure the user exited the application entirely.
In addition the modification of the view selection formula can break the signature of the design element and then other errors occur.
Better use another approach:
Use a Folder for every user and put the selected documents in there (after doing a NotesDatabase.Search with the formula
Use a separate view for every user and let a server agent manipulate its selection formula with a user that has access.
For having a separate view / folder for every user you could use "Shared, Private on first use"- views (they are not easy to maintain), or any process that generates them and is able to assign every view to the users they belong to... in both cases this needs some effort, but at least it will work.

Calling a non-modal dialog page passing IR report ID in page url

I am trying to change all popup pages in an app from normal page template to non-modal-dialog page template in apex 5.1
I'll try to describe the complete use-case:
I have an Interactive report page with link columns for each record which opens a dialog window where users can edit/interact with the record.
The dialog has Previous/Next buttons to allow users to navigate through the records.
When a filter is set on the report, the dialog window should take this into account in the Next/Previous behavior.
For e.g. if the report filter selects only one row, then the dialog window Next/Previous buttons are disabled because there are no more rows shown by the report to navigate through.
For this functionalities, I need to pass the IR-report ID to the non-modal page.
Now the href property of the link column in the IR report should be something like:
javascript:apex.navigation.dialog('f?p=123:40:12345678:::40:P40_SIGNAL_DEF_ID,P40_IR_REPORT_ID,P40_MODE:42,41982451655076402,E&p_dialog_cs=NwEcqexhNPGD1VziCXol65xHCP8',{title:'SIGNALS_DIGITAL',height:'auto',width:'720',maxWidth:'960',modal:false,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#myStaticID'));
Only two parts in this link I am concerned about. One is the checksum part (p_dialog_cs=NwEcqexhNPGD1VziCXol65xHCP8) and other part is the IR report ID(41982451655076402) I used apex_util.prepare_url function in the SQL query but this is not returning IR report ID something like :
javascript:apex.navigation.dialog('f?p=123:40:12345678:::40:P40_SIGNAL_DEF_ID,P40_IR_REPORT_ID,P40_MODE:42,,E&p_dialog_cs=NwEcqexhNPGD1VziCXol65xHCP8',{title:'SIGNALS_DIGITAL',height:'auto',width:'720',maxWidth:'960',modal:false,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#myStaticID'));
I am not able to get the IR report ID here I tried using $v("myStaticID_report_id") inside this query but not working(though it is working in console)
So right now I am calling apex_util.prepare_url with dummy string say 'report_ID' the result I am passing to a javascript function as an argument. In javascript function, I am extracting the url part of the string(because I need the checksum value) and then replacing the dummy variable with $v("myStaticID_report_id") and then calling apex.navigation.dialog from there.
Now its functional but this needs to be repeated in almost 70 pages in my application. So I want to know if there is a better way to do this.
Thanks in advance

Django multi-select widget. Add arbitrary select components

i would like to make a widget that lets the user select a value from a drop-down list and then add new drop-down lists with values filtered based on the previous selections. I don't know where to start from....
If the amount of drop-downs is finite and determinable by the time you develop the software (e.g. selecting country->city->street) I would suggest to:
add all the extra dropdowns (without data yet) to your form, make sure they are hidden
use jqueryui to un-hide and populate the dropdowns as needed using ajax
Don't forget to disable/hide the whole form by default and only show it if JS is enabled in browser.
Also, you will of course need another view, with which only ajax speaks.
Here for you to catch the idea how the stuff should work. Sorry don't know if they have anything more similar. But: user selects something -> jquery requests data for the next dropdown -> jquery displays next populated dropdown.

Which is the best approach to get the sitecore item on ajax call

Think about the scenario, where the page has to render the content dynamically when they do some operation on page.
Here basically, page will contain a list of rendering and in each rendering we will be able to get the current item using below statement.
var item = Sitecore.Mvc.Presentation.RenderingContext.Current.Rendering.Item;
Now if i have to show the content on button click, we will do a ajax call to our mvc controller/action, and in our Action we can render the item by following statements.
Item item = SitecoreHelper.GetSCDb().GetItem("{item id}");
or
Item item = SitecoreHelper.GetSCDb().GetItem("item path");
But in both the cases we have to hardcode the id/path.
So can anyone tell me, is there any better approach to do this.
I appreciate your help.
Cheers:)
Something I've done on Sitecore + MVC projects was for content items that are going to be accessed by both Page Editor and by AJAX calls in JavaScript, is creating a new device in that items template _StandardValues, in that I set the query to ?Ajax=true. I then put only the HTML piece (without styles, and JS) as the layout. While the desktop view has what it would look like "after" it's been called by AJAX. This doesn't need any .net coding, it's all done via sitecore.

Use a link as a form field without javascript

i'm almost done developing a search engine in django 1.3. I'm having some filters on the left side of my application.
What i want to do is display those filters as links (not as radiobuttons /selectbox /checkbox) and whenever a user clicks on one of those links, the form is resubmitted with that filter's value submitted (maybe grabbed by a TextInput widget)
Basically, something like the left side filtering in this example from Google, but without javascript (so even a "non js user" can use my website)
Is it possible? How? Or am i bound to javascripts for this purpose?
Thanks all in advance!
Why not simply use GET query parameters?
Imagine the following:
User searches for "bear", the URL becomes: /search/?q=bear
The query parameters are handled by your view (collect all images corresponding to the query parameters)
The query parameters are sent back to the template in a variable;
Each filter link has the query parameters attached to it together with its own specific parameters, so that the filter link for e.g. medium-sized images becomes /search/?q=bear&size=medium;
Upon clicking that filter link, your view will get a q and an size key in its request.GET dictionary;
Repeat ad infinitum (e.g. /search/?q=bear&size=medium&expression=smiling&color=b-w&activity=dancing).