1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    28
    Vote Rating
    0
    aktxyz is on a distinguished road

      0  

    Default save state in a portal to server, care to refactor?

    save state in a portal to server, care to refactor?


    When someone moves a portlet in a portal, I am using this method to gather the positions and then send that to the server...

    PHP Code:
    function save_layout()
    {
        
    //===== gather layout
        
    ""
        
    portal Ext.select(".x-portal").first();
        
    portal.select('.x-portal-column').each(function(e)
        {
            
    e.select('.x-portlet').each(function(e)
            {
                
    += e.dom.id;
                
    += ",";
            });
            
    l.replace(/.?$/, '');
            
    += "|";
        });
        
    l.replace(/.?$/, '');
        
    alert(l);
        
        
    //===== send layout to server

    I only have 1 portal on the page, and I have set the portlets to have id's that basically map to the portlet ids as stored on the server. Not being that into javascript, the code works but seems ugly. Would love some refactoring mojo here.

    -- Thanks

  2. #2
    Sencha User
    Join Date
    Dec 2007
    Posts
    28
    Vote Rating
    0
    aktxyz is on a distinguished road

      0  

    Default one more thing

    one more thing


    The resulting layout string looks like this...

    19dfec36b592ed09,4bef2fa9040d4ecf|db129420a4d6b3f5,c5e790c0bdcd3d6e|00bd9881898d9422,c1727efc57be05fb"

    which translates into

    col1portlet1,col1portlet2|col2portlet1,col2portlet2|col3portlet1,col3portlet2

  3. #3
    Sencha User fangzhouxing's Avatar
    Join Date
    Mar 2007
    Posts
    468
    Vote Rating
    1
    fangzhouxing is on a distinguished road

      0  

    Default


    hi, aktxyz,I have a new Portal example with state management.

    After download, put it in Ext 2.0 examples\portal2 dir like:
    --ext-2.0\examples\portal
    --ext-2.0\examples\portal2 <--- new Portal example

    Hope it helps!
    Attached Files

  4. #4
    Sencha User
    Join Date
    Dec 2007
    Posts
    28
    Vote Rating
    0
    aktxyz is on a distinguished road

      0  

    Default


    Very nice indeed! I need state saved on the server side. I am not sure why all the portal state saving discussions have been about cookie methods. igoogle, netvibes, pageflakes all save state on the server.

  5. #5
    Sencha User fangzhouxing's Avatar
    Join Date
    Mar 2007
    Posts
    468
    Vote Rating
    1
    fangzhouxing is on a distinguished road

      0  

    Default


    In my project, i save state on the server side like this:

    Code:
    Divo.state.DivoProvider = function(config) {
    	Divo.state.DivoProvider.superclass.constructor.call(this);
    	this.userId = Divo.getUserId();
    	Ext.apply(this, config);
    };
    
    Ext.extend(Divo.state.DivoProvider, Ext.state.Provider, {
    	// private
    		set : function(name, value) {
    			
    			//if (name.length>3 && name.substr(0,3)=='ext') return;
    			
    			if (typeof value == "undefined" || value === null) {
    				this.clear(name);
    				return;
    			}
    			var o = {
    				userId : this.userId,
    				code : name,
    				value : this.encodeValue(value)
    			};
    			Divo.rmtCallAsync("SysFacade.saveStorage",Ext.emptyFn(),[o]);
    			Divo.state.DivoProvider.superclass.set.call(this, name, value);
    		},
    
    		// private
    		clear : function(name) {
    			var o = {
    				userId : this.userId,
    				code : name,
    				value : ''
    			};
    			Divo.rmtCallAsync("SysFacade.saveStorage",Ext.emptyFn(),[o]);
    			Divo.state.DivoProvider.superclass.clear.call(this, name);
    		},
    
    		// private
    		get : function(name, defaultValue) {
    			
    			//if (name.length>3 && name.substr(0,3)=='ext') return undefined;
    			
    			var result;
    			Divo.rmtCallSynch("SysFacade.restoreStorage",function(retValue) {
    			   result = retValue;
    			},[this.userId, name]);
    			if (!result) {
    				this.set(name, defaultValue);
    				return this.decodeValue(defaultValue);
    			}
    			return this.decodeValue(result.value);
    		}
    
    });
    		
    Ext.override(Ext.Component,{
       stateful:false
    }); //Thanks: http://extjs.com/forum/showthread.php?t=15675
    
    Ext.state.Manager.setProvider(new Divo.state.DivoProvider());
    
    //EOP
    I use dwr and java server side.

  6. #6
    Sencha Premium Member
    Join Date
    Mar 2008
    Location
    Pune, India.
    Posts
    23
    Vote Rating
    0
    manishaNC is on a distinguished road

      0  

    Default Facing similar problem - how to save drag and drop position, state of Panel

    Facing similar problem - how to save drag and drop position, state of Panel


    Hi,
    I am using ext-2.0\examples\portal\portal.html example.
    I want to save drag and drop position, state of a Panel/portal after each and every drag and drop, minimize/maximize state at backend/server.

    I have seen your above mentioned code but its not working on my end.

    Any help will be greately appreciated.

    Thanks & Regards

  7. #7
    Sencha Premium Member
    Join Date
    Mar 2008
    Location
    Pune, India.
    Posts
    23
    Vote Rating
    0
    manishaNC is on a distinguished road

      0  

    Default on forum PHP code given for similar problem

    on forum PHP code given for similar problem


    At 2/3 places on forum PHP code is given for similar problem but I am not using PHP.

    I want to save at backend database panelId and position for ex: row1Col1, state for ex:minimize. How to get these things (position ,state ) using EXTJS after drag & drop and minimize or maximize.

    Any help will be greately appreciated.

    Thanks & Regards

  8. #8
    Sencha User fangzhouxing's Avatar
    Join Date
    Mar 2007
    Posts
    468
    Vote Rating
    1
    fangzhouxing is on a distinguished road

      0  

    Default


    After reading jsakalos's post in
    http://extjs.com/forum/showthread.php?t=25042

    I can now save and restore portlet position in my project.

  9. #9
    Ext User
    Join Date
    Oct 2007
    Posts
    11
    Vote Rating
    0
    Gadalon is on a distinguished road

      0  

    Default


    Quote Originally Posted by fangzhouxing View Post
    After reading jsakalos's post in
    http://extjs.com/forum/showthread.php?t=25042

    I can now save and restore portlet position in my project.
    Hello fangzhouxing,

    is it possible to post the code? Maybe there are some others in this forum (beside me) who wants to look at the code. Thanks in advance.

    Regards
    Gadalon

  10. #10
    Sencha User fangzhouxing's Avatar
    Join Date
    Mar 2007
    Posts
    468
    Vote Rating
    1
    fangzhouxing is on a distinguished road

      0  

    Default


    The code is in attached file, put it in examples dir like this:
    ...ext-2.0\examples\portal
    ...ext-2.0\examples\portal2

    Tested only in ExtJS 2.0.
    Attached Files