不同页面的 Scout Eclipse Neon url
Scout Eclipse Neon different url for for different pages
我想知道在Scout 中是否有办法在不同的链接上制作不同的表格。现在所有的表格都在相同的 url 链接上打开。
例如,如果应用程序在 http://localhost:1808/ that after opening person form, this form open in link http://localhost:1808/person?id=300 上运行。
有办法吗?
您要找的关键词是"Deep-Links"。恐怕我们没有很多关于它的文档,因为该功能仍在开发中。第一个版本添加了 Neon.M6.
目标是能够跳转到应用程序中具有特定 URL 的某个地方。
此功能还可以使用 Web 浏览器中的 Back/Forward 按钮(有一些限制)。
我们的 Widgets 演示应用程序中有一个实施示例:
http://<URL to the APP>/?deeplink=widget-svgfield
注意:参数的名称将来可能会从 dl
和 i
而不是 deeplink
和 info
。
Deep-Link 功能在 release/6.0.x 分支上可用,其工作方式如下:
您可以将 URL 参数 "dl" 传递给 Scout servlet。 "dl" 参数包含以下格式的字符串:[处理程序名称]-[数据]。示例:form-123456.
对于您要在 Scout 应用程序中处理的每个 deep-link 模式,您必须注册一个 deep-link 处理程序,该处理程序实现 IDeepLinkHandler 并且通常继承自AbstractDeepLink处理程序。在构造函数中,您指定一个匹配 deep-link 模式的正则表达式,并将数据提取为正则表达式组。在 handleImpl 方法中,您可以实现 deep-link 在 Scout 模型中应该做的任何事情。 deep-link 处理程序将自动注册为 (Scout) Bean。
下面是一些示例代码,用于打开带有深度 link 的 Scout 表单:
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;
}
}
可选的 createBrowserHistoryEntry(IForm) 创建一个在浏览器历史记录中使用的条目,这意味着它将更改浏览器地址栏中的 URL。它还允许在 Scout 应用程序中使用历史记录 back/forward 按钮。为此,您可以在您的表单中执行此操作:
@Override
protected void execInitForm() {
BrowserHistoryEntry entry = BEANS.get(FormDeepLinkHandler.class).createBrowserHistoryEntry(this);
ClientSessionProvider.currentSession().getDesktop().setBrowserHistoryEntry(entry);
}
有了它,您终于可以通过打开 URL:
来开始您的表单了
http://foo.com/?dl=form-300&i=Title-of-the-form
注意:"i" 参数是完全可选的。您可以使用它来提高 URL 对人类的可读性或作为搜索爬虫的提示。
我想知道在Scout 中是否有办法在不同的链接上制作不同的表格。现在所有的表格都在相同的 url 链接上打开。 例如,如果应用程序在 http://localhost:1808/ that after opening person form, this form open in link http://localhost:1808/person?id=300 上运行。
有办法吗?
您要找的关键词是"Deep-Links"。恐怕我们没有很多关于它的文档,因为该功能仍在开发中。第一个版本添加了 Neon.M6.
目标是能够跳转到应用程序中具有特定 URL 的某个地方。
此功能还可以使用 Web 浏览器中的 Back/Forward 按钮(有一些限制)。
我们的 Widgets 演示应用程序中有一个实施示例:
http://<URL to the APP>/?deeplink=widget-svgfield
注意:参数的名称将来可能会从 dl
和 i
而不是 deeplink
和 info
。
Deep-Link 功能在 release/6.0.x 分支上可用,其工作方式如下:
您可以将 URL 参数 "dl" 传递给 Scout servlet。 "dl" 参数包含以下格式的字符串:[处理程序名称]-[数据]。示例:form-123456.
对于您要在 Scout 应用程序中处理的每个 deep-link 模式,您必须注册一个 deep-link 处理程序,该处理程序实现 IDeepLinkHandler 并且通常继承自AbstractDeepLink处理程序。在构造函数中,您指定一个匹配 deep-link 模式的正则表达式,并将数据提取为正则表达式组。在 handleImpl 方法中,您可以实现 deep-link 在 Scout 模型中应该做的任何事情。 deep-link 处理程序将自动注册为 (Scout) Bean。
下面是一些示例代码,用于打开带有深度 link 的 Scout 表单:
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;
}
}
可选的 createBrowserHistoryEntry(IForm) 创建一个在浏览器历史记录中使用的条目,这意味着它将更改浏览器地址栏中的 URL。它还允许在 Scout 应用程序中使用历史记录 back/forward 按钮。为此,您可以在您的表单中执行此操作:
@Override
protected void execInitForm() {
BrowserHistoryEntry entry = BEANS.get(FormDeepLinkHandler.class).createBrowserHistoryEntry(this);
ClientSessionProvider.currentSession().getDesktop().setBrowserHistoryEntry(entry);
}
有了它,您终于可以通过打开 URL:
来开始您的表单了
http://foo.com/?dl=form-300&i=Title-of-the-form
注意:"i" 参数是完全可选的。您可以使用它来提高 URL 对人类的可读性或作为搜索爬虫的提示。