Migrating ActionButtons to not use deprecated constructor for 12.2

LabKey Support Forum (Inactive)
Migrating ActionButtons to not use deprecated constructor for 12.2 Karl Lum  2012-06-28 12:17
Status: Closed
 
Hi Scott,

For your examples I would probably use the variant of constructor that takes an ActionURL class : ActionButton(ActionURL, String). That way you can pass in an ActionURL that contains your action class plus any optional parameters. The ActionURL is usually constructed from a controller action class and Container. If your controller actions are not visible from your implementing class, let me know and I can show you ways to expose them.

So for example, you could possibly refactor the getButtonBar class like this:


        ActionURL insertUrl = new ActionURL(InsertToStudyAction.class, getContainer());
        ActionURL actionUrl = new ActionURL(InsertToBatchAction.class, getContainer()).addParameter("labstudyseqId", "+queryValue");

        ...

        protected ButtonBar getButtonBar(ActionURL insertURL, ActionURL action)
        {
            ButtonBar bb = new ButtonBar();

            ActionButton insertButton = new ActionButton(ActionButton.BUTTON_DO_INSERT);
            insertButton.setURL(insertURL);
            insertButton.setCaption("Insert a Row");
            bb.add(insertButton);
            ActionButton viewButton = new ActionButton(action,"View Data");
            bb.add(viewButton);

            ActionButton goBack = new ActionButton(new ActionURL(BeginAction.class, getContainer()), "Go Back");
            ActionURL backURL = new ActionURL(EliSpotModule.NAME,VIEW_BEGIN, getContainer());
            goBack.setURL(backURL.getLocalURIString());
            bb.add(goBack);
            return bb;
        }


- Karl