GoView, GoWebForms and Session states


#1

Hi,
I am having real trouble with the evaluation, everything seemed rosey until I hit this snag. I might be being stupid here but I would appreciate all the help I can get.
We have a page that gets the data from an object model connecting to a DB, the first time into the page the diagram loads fine and everything is sweet, I can changes nodes delete links etc. When we come out of the page and change the input parameters and go back in to the page, the first image that is displayed is the old image. we have to physically click a button to refresh the view. (When going back in to the page the chart could for totally differnent data).
I have located that problem is that GoDiagram is retrieving the image from the session state on the reload, and overwriting any changes I make in Page_Load or Init. Is there an easy way to tell it not to use this ID/Image from the session when going back in to the page.
I have tried to include a public class in my Webform which inherits from GoView, however I get the following exception.
base class includes the field ‘GoView1’, but its type (GoRefreshView.WebForm2+MCLGoView) is not compatible with the type of control (Northwoods.GoWeb.GoView).
I tried this so I could have access to the Page.IsPostBack property and thus in the OnLoad event I could force it to create a new GoView.
SO the second question is how do I subclass GoView Correctly and insert it on a webform.
Regards,
Paul Kinlan


#2

Hi Everyone,
I have been fiddling around like crazy and I think I have found a potential solution.
On the Page_Load event at if the page is NOT a postback then store any updates that you have made to the document using the GoView.StoreSessionView() method. I think that this is a hack, but I might be wrong. And it did seem to work.


#3

I was going to ask about whether you checked the Page.IsPostBack property. You didn’t say exactly how the user would go back to the original page.
Something that people often do, and that might apply in your situation, is to use the GoView as a way to go to a different page. Imagine the diagram having a bunch of objects representing what in HTML would be tags. You can implement this with the following event handler:
private void MyView_ObjectSingleClicked(Object sender, GoObjectEventArgs evt) {
IGoLabeledNode n = evt.GoObject.ParentNode as IGoLabeledNode;
if (n != null) {
String url = n.Text;
if (url.IndexOf(“http://”) == 0) {
MyView.GetSessionViewsTable().Clear();
this.Response.Redirect(url, true);
}
}
}
Of course you would have your own way of identifying objects that really represented HTML-like links and what the URL should be.
What’s not obvious is that I have added a statement that clears the GetSessionViewsTable() for the session. Since we are calling HttpResponse.Redirect, we know that we’re not coming back to this page, so we can discard any saved GoDiagram session state. This also saves on server resources until the session times out.
Note that if you do this, if the user hits the “Back” button, they will see the original page after all, and none of the GoDiagram images will display anything. You’ll probably want to handle this case somehow–either preventing going “Back”, or by reinitializing (by checking the IsPostBack property).


#4

Hi Thanks for the response,
We will be navigating to other pages from nodes that we select, however some of the team have developed special page controller classes to handle all that. However the client can go back through a variaty of ways, 1, using our own back button which handles navigatio or two using the browsers back button. We will try and get all the users to use our navigation as there will be very littly chance that they could re-view a viewed page [if that makes sense].
The solution that you presented works well and I can’t thank you enough.
Kind regards,
Paul