Support deep links to open entity directly in CUBA app

CUBA has a feature to add entities to favorites. I think it would be a good idea if entities could be opened directly via a deep link in the CUBA app.

E.g. there could be a new standard action “Get Entitiy Link” or “Send Entity Link” to generate a deep link. So these links can be saved in browser favorites or send to others. I think the deep link just needs the classname and id value as parameter.

Hi Stefan,

in fact this feature is already there. I wrote a blog post about a while ago: Deep Links for Resources – Road to CUBA and beyond...

It is just a little bit hidden.

Bye
Mario

2 Likes

Great write up mario, but I also like the idea of a standard action in Studio for this.

1 Like

For some reason I wasn’t able to get this to work exactly as written in the blog.
Likely because:

  • I wasn’t using groovy
  • I use Integer Identity rather than UUID for my entities (SQL Server, So I want a clustered primary key)

I was able to get this to work on the screen controller itself however:

package com.company.tts.web.account;

import com.company.tts.entity.Account;
import com.haulmont.cuba.core.global.GlobalConfig;
import com.haulmont.cuba.gui.components.AbstractLookup;
import com.haulmont.cuba.gui.data.Datasource;
import javax.inject.Inject;

public class AccountBrowse extends AbstractLookup {

    @Inject
    private Datasource<Account> accountsDs;

    @Inject
    private GlobalConfig globalConfig;

    public void showDeepLink() {

        Account account = accountsDs.getItem();
        String title = "Direct Link to Account: "+accountsDs.getItem().getAccountName();
        String webAppUrl = globalConfig.getWebAppUrl();
        String className = account.getMetaClass().getName();
        String screen = className+".edit";
        String item = className+"-"+(accountsDs.getItem().getId());
        String deepLink = webAppUrl+"/open?screen="+screen+"&item="+item;

        showMessageDialog(title, deepLink, MessageType.CONFIRMATION);
    }
}

image

Your blog definitely pointed me in the right direction. So I wanted to say thanks!

We are working on supporting URLs that will represent current app state. It also includes open entitiy editors and enables to copy-paste a link to current entity: URL browser history and navigation #280.

Regards,
Daniil.

1 Like

Hello,

Can you help?

How can I get a deep link for a screen like MasterDetailScreen?

Hi,

This feature has been implemented as a Routing API.
Take a look at this documentation section : URL History and Navigation - CUBA Platform. Developer’s Manual

1 Like