Customizing a button bar via java | Matt V | 2017-09-01 11:28 |
Status: Closed | ||
I'm trying to customize a button bar for my site's datasets using a java customizer. I've added that definition to each dataset's query.xml: <javaCustomizer>org.labkey.bcc.query.MyCustomizer</javaCustomizer>. The goal is to hide and/or rename some of the standard buttons. However, when I getItems() from the buttonBarConfig, the standard buttons are not returned. I can see them in the ButtonBar class when debugging the site and loading a dataset page. That is, _elementList seems to have all the standard buttons in debug, but that version of _elementList isn't what's returned in my customizer. A stripped down version of the code with some things I was trying looks like: public class MyCustomizer extends AbstractTableCustomizer { if (ti instanceof AbstractTableInfo) { AbstractTableInfo ati = (AbstractTableInfo)ti; customizeButtonBar(ati); } } private void customizeButtonBar(AbstractTableInfo ti) { ButtonBarConfig buttonBarCfg = ti.getButtonBarConfig(); buttonBarCfg.setIncludeStandardButtons(false); Set<String> hiddenStandardButtons = buttonBarCfg.getHiddenStandardButtons(); List<ButtonConfig> buttons = buttonBarCfg.getItems(); List<ButtonConfigFactory> queryButtons = LDKService.get().getQueryButtons(ti); buttonBarCfg.setItems(buttons); ti.setButtonBarConfig(buttonBarCfg); } } Due to the large number of datasets, I'm hesitant to rely on XML customizations. Any change would have to be repeated across a significant number of files. It's easier and more sustainable to add the customizer to each query when adding new datasets and then control the button configs in a single java class. Is there a way outside of the XML that I can achieve this without modifying the labkey core code? Alternatively, is there a way to use XInclude (https://www.xml.com/pub/a/2002/07/31/xinclude.html) to import the buttonbarconfig from another xml file? Tried that as well to no avail. Thanks! |
||