本文介绍了Vaadin 12 中标签字段内的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Vaadin 12 中,我似乎无法在标签字段中创建超链接(或就此而言,任何正常"http 条目).它最终将我的命令显示为文本.这是我的代码:

final Label lblRunMs = new Label("

  1. 请现在使用在上一步中构建的 gs-DIA 方法文件运行您的质谱仪 (MS).</li><;li>当 MS 运行时,生成的 MS 文件将自动且近乎实时地导入(例如,在创建 MS 文件后约 60 秒)导入到+ Constants.MAIN_APP_NAME +"系统中./li> <li>一旦 MS 生成了一个或多个 MS 文件并将其导入"+ Constants.MAIN_APP_NAME + "系统,您就可以进行下一步,即运行" + Constants.MAIN_APP_NAME + " 这是下一个选项卡.在下一个选项卡中,您可以选择一个或多个导入的 MS 文件进行 " + Constants.MAIN_APP_NAME + " 处理.</li></ol>");添加(lblRunMs);

基于谷歌搜索,我可以看到早期版本的 Vaadin 允许您指定 ContentMode,如下所示:

Label htmlLabel = new Label("在HTML模式下,所有HTML格式标签,如\n" +"
    "+" <li><b>粗体</b></li>"+" <li>分项列表</li>"+" <li>等</li>"+"</ul>"+被保存了.",内容模式.HTML);

但该选项在 Vaadin 12 中似乎不可用.在 Vaadin 12 中满足这一需求的正确"方法是什么?

解决方案

在 V10+ 中,Label 组件映射到一个 HTML 标签,这可能是不是你想要的.在上面的示例中,使用 new Html() 会更合适.对于文本内容,SpanText 是不错的选择.

In Vaadin 12, I can't seem to create a hyperlink (or for that matter, any "normal" http entries) inside a label field. It just ends up displaying my commands as text. Here's my code:

final Label lblRunMs = new Label("<ol><li>Please now run your mass spectrometer (MS) using the gs-DIA method files built in the previous step.</li><li>While the MS is running, the generated MS files will be automatically and in near real-time imported (eg ~60 seconds after the MS files have been created) imported into the " + Constants.MAIN_APP_NAME + " system.</li> <li>Once one or more of the MS files have been generated by the MS and imported into the " + Constants.MAIN_APP_NAME + " system, you can then move on the next step, namely \"Run " + Constants.MAIN_APP_NAME + " which is the next tab. In that next tab, you can select one or more of those imported MS files to undergo the " + Constants.MAIN_APP_NAME + " processing.</li></ol>");
add(lblRunMs);

Based on googling, I can see that earlier version of Vaadin allowed you to specifying ContentMode, as in:

Label htmlLabel = new Label(
    "In HTML mode, all HTML formatting tags, such as \n" +
    "<ul>"+
    "  <li><b>bold</b></li>"+
    "  <li>itemized lists</li>"+
    "  <li>etc.</li>"+
    "</ul> "+
    "are preserved.",
    ContentMode.HTML);

but that option doesn't seem available in Vaadin 12. What's the "right" way to address this need in Vaadin 12?

解决方案

In V10+, the Label component maps to a <label> HTML tag, which is probably not what you want here. In your example above, using new Html() would be more appropriate. For text content, Span or Text are good options.

这篇关于Vaadin 12 中标签字段内的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 08:34