cancel
Showing results for 
Search instead for 
Did you mean: 

How can I access the model from a custom container

egoltzman
Senior

Hi, I have a common custom container that is included in all my views.

I need to access a method from the model, usually, in a view, I do this from the presenter, how can I do this in the custom container in a general way without passing the view to the custom container?

Thanks,

Eyal

13 REPLIES 13
Martin KJELDSEN
Chief III

Hi Eyal!

Are you reluctant to pass the view because you don't know the type? You could have those views that need this custom container to inherit from a base view with the functionality to interact with the model. Or, you could use generic callbacks depending on what you're looking to do.

/Martin

egoltzman
Senior

Hi Martin,

Thanks for getting back to me.

The case is this, I have a common custom container that is included (from with in the designer) in all my views (more then 40) and I want to access the model from within the custom container.

If I need to pass the view to the customer container then I need to go to each view setup and call a customer container method that take the view, I want to avoid this if possible.

Thanks!

Eyal

Martin KJELDSEN
Chief III

If every view needs this custom container, create a Base View that declares this container and adds it to the root view container and then have every view inherit from it.

/Martin

egoltzman
Senior

I'm not sure I follow your idea, I have a designer project with existing 40 screens\view, now, on top of that, the need is raised to add a custom container to all those views.

How can I make a base view in that scenario and make all the existing screen inherit from it?

Martin KJELDSEN
Chief III

Hi Eyal,

The idea is to only declare the Custom Container member in a baseview that is shared by all - This feature is not supported by the designer, so you will have to edit all your screens and new screens that you create. I will see if i can take the time to create an example for you.

/Martin

Hi Martin,

I'm having the same issues as Eyal did and it would be really helpful if you could create an example for an small application.

Basically a application in which a designer generated view inherits from a custom base view. I'm aware that for this a modification by hand will be necessary.

Thanks

Michael

sasha
Associate III

Hello, I am also trying to acheive the same thing and would really appreciate an example of how to modify the generated files to achieve this!

Hi,

Same, i would really appreciate an example of how to implement this.

Thanks,

Dani

LRaim.2
Associate II

I've added an answer to a similar (kind of...) problem in this post https://community.st.com/s/question/0D50X0000AFpwBx/can-you-call-a-method-on-view-from-a-custom-container.

Hope it helps