简体   繁体   English

GWT 应用程序中的上下文相关帮助

[英]Context sensitive help in GWT application

I need to provide context sensitive help in my GWT application.我需要在我的 GWT 应用程序中提供上下文相关帮助。 For this every GWT view will have many help links each of which will open a dialog box with appropriate help text (different for each link).为此,每个 GWT 视图都会有许多帮助链接,每个链接都会打开一个带有相应帮助文本的对话框(每个链接不同)。 The problem is I cannot have so many ui:field elements each with unique name and click listener in my view classes as the number of help links may be very large.问题是我的视图类中不能有这么多 ui:field 元素,每个元素都有唯一的名称和单击侦听器,因为帮助链接的数量可能非常大。 What I need is to have many Anchor elements in my UI binder xml file and all the anchors should have the same click listener.我需要在我的 UI 活页夹 xml 文件中有许多 Anchor 元素,并且所有锚点都应该有相同的点击监听器。 The click listener will decide based on some parameter which help text to display in the dialog box.点击监听器将根据一些参数决定在对话框中显示哪些帮助文本。

I tried to use Hyperlink element with different history tokens for all links, but it changes the history which is not desirable.我尝试对所有链接使用具有不同历史标记的超链接元素,但它改变了不可取的历史。 I just want to show a dialog box with appropriate help message without modifying history.我只想在不修改历史记录的情况下显示一个带有适当帮助消息的对话框。

Is it possible in GWT? GWT 有可能吗?

Thanks for your help.谢谢你的帮助。

You can obviously use <g:Anchor href="javascript:;"> in your UiBinder and later add handler in your code.您显然可以在 UiBinder 中使用<g:Anchor href="javascript:;"> ,然后在代码中添加处理程序。

But, since you have a lot of this all around your app I'd use gwtQuery :但是,由于您的应用程序周围有很多这样的东西,我会使用gwtQuery

$(".help-link").click(new Function(){
      public void f(Element element) {
          // do something here
          // `element` tells you which element triggered the event        
});

then I'd just add css class .help-link to all relevant anchors.然后我只需将 css class .help-link添加到所有相关锚点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM