PDA

View Full Version : best practice for MVC auto-creation of views with multiple profiles



jep
28 Apr 2012, 10:38 PM
I have an app with phone and tablet profiles. It has a view with a button that brings up another view. In the tablet version, this new view is simply a floating window shown next to the button. In the phone version, it is a whole screen that is switched to.

I'm trying to figure out what the best practice is for this situation. Is it to give each profile view a different xtype and then create two separate refs, one in each controller like:

phone controller:


myView:{
selector:'someViewPhone',
xtype:'someViewPhone',
autoCreate:true
},


tablet controller:


myView:{
selector:'someViewTablet',
xtype:'someViewTablet',
autoCreate:true
},


?

Then in the phone controller's click for the button:



Ext.Viewport.add(this.getMyView());
Ext.Viewport.setActiveItem(1);


and in the tablet controller:


this.getMyView().showBy(this.getMyButton());


?

Or is there some more elegant way to go about this?

mitchellsimoens
30 Apr 2012, 12:11 PM
Each profile should have it's own controller. I usually have a base controller and have the phone/tablet controllers extend it so I can reuse that base code but put the profile specific logic in the profile controllers.

jep
30 Apr 2012, 12:13 PM
Yes, mitchell, that's why I specified in my tablet that I have a phone and a tablet controller (along with the base one). My question was about what to do to create the controller-specific view. Check out my question again.

mitchellsimoens
30 Apr 2012, 12:19 PM
Checkout my reply again. If you have a base controller that can handle say a button click but what happens on that button click is profile specific, now different controllers can take over.

jep
30 Apr 2012, 12:21 PM
That's what I'm doing, mitchell. I'm not asking about the controllers so much as the VIEWS. Notice my question about having two different xtypes.

siebmanb
15 Aug 2012, 11:53 PM
I think I understand what you mean and I believe you will find your answer there : http://www.sencha.com/forum/showthread.php?179535-Beta-1-Profiles-amp-xtypes