View Full Version : Causing specialized behavior in instances of general components
02-15-2012, 05:21 PM
Sorry if that title's confusing, it was as concise as I could think.
I have this component that is used in a few places. Sometimes, when a button on that component is pushed, it needs to validate something from what owns the instance of that component, but not always. (Is that the Visitor design pattern?) I know how I'd do this in MFC or any other C++ environment, but I'm very new to Flex. What's the best way to go about this?
02-15-2012, 09:42 PM
Can you be more specific about the actual problem or use-case you are trying to solve?
If I understand you correctly, you have a component that sometimes must check on its parent to function correctly. If this is correct, I would probably suggest a different approach all together. As a rule of thumb, components should never really have any knowledge of their parent or sibling components.
Its difficult to give advise on architecture without knowing more about what challenge you are trying to overcome, and how it will be integrated into your application as a whole.
02-16-2012, 01:27 PM
Certainly. I have a component called <my:component> that derives from a <mx:Canvas>. It has 2 listboxes and 3 buttons. Now in one place where <my:component> is used, some validation needs to occur when one of those buttons is pressed. If invalid, it should show an error message and otherwise behave as though the button was never pressed.
I'm hoping that a fundamental rewrite of the component is not necessary, because I didn't write it, and I'll almost certainly break something. So far, all the bugfixes I've done resulted in commits to the repo w/enough lines changed to count on both hands.
vBulletin® v3.8.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.