The TACTIC Custom Layout Editor is a key tool for building enterprise applications in TACTIC. When building dynamic enterprise applications, dynamically loaded view or a custom widget make for a much better end user experience.
Dynamic loading can be done with the javascript api function:
spt.panel.load(element, class_name, kwargs);
However, this function requires writing a full behavior with custom javascript code. Using Javascript is necessary if some logic is required to determine what to load, but often one just needs to load a know widget with known keyword arguments. This can be very easily achieved using custom html classes. For example, to a load a view “customers.list”, one could just use the “tactic_load” class:
<div>
<input type=”button tactic_load” view=”customers.list” target=”content” value=”View Customers” />
<div class=”content”/>
</div>
This will create a button with the label “View Customers”. When clicking, it will dynamically load the view “customers.list” into the “content” element. This is a very simple way to create a dynamically loaded applications. It is very useful for creating sidebars or menu items.
Sometimes arguments need to passed to this new view. This is easily done by adding extra attributes to the html element
<input type=”button tactic_load” view=”customers.list” target=”content” search_type=”workflow/asset” value=”View Customers” />
This will add the “search_type” key with the value “workflow/asset” into the kwargs of the view “customer.list”. This is very useful for configuring the usage of a widget that is to be loaded. Even more powerful would be to make the value a variable that is determined in Python.
Similarly, the “tactic_popup” class will open up a popup with the corresponding widget. This is often used to open up edit or insert widgets or to display some additional information.
The use of these built-in classes make for a very powerful application building tool. For a concrete example, this is how the TACTIC Portal loads most of its content. Since these classes can open up any widget in TACTIC, one can create complex dynamic applications very quickly.