# Add binding and scripting to vision component

**URL:** <https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650>\
**Category:** Module Development\
**Tags:** vision, scripting\
**Created:** [March 18, 2021, 7:23pm UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650 "2021-03-18T19:23:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien.boissat](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@damien.boissat](https://forum.inductiveautomation.com/u/damien.boissat)\
**Post date:** [March 18, 2021, 7:23pm UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650/1 "2021-03-18T19:23:20Z")

</div>

Hello,

We have created our own modules with custom components and containers, but we can not find how to add binding and scripting (Jython code on mouseClicked event for example) to them.

We have to draw hundreds of components with very specific locations and orientations, and that’s the reason why we had to create our own modules to automate this part, but we also need these components to have bound properties to tags and custom scripts to be executed on interaction events, without having to configure them all manually.

Could you help us to figure this out? or to point us to right documentation and examples?

Thank you,

---

<div class="post-metadata">

**Author:** ![damien.boissat](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@damien.boissat](https://forum.inductiveautomation.com/u/damien.boissat)\
**Post date:** [March 22, 2021, 9:38am UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650/2 "2021-03-22T09:38:05Z")

</div>

Anyone from **inductiveautomation** could help us?

Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2021, 1:21pm UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650/3 "2021-03-22T13:21:36Z")

</div>

You don't _add_ binding to your component, but simply _support_ binding to your properties by marking them as such in your component's beaninfo. Bindings themselves are not part of a component--they are stored in a window's InteractionController.

Event script support is automatically available to all components. Extension functions can be supported by setting them up in the beaninfo. This post from last year shows all of this:

> [@Adding Data & selectedRow Properties to Custom Module](http://forum.inductiveautomation.com/t/adding-data-selectedrow-properties-to-custom-module/38223/4):
>
> I guess I can share how NoteChart does this with the Classic Chart–you’ll have to adapt for the Power Table: public class NoteChartBeanInfo extends CommonBeanInfo { public NoteChartBeanInfo() { super(NoteChart.class, new CustomizerDescriptor[] { ChartCustomizer.VALUE\_DESCRIPTOR }); getBeanDescriptor().setValue("dbl-click-customizer", ChartCustomizer.VALUE\_DESCRIPTOR.getValueName()); } @Override protected void initProperties() throws IntrospectionException { // Adds common proper…

Note that all of these features are intended to allow your users to attach functionality to your components at design-time. If you want functionality to be built-in, you should be attaching your own event listeners (in java) to your components at component creation time. You should not be populating design-time data structures.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2021, 1:41pm UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650/4 "2021-03-22T13:41:30Z")

</div>

Some implementation notes for built-in functionality:

- The designer’s mouse events, key events, and propertyChange listeners simply implement the corresponding java listeners. Your components would implement built-in functionality directly in java, and add them to the component either at creation or in the startup method.

- Property bindings you wish to implement would simply be listeners of the appropriate types for all of the relevant source data. If the source data is on a different component, add a listener defined in the destination component to listen to the source component. (In the startup method, to ensure source components have been created.)

- Tag bindings are subscriptions–TagChangeListeners. You’d add them in the startup method of the destination component.

- SQL Bindings and Tag History Bindings are runnable background tasks that your destination component would kick off when the desired conditions are met (other listeners’ data arrival, perhaps). The final step in such background tasks is to place a runnable on the foreground thread to make the final assignment to the target property.

Be sure to remove all created listeners in the shutdown method.

---

<div class="post-metadata">

**Author:** ![damien.boissat](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@damien.boissat](https://forum.inductiveautomation.com/u/damien.boissat)\
**Post date:** [March 23, 2021, 6:25am UTC](https://forum.inductiveautomation.com/t/add-binding-and-scripting-to-vision-component/44650/5 "2021-03-23T06:25:37Z")

</div>

Thank you very much @pturmel for your time and your support, very appreciated!

We will now proceed this way and hopefully we will succeed.

Best Regards,  
Damien
