Resfresh page with ZENMojo and Bootstrap

I have a homeTemplate and ExamesTemplate page. When I'm in ExamesTemplate and make a resfresh (F5 browser), the page back to the HomeTemplate. I need the page ExamesTemplate not return HomeTemplate.

I'm using ZenMojo with Bootstrap

Can someone help me?

 

Thanks.

Answers

When the user refreshes the page, the template defined in the parameter TEMPLATECLASS is loaded. Also, the default keys as specified in your XData block will be used to retrieve your layout and our data (initialLayoutKey and initialDocumentKey).

You can use the documentView's callback onload and load another template and set correct keys before the documentView actually starts the setup process.

Assuming the following documentView definition:

<mojo:documentView id="mainView"
onload="zenPage.initPage();"
initialDocumentKey="home"
initialLayoutKey="home"
ongetlayout = "return zenPage.getContent('layout',key,criteria);"
ongetdata = "return zenPage.getContent('data',key,criteria);"
>
<mojo:jQM-1.3.2-PageManager jQueryAnimation="flip" onPageShow="zenPage.onPageShow(layoutkey,documentkey);">
<mojo:jQM-1.3.2-Helper/>
<mojo:googleMaps-3-Helper/>
<mojo:HTML5Helper/>
<mojo:mojoDefaultHelper/>
</mojo:jQM-1.3.2-PageManager>
</mojo:documentView>

You can define the following method initPage:

ClientMethod initPage() [ Language = javascript ]
{
    zenPage.gotoArea('the area identifier you want to load')
    zen('mainView').initialLayoutKey = 'the layout key you want to use';
    zen('mainView').initalDocumentKey = 'the data key you want to use';
}

Please note that you are first loading your template and then set the initialLayoutKey and initialDocumentKey values, as the documentView hasn't actually done any work yet.

It is on you to store any relevant state somewhere locally, e.g. in a cookie or the localStorage. You can retrieve that state in your initPage() method and initialize your page accordingly.

Stefan, I changed my code and it worked, I used the HTML5 sessionStorage, but the value of my Stash variables in the template page deleted when I do refresh.

How do I keep the value in my stash variables?

 

SessionStorage:

sessionStorage.setItem('customUser',response.ObjUsuario.USRID);

var customUser sessionStorage.getItem('customUser');

 

Stashing:

zenPage._ObjUsuario response.ObjUsuario;

var ObjUsuario zenPage._ObjUsuario

 

Thanks.

We are using Hashtags to load the templates.  

Thats the URL for example:

www(.)mypage.com/myzenapp/mojoclass.cls#Login?r=Dashboard

or

www(.)mypage.com/myzenapp/mojoclass.cls#Dashboard

or

www(.)mypage.com/myzenapp/mojoclass.cls

 

Our custom-script CAJAXNavigation uses onHashChange-Callback (that we bound to zenPage.onHashChanged). There we change the layout with pop and push document. This works very well with the browser history stack. The browser manages hashtag-changes automatically.

With this concept we are changing the layout by simply clicking an anchor with href="#MyLayout"

 <mojo:documentView
 id="mainView"
ongetdata="return zenPage.getContent('data',key,criteria);"
ongetlayout="return zenPage.getContent('layout',key,criteria);"
developerMode="false"
effectsEnabled="false"
maxPanels="2"
onload="zen('mainView').setDocumentKey(CAJAXNavigation.GetInstance().GetCurrentPage() || 'Home');zen('mainView').setLayoutKey(CAJAXNavigation.GetInstance().GetCurrentPage() || 'Home')"
>