如何在Tapestry5中显示确认消息?

发布于 2024-08-31 17:43:16 字数 190 浏览 3 评论 0原文

我正在开发一个网站,作为我最后一年项目的一部分,我想显示一条消息来确认电子邮件已发送。

我知道如何在表单上显示自定义错误消息,即在修复以下错误之前您无法继续操作:登录名未知!

我想显示一条消息:您的电子邮件已发送!我发送电子邮件后。 有人告诉我应该通过闪光灯显示此消息。

我不确定如何做到这一点,任何帮助将不胜感激。

I am developing a website as part of my final year project and I want to display a message which confirms that an email has been sent.

I know how to display custom error messages on a form i.e. You cannot go any further until the following errors are fixed : login name not known!

I want to display a message which will say: your email has been sent! after I send an email.
I have been told that I should display this message through the flash.

I am unsure on how to do this, any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染墨丶若流云 2024-09-07 17:43:16

最简单的做法是在发送消息时显示的页面上显示条件消息,例如:

<span t:type="If" t:test="messageSent">Your message was sent.</span>

页面类片段:

@Persist(PersistenceConstants.FLASH)
private boolean messageSent;


public boolean isMessageSent() {
    return this.messageSent;
}

@OnEvent(EventConstants.SUCCESS)
void onSendMessage() {
    ...
    this.messageSent = true;
}

如果您的代码中有其他位置想要显示消息,或者如果您希望喜欢做一些奇特的 AJAX,创建一个消息组件添加到您的布局中可能是一个选择。

The simplest thing to do would be to show a conditional message on the page displayed when the message was sent, like:

<span t:type="If" t:test="messageSent">Your message was sent.</span>

Page class snippet:

@Persist(PersistenceConstants.FLASH)
private boolean messageSent;


public boolean isMessageSent() {
    return this.messageSent;
}

@OnEvent(EventConstants.SUCCESS)
void onSendMessage() {
    ...
    this.messageSent = true;
}

If you have other places in your code where you'd like to display messages, or if you'd like to do some fancy AJAX, creating a messages component to add to your layout might be an option.

宫墨修音 2024-09-07 17:43:16

从 Tapestry 5.3 开始,您可以使用警报组件。

模板:

<t:alerts />

页面类:

@Inject
private AlertManager alertManager;

@OnEvent(EventConstants.SUCCESS)
void onSendMessage() {
     ...
     this.alertManager.success("Your message was sent.");
}

Jumpstart 有一个例子。您可以在 http://jumpstart.doublemale.com.au/ 进行尝试Jumpstart7/示例/组件/警报

Since Tapestry 5.3 you can use the Alerts component.

Template:

<t:alerts />

Page class:

@Inject
private AlertManager alertManager;

@OnEvent(EventConstants.SUCCESS)
void onSendMessage() {
     ...
     this.alertManager.success("Your message was sent.");
}

Jumpstart has an example of it. You can play around with it at http://jumpstart.doublenegative.com.au/jumpstart7/examples/component/alerts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文