1

I am developing a mobile application with sencha extjs. I want my application to support back button on android phone, then I figure out using sencha route can solve on this matter. I have many views to use route and some views are relevant to each other. Therefore, some view controllers need parameters. For example, to view a View, in view I have view listeners for view actions.

viewA : function(obj1, obj2){
     //obj1, obj2 are required to open that view
     this.redirectTo('myViewA', ture);
}

In route controller

routes: {
    'myViewA' : {
        action: 'onMyViewA'    //method onMyViewA to view viewA 
     }
},
{
    onMyViewA : function(){
       //view viewA need parameter obj1, obj2
    }
}

My question is that, how can I pass parameter obj1, obj2 to route controller? or any solutions else to solve this. Thanks.

Phon Soyang
  • 1,303
  • 2
  • 9
  • 17

2 Answers2

0

When you register your routes you can add parameters like this:

routes: {
    'myViewA/:id1/:id2' : {
        action: 'onMyViewA'    //method onMyViewA to view viewA 
     }
},
{
    onMyViewA : function(id1, id2){
    }
}

And in your view add the parameter to the route like this:

viewA : function(id1, id2){
     if (id1 && id2)
        this.redirectTo('myViewA/' + id1 + '/' + id2, true);
}

Check the documentation for routes on this link for more info. You can also have validation of the parameters.

If your obj1 and obj2 are complex objects you need to write some custom logic that stores those objects somewhere and puts only id or some kind of reference to url of the route.

Bojan Dević
  • 1,875
  • 14
  • 24
0

You can pass parameter with help of & symbol.For ex. you can pass data as below www.any.com/any/#param1&value1&param2&value2. Then you can seperate out these tokens with respective key-value pair. But you cant pass object through url.

Tejas
  • 894
  • 7
  • 24