Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:42:40+00:00 2026-06-03T21:42:40+00:00

MVP pattern assumes that View expose methods to Presenter. For example in View we

  • 0

MVP pattern assumes that View expose methods to Presenter. For example in View we can write:

public HasClickhandlers getButton() {
    return myBtn;
} 

and access to this method from presenter, like

view.getButton().addclickhanlder() ...

But when I build my app in this style, I have a lot unnecessary code. For example I want to create TablesView and TablesPresenter (I decide thatTablesPresenter and TablesView is minimal entity (minimal module), that can not be divided into more small presenters and views, and can not be more complex). Then, when I create TablesView, I want to put inside this view another custom component – MyCustomTable. And Inside MyCustomTable put MyCustomHeader, inside MyCustomHeader put MyCustomFilter and so on (this sequence may be much longer)…
So problem is when I want to access from Presenter to entered text(by user) inside MyCustomFilter, I need to expose method on MyCustomFilter:

//inside MyCustomFilter
public String getFilterText() {
   return textBox.getText();
}

then in widget that contains MyCustomFilter – i.e. in MyCustomHeader I need to expose this method:

//inside MyCustomHeader
public String getFilterText() {
  return myCustomFilter.getFilterText();
}

after it, inside MyCustomTable I need to expose this method:

//inside MyCustomTable
public String getFilterText() {
  return myCustomHeader.getFilterText();
}

After it I need to expose getFilterText() method inside TablesView (that contains MyCustomTable) and after all this operations my presenter can access to text inside MyCustomFilter.. And sometime this sequence is more longer.
So how to solve this problem? May be I not understand some things about MVP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:42:41+00:00Added an answer on June 3, 2026 at 9:42 pm

    One way to solve it would be the use of interfaces. By that you could expose a view of your components without creating a tight coupling between the view and the presenter.

    Something along these lines:

    public interface CustomFilter {
       String getFilterText();
       // other methods that might be accessed from your presenter
    }
    
    public class MyCustomFilter implements CustomFilter {
    
        @Override
        public String getFilterText() {
            return textBox.getText();
        }
    }
    

    You can do the same thing for the other componenents:

    CustomHeader:

    public interface CustomHeader {
       CustomFilter getFilter();
       // or String getFilterText()
       // other methods that might be accessed from your presenter
    }
    
    public class MyCustomHeader implements CustomHeader {
    
        @Override
        public CustomFilter getFilter() {
            return myCustomFilter;
        }
    }
    

    CustomTable:

    public interface CustomTable {
       CustomHeader getHeader();
       // or Sring getFilterText();
       // other methods that might be accessed from your presenter
    }
    
    public class MyCustomTable implements CustomTable {
    
        @Override
        public CustomHeader getHeader() {
            return myCustomHeader;
        }
    }
    

    You can decide if you only want to expose in each interface just a String or the entire client component’s interface. If you expose the entire interface you might violate the law of demeter by having calls like this in your presenter:

    getView().getTable().getHeader().getFilter().getFilterText(). 
    

    Probably a better solution would be to define Strings in your interfaces which delegate the calls up the hierarchy to the your CustomFilter interface: getView().getTable().getFilterText(); or even getView().getFilterText().

    The other benefits of using interfaces is that you can easily mock them for Unit testing your presenters and even view components in isolation and you can easily create an switch between different implementations of your UI components (for example one that is optimized for smartphones, etc) without changing anything in your Presenters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MVP pattern, a Presenter has an interface of View so the presenter can
I got a view (GWT MVP pattern) that contains a listbox. I created a
in a classic Passive-MVP pattern, how can i avoid a reference of the presenter
I'm using MVP pattern, so I have a View that has almost no logic
Can you advise if it is a violation of MVP pattern if the presenter
Suppose I'm implementing an MVP pattern and I have a view interface as such:
In project I use MVP pattern. I have 2 view and 2 corresponding presenters.
In MVP pattern the widget (the view) exposes its widgets in form like this:
Using GWT with the MVP pattern , I'd like to have a place that
Can somebody point me to a good tutorial or sample project where MVP pattern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.