• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Mediator Pattern in Javascript

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is more of a question to discuss.I do not think that it will ever be asked in SCEA.
The mediator pattern [GOF] says "Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and lets you vary their interaction independently"

I was just thinking can we implement mediator pattern in javascript or DHTML(Client Side).Javascript is also an object based language and supports a lot of object oriented features.If I have a situation like I have a set of text boxes and a set of buttons and condtionally I have to enable and disable them.If I am using a fat client like SWING or even applet, it can be done, but what about javascript.Can we do it at all???

 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this discussion to "OO,Patterns, UML and Refactoring" forum...
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why dont you use a function which will enable /disable control boxes conditionally.
Like function changeLook(condType)
{
If(condType=="Y")
document.getElementById("T1").disabled=true;
else
document.getElementById("T1").disabled=false;

}

call this function from your other function
like changeLook('Y');

Thanks,
kundan
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sure thing ...we can even pass an html control reference to the function, check the type of the control and make that control enabled/disabled.

I was thinking the intent of the Mediator Pattern is "encapsulate how a set of objects interact together by promoting loose coupling by keeping the objects from directly referring or even contact each other"

Html script consitsts of html controls.So whether the interaction between the HTML controls can be encapsulated by using javascript mediation was my question.

I was thinking whether I can pass HTML event to a javascript mediator, which I think I cannot.What I think I can do is put independent javascript processing functions on HTML events.These javascript functions can do the mediation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic