The Deep-Link feature is available on release/6.0.x branch and works like this:
You can pass an URL parameter "dl" to the Scout servlet. The "dl"-parameter contains a string in this format: [handler name]-[data]. Example: form-123456.
For each deep-link pattern you want to process in your Scout application, you have to register a deep-link handler which implements IDeepLinkHandler and typically inherits from AbstractDeepLinkHandler. In the constructor you specify a regular expression that matches your deep-link pattern, and extracts the data as a regex-group. In the handleImpl method you implement whatever the deep-link should do in the Scout model. The deep-link handler will be automatically registered as a (Scout) Bean.
Here's some example code to open a Scout form with a deep-link:
public class FormDeepLinkHandler extends AbstractDeepLinkHandler {
private static final String HANDLER_NAME = "form";
public FormDeepLinkHandler() {
super(defaultPattern(HANDLER_NAME, "\\d+"));
}
@Override
public void handleImpl(Matcher matcher) throws DeepLinkException {
String formId = matcher.group(1);
IForm form = getFormById(formId);
form.start();
}
private IForm getFormById(String formId) throws DeepLinkException {
if ("300".equals(formId)) {
return new ScoutInfoForm();
}
// throw a DeepLinkException when resource requested by deep-link does not exist
throw new DeepLinkException("Form not found");
}
public BrowserHistoryEntry createBrowserHistoryEntry(IForm form) {
return DeepLinkUriBuilder.createRelative()
.parameterInfo(form.getTitle())
.parameterPath(toDeepLinkPath(getFormId(form)))
.createBrowserHistoryEntry();
}
private String getFormId(IForm form) {
// TODO: return an ID for different forms, or you could use form.getFormId();
return "300";
}
@Override
public String getName() {
return HANDLER_NAME;
}
}
The optional createBrowserHistoryEntry(IForm) creates an entry to be used in the browser history, which means it will change the URL in the address bar of your browser. It also enables the possibility to use the history back/forward buttons in a Scout application. For that you could do this in your form:
@Override
protected void execInitForm() {
BrowserHistoryEntry entry = BEANS.get(FormDeepLinkHandler.class).createBrowserHistoryEntry(this);
ClientSessionProvider.currentSession().getDesktop().setBrowserHistoryEntry(entry);
}
With that you can finally start your form by opening the URL:
http://foo.com/?dl=form-300&i=Title-of-the-form
Note: the "i" parameter is completely optional. You can use it to make the URL more readable for humans or as a hint for search crawlers.