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

  • Home
  • SEARCH
  • 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 6041625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:41:18+00:00 2026-05-23T06:41:18+00:00

I have several widgets involved in a presentation that need to interact with each

  • 0

I have several “widgets” involved in a presentation that need to interact with each other, but the interactions have gotten complex enough to warrant a new object to handle the interactions.

In trying to work through a Mediator as that object, I am confused as how to construct the participants effectively. The mediator has to know about the widgets, and the widgets have to know about the mediator.

Using the toy classes below can someone show me how the constructors would look and in what order they would typically be created?

Cheers,
Berryl

class WidgetOne {       
    Mediator _mediator;
} 

class WidgetTwo {       
    Mediator _mediator;
} 

class Mediator {    
    WidgetOne _widgetOne;
    WidgetTwo _widgetTwo;               
}
  • 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-05-23T06:41:19+00:00Added an answer on May 23, 2026 at 6:41 am

    That really depends on a number of other circumstances, but I would probably do this:

    class Mediator {    
        WidgetOne _widgetOne;
        WidgetTwo _widgetTwo;   
    
        void setWidgetOne(WidgetOne one){_widgetOne = one;}
        void setWidgetTwo(WidgetTwo one){_widgetTwo = one;}            
    }
    
    class WidgetOne {
        Mediator me
        void WidgetOne(Mediator me){
            this.me = me
            me.setWidgetOne(this);
        }
    }
    
    class WidgetTwo {
        Mediator me
        void WidgetTwo(Mediator me){
            this.me = me
            me.setWidgetTwo(this);
        }
    }
    
    Mediator me = new Mediator();
    WidgetOne one = new WidgetOne(me);
    WidgetTwo two = new WidgetTwo(me);
    

    Of course, if nothing else needs to know about the widgets, then I would get rid of the setters and just have this:

    class Mediator {    
        WidgetOne _widgetOne;
        WidgetTwo _widgetTwo;   
    
         void Mediator(){
            _widgetOne = new WidgetOne(this);
            _widgetTwo = new WidgetTwo(this);
         }            
    }
    
    class WidgetOne {
        Mediator me
        void WidgetOne(Mediator me){
            this.me = me
        }
    }
    
    class WidgetTwo {
        Mediator me
        void WidgetTwo(Mediator me){
            this.me = me
        }
    }
    

    A couple of others in brief… brief form:

    // Factory:
    
    class Mediator {    
        WidgetOne _widgetOne;
        WidgetTwo _widgetTwo;   
    
         void Mediator(){
            _widgetOne = WidgetFactory.getW1(this);
            _widgetTwo = WidgetFactory.getW2(this);
         }            
    }
    
    class W1 {
        Mediator me
        void W1(){
        }
        void setMediator(Mediator med){me = med}
    }
    
    class WidgetFactory {
        W1 getW1(Mediator me){ W1 w = new W1(); w.setMediator(me); return me}
    }
    
    
    // Centralized "model" (variant of factory)
    class Mediator {
       W1 w1;
    
       static Mediator getInstance(){ return inst; }// See Singleton
    
       void registerW1(W1 w){w1 = w; w.setMediator(this);}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that uses several dijit form widgets. I also have an
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
We have several jobs that run concurrently that have to use the same config
I have several old 3.5in floppy disks that I would like to backup. My
I have several applications that are part of a suite of tools that various
We have several .NET applications that monitor a directory for new files, using FileSystemWatcher.
I'm getting in to a situation where I have several interacting widgets (on a
I currently have a Table [org.eclipse.swt.widgets.Table] with several TableColumns; however, due to UI space
I have a wx.Frame, in which there is a main wx.Panel with several widgets
Please help an EF n00b design his database. I have several companies that produce

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.