how to add/remove folder from folder panel

Hello,
I am new to Cuba and have a problem with the folders panel.How do i remove a folder or add one?

Like the library project(is the one of the sample projects).I added a button inside Books.Browse to make add/delete.I can reach out to folders with the code below


FoldersService service = AppBeans.get(FoldersService.NAME);
List<AppFolder> list = service.loadAppFolders();

But that’s all.Modifying list is not affecting the folders panel.

Hi,

You should add/remove AppFolder entities (via DataManager for example), and then invoke the loadFolders() method of the FoldersPane component which is available on the extended main window.

1 Like

Thank you for the quick reply sir.Now I have 2 new questions related to it.
How can i create a new AppFolder object?
Changes on the folders panel is not instant.To be able to see the changes, i need to close the application and reopen it from the studio.How can i make it instant?

Please see an example project here: GitHub - cuba-labs/add-app-folder: Adding an App Folder programmatically

The code adding a folder:

public class CustomerBrowse extends AbstractLookup {

    @Inject
    private Metadata metadata;
    @Inject
    private DataManager dataManager;


    public void onAddFolderClick() {
        AppFolder appFolder = metadata.create(AppFolder.class);
        appFolder.setName("My customers");
        appFolder.setFilterComponentId("&#91;sample$Customer.browse&#93;.filter");
        appFolder.setTabName("My customers");
        appFolder.setFilterXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<filter>\n" +
                "  <and>\n" +
                "    <c name=\"name\" class=\"java.lang.String\" operatorType=\"CONTAINS\" width=\"1\" type=\"PROPERTY\"><!&#91;CDATA&#91;e.name like :component$filter.name63023 ESCAPE '\\' &#93;&#93;>\n" +
                "      <param name=\"component$filter.name63023\" javaClass=\"java.lang.String\">NULL</param>\n" +
                "    </c>\n" +
                "  </and>\n" +
                "</filter>");
        dataManager.commit(appFolder);
        showNotification("AppFolder has been added. Re-login to see it.");
    }
}

Unfortunately, there is no API to refresh the list of folders, so the user will see the new folder only after logout and login again. We’ll add required methods to the FoldersPane component in 6.6.0, then I will update the example. See the linked issue for tracking the progress.

1 Like

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-9383