PDA

View Full Version : [CLOSED] Desktop - saving user configuration and restoring it after login



inteligencija
Jul 23, 2012, 1:06 PM
Hi,

I can't find any example discribing/showing how to maintain changes a user might do to desktop page .

I want to save user configuration (shortcut positions , autorun modules , theme ... ) in DB and restore those settings after user login .
Is this possible for desktop control . I want to save state for whole default.aspx(desktop) page

I explored
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.state.Stateful-cfg-stateful (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.state.Stateful-cfg-stateful)

but

i do not know how to implement this ... Any sample would be appreciated

Thanks

Daniil
Jul 23, 2012, 3:57 PM
Hi,

Unfortunately, we have no such example.

There are some things I can tell.

1. You could easily use the built-in Stateful functionality setting up:

<ext:ResourceManager runat="server" StateProvider="Cookie" />
and

<DesktopConfig Stateful="true">

It will save a state to Cookie and get, respectively, from Cookie.

Apart from investigating the ExtJS docs, to understand better how it works, I can recommend to investigate the Desktop sources, this file:

<Ext.NET sources root>\Ext.Net\Build\Ext.Net\ux\desktop\js\Desktop.js

Please see the getState and applyState functions. As you can see it saves and restores shortcut positions and the quickStart and tray widths.

Sure, you could extend this functionality.

2. To save it into Database using the same mechanism you will need to implement your own State Provider.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.state.Provider (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.state.Provider)

3. Or you could just listen respective events, for example, the Desktop ShortcutMove one to save shortcut positions to a database. When restore it on server side setting up respective properties on creation time.

inteligencija
Jul 24, 2012, 7:39 AM
thanks ,
this is very helpful

inteligencija
Jul 25, 2012, 10:07 AM
Hi , I was able to set this option for cookie provider

I would like to use third option (your suggestion) because I do not understand how to create and use personal provider

Can you help me to pass ,for example, shortcut position (probably as extraparam) . I was not able to find info about current position

I Tried something like this


App.Desktop1.modules[5].shortcut.Y


Thanks

Daniil
Jul 25, 2012, 10:32 AM
The ShortcutMove event is invoked with the following arguments.


el - the Desktop
module - the Module
record - the Shortcut record
xy - the new positon


You could know it setting this:

<Listeners>
<ShortcutMove Handler="debugger;" />
</Listeners>
and move the shortcut.

Or just looking at the Page Sources.

All these arguments you can use to populate ExtraParams. Here is the example.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
class XY
{
public int x { get; set; }
public int y { get; set; }
}

protected void ShortcutMove(object sender, DirectEventArgs e)
{
string moduleId = e.ExtraParams["moduleId"];
XY xy = JSON.Deserialize<XY>(e.ExtraParams["xy"]);
string msg = string.Format("module id: {0}</br>x: {1}<br/>y: {2}", moduleId, xy.x, xy.y);
X.Msg.Alert("ShortcutMove", msg).Show();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:Desktop runat="server">
<Modules>
<ext:DesktopModule ModuleID="Hello" AutoRun="true">
<Shortcut Name="Hello" />
<Window>
<ext:Window runat="server"
Plain="true"
Padding="10"
Width="150"
Height="100"
Title="Greeting"
CloseAction="Destroy"
Maximizable="false"
Minimizable="false">
<Content>
Welcome to Ext.Net desktop!
</Content>
</ext:Window>
</Window>
</ext:DesktopModule>
</Modules>
<DirectEvents>
<ShortcutMove OnEvent="ShortcutMove">
<ExtraParams>
<ext:Parameter Name="moduleId" Value="module.id" Mode="Raw" />
<ext:Parameter Name="xy" Value="xy" Mode="Raw" Encode="true" />
</ExtraParams>
</ShortcutMove>
</DirectEvents>
</ext:Desktop>
</body>
</html>

inteligencija
Jul 25, 2012, 11:58 AM
could you remove close mark for this thread ...

Thanks . it helped a lot .is there a way to get all params (Needed for saving state ) in one direct event ?
for example can I get shortcut position from another event (not shortcut move event )
having simple button that will handle saving all needed parrams


I have anther issue :

code below does not work because
Ext.Net.X.IsAjaxRequest returns
false ( I am using Chrome if it is relevant )

Protected Sub Default_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Desktop1.Modules(5).Shortcut.SetXY("0", "0")

I assume I can not call this method in page_load
I am not sure what AjaxRequest means . Short explanation would be appreciated

And one more thing

what should happen when I use ?


<Listeners>
<ShortcutMove Handler="debugger;" />
</Listeners>
because I do not see any result (where I can see that debugger ) - sorry for probably dumb question . I just started to learn java
And sorry for bed English ...I hope you can understand me

Thanks

Daniil
Jul 25, 2012, 1:11 PM
could you remove close mark for this thread ...


No problem, done.



is there a way to get all params (Needed for saving state ) in one direct event ?
for example can I get shortcut position from another event (not shortcut move event )
having simple button that will handle saving all needed parrams


I think it is possible. You can send as many parameters as you wish. Sure, taking in the account the AJAX, browser limitations.

You should go through all shortcuts on client to get its positions.



I have anther issue :

code below does not work because
Ext.Net.X.IsAjaxRequest returns
false ( I am using Chrome if it is relevant )

Protected Sub Default_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Desktop1.Modules(5).Shortcut.SetXY("0", "0")

I assume I can not call this method in page_load
I am not sure what AjaxRequest means . Short explanation would be appreciated


IsAjaxRequest returns true if DirectEvent/DirectMethod occurs.

Yes, please use the SetXY method during DirectMethod/DirectEvent only.

During initial Page_Load you can just set up the X and Y Shortcut properties.



And one more thing

what should happen when I use ?


<Listeners>
<ShortcutMove Handler="debugger;" />
</Listeners>
because I do not see any result (where I can see that debugger ) - sorry for probably dumb question


Generally, "debugger" allows to debug JavaScript. A browser (all special plugin like FireBug for FireFox) stops JavaScript execution and allow to debug JavaScript.

In this case I recommended it to know the ShortcutMove event arguments.

When you would move a shortcut, a browser (if it can catch "debugger") should stop JavaScript execution and you would see the names of the arguments.

Though it is rather easy to look at the Page Sources.



I just started to learn java


JavaScript :) Java is another language.



And sorry for bed English ...I hope you can understand me


No problem, you are understandable.

inteligencija
Jul 25, 2012, 2:34 PM
so how to set icon position when page loads ?

Daniil
Jul 25, 2012, 3:03 PM
I think here is the answer.



During initial Page_Load you can just set up the X and Y Shortcut properties.


You should read the saved X,Y from the database and apply them to the Shortcut X,Y properties.

inteligencija
Jul 25, 2012, 3:19 PM
Thanks . I finally finished this functionality .

You can mark as Closed now :)

Again , thanks . you helped me a lot