Hybrid View

  1. #1
    Ext User
    Join Date
    Dec 2010
    Posts
    4
    Vote Rating
    1
    jartem is on a distinguished road

      1  

    Default Problem with passing multiple parameters in url with Sencha-touch MVC routing

    Problem with passing multiple parameters in url with Sencha-touch MVC routing


    Hi,

    I stuck in a place where I need to pass several parameters in url while using Ext.Router & built-in MVC in Sencha-touch. Having initialized routing as below:
    Code:
    Ext.Router.draw(function (map) {
    map.connect(':controller/:action/:parameter');
    }
    entering url "localhost/#users/show/3" executes 'show' action in 'users' controller with "3" as passed parameter.
    works just fine, until several parameters need to be passed to an action for example "localhost/#users/search/type=3&quote=john", I would expect that 'search' action in 'users' controller would be executed with string parameter as "type=3&quote=john", but routing does not call any action if any spacial char is passed as parameter (':', '=',' &').
    I assume this is a restricted by routing, but I dont get it why.
    Other option is to register routes as following:
    Code:
    map.connect(':controller/:action/:parameter1/:parameter2/:parameter3/:parameter4');
    but I dont find it the best practice (for example when the number of parameters is dynamic)

    Could anyone explain this to me how multiple parameters should be passed to action using routing, assuming that each parameter should be recognizable by its name.

    cheers

  2. #2
    Ext User
    Join Date
    Jan 2011
    Posts
    1
    Vote Rating
    0
    szwejkc is on a distinguished road

      0  

    Default


    Sorry my friend. I don't have an answer. I really want to know the solution for this problem. Very good question!

  3. #3
    Ext JS Premium Member
    Join Date
    Oct 2010
    Posts
    80
    Vote Rating
    1
    suzzer99 is on a distinguished road

      0  

    Default


    Does anyone know why I can't find Router in either the EXT JS or Sencha Touch API docs? Very strange.

  4. #4
    Touch Premium Member
    Join Date
    Dec 2010
    Location
    Bonn, Germany
    Posts
    18
    Vote Rating
    0
    Ion Tichy is on a distinguished road

      0  

    Default


    The docs have a few small holes in them. 'Viewport' is another missing class.

  5. #5
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    21
    Vote Rating
    0
    parseroo is on a distinguished road

      0  

    Default


    I can't say what the purpose is, but probably mostly to be simpler and more integrated with the basic 'app' model they have.

    You can get the '&foo=bar' part to come through the Router into the controller by changing 'Ext.util.Route::createMatcherRegex' to allow the characters in a trailing (potentially ':rest' ) attribute and use that with a route like:
    Code:
            map.connect(':controller/:action/:rest');
    for 'localhost/#users/search/type=3&quote=john' or change the last slash to a '&' and you could use 'localhost/#users/search&type=3&quote=john' which might be a bit more standard.


    Code:
        createMatcherRegex: function(url) {
            
            var paramsInMatchString = this.paramsInMatchString,
                length = paramsInMatchString.length,
                i, cond, matcher;
            
            for (i = 0; i < length; i++) {
                cond    = this.conditions[paramsInMatchString[i]];
                if (i == length - 1) {
                    matcher = Ext.util.Format.format("({0})", cond || "[%a-zA-Z0-9\\_\\s,\\&\\=]+");
                } else {
                    matcher = Ext.util.Format.format("({0})", cond || "[%a-zA-Z0-9\\_\\s,]+");
                }
    
                url = url.replace(new RegExp(paramsInMatchString[i]), matcher);
            }
    
            
            return new RegExp("^" + url + "$");
        }

  6. #6
    Ext User
    Join Date
    Dec 2010
    Posts
    4
    Vote Rating
    1
    jartem is on a distinguished road

      0  

    Default


    thanks a million, that helps a lot,

Similar Threads

  1. Sencha Touch + MVC?
    By Bucs in forum Sencha Touch 1.x: Discussion
    Replies: 16
    Last Post: 2 Jul 2011, 12:19 PM
  2. Using Sencha Touch with ASP .Net MVC
    By atulbahl in forum Sencha Touch 1.x: Discussion
    Replies: 8
    Last Post: 24 Mar 2011, 12:33 PM
  3. Sencha Touch's MVC
    By Steffen Hiller in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 27 Nov 2010, 8:24 PM
  4. Sencha Touch MVC
    By crysfel in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 25 Nov 2010, 12:36 AM
  5. change store URL or passing parameters
    By Brendan in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 28 Jan 2009, 6:04 PM

Thread Participants: 7

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar