JSF中的确认链接电子邮件 [英] Confirmation link Email in JSF

查看:177
本文介绍了JSF中的确认链接电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何创建一个链接,您可以将该链接发送给用户,以确认在JSF中单击了他们的电子邮件地址?即,一旦他们点击链接,他们的帐户就会被激活.

How do you make a link which you can email to users to confirm their email address is clicked in JSF? i.e. once they click on the link their account will be activated.

推荐答案

假设您已经在使用JSF 2.0,则可以使用@ManagedProperty@PostConstruct.

Assuming you're already on JSF 2.0, you could grab @ManagedProperty and @PostConstruct.

@ManagedBean
@RequestScoped
public class Activation {

    @ManagedProperty(value="#{param.key}")
    private String key;
    private boolean valid;

    @PostConstruct
    public void init() {
        valid = check(key); // And auto-login if valid?
    }

    // ...
}

,然后在 http://example.com/activate.jsf访问的JSF中? key = somelonggenickey

<h:panelGroup layout="block" rendered="#{activation.valid}">
   <p>Your account is successfully activated!</p>
   <p><h:link outcome="home">Go to home page</h:link></p>
</h:panelGroup>
<h:panelGroup layout="block" rendered="#{!activation.valid}">
   <p>Activation failed! Please enter your email address to try once again.</p> 
   <h:form>
       ...
   </h:form>
</h:panelGroup>

这篇关于JSF中的确认链接电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆