Skip to main content
xchen.1480
Associate II
December 12, 2019
Question

How container can call the methods in Model ?

  • December 12, 2019
  • 1 reply
  • 751 views

Hi,

​

I have a question when trying to change screen by click different buttons.

​

There are 5 buttons on Screen 1, and Screen 2 have 5 similar but different styles.

When Screen 1 - Button 1 was clicked, goto Screen 2 and showed in style 1.

​

My mind to do this is define a variable member in Model, and set the value by Screen1View->Screen1Presenter->Model->setValue, and then in setupScreen of Screen 2 to get value by Screen2View->Screen2Presenter->Model->getValue, and then initialize the style.

​

It worked OK!

​

But the buttons in Screen 1 is to simple, I want to add some other elements (text, icon, background, ...) to button. So I used user container.

The container includes all elements I want, and a button with tranparent image on the top level.

Set a button clicked callback method, in which, set the value in model.

​

The problem is that model mothods can only called by presenter, and presenter can only accessed by viewer. So I can't set the style value in container method.

​

Any one have suggestion for my question? Or is my mind wrong, and have any better to do it?

Thanks!

This topic has been closed for replies.

1 reply

Martin KJELDSEN
Principal III
December 12, 2019

Either use callbacks in your container so that they are portable (use in multiple views) or just configure the container with a pointer to the View that you can call methods on.

/Martin