SEAM无状态bean未更新



我试图在我们的索引页中使用JSF SEAM实现'忘记密码'功能,我使用a4j:jsFunction通过两个's向用户发送电子邮件和卡号

当我只是发送电子邮件(作为字符串)时,它似乎工作得很好,但是当我添加卡号(int)时,它抛出了以下内容…

原因:javax.el.PropertyNotFoundException:/index.xhtml @256,138 assignTo="#{forgotPasswordActions. #:类"org.javassist.tmp.java.lang"。Object_$$_javassistrongeam_5'没有属性'cardnumber'。

后台bean是这样的…

@Stateless
@Name("forgotPasswordActions")
public class ForgotPasswordActionsBean implements ForgotPasswordActions, Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    @Logger private Log log;
    @In private EmailService emailService;
    @In private UserDAO userDAO;
    @In private MessagePoster messagePoster;
    @In private Map<String, String> messages;
    private User user;
    private String address;
    private String email;
    private int cardnumber;
    @Override
    public void resetPassword(){
        new RunAsOperation(true) {
            public void execute() {
                if(StringUtils.isNotEmpty(email)){
                    user = userDAO.findByEmail(email);
                }
                else{
                    messagePoster.postPopupInfoMessage(messages.get("inputEmpty"));
                }
                if(user!=null && cardnumber == user.getCardId()){
                    String newPassword = generateRandomPassword();
                    log.debug("updating password...");
                    user.setPassword(newPassword);
                    user = userDAO.makePersistent(user);
                    address = user.getEmail();
                    log.debug("password changed to: "+newPassword);
                    Map<String, Object> emailInfo = new HashMap<String, Object>();
                    emailInfo.put("name", user.getFirstname());
                    emailInfo.put("newPassword", newPassword);
                    emailService.sendToAddress(Email.user_password_reset, address, emailInfo);
                    messagePoster.postPopupInfoMessage(messages.get("pwReset")+" "+user.getEmail());
                }
                else{
                    messagePoster.postPopupInfoMessage(messages.get("resetFailed"));
                }
            }
        }.run();
    }
    //---------------------- Setters
    @Override
    public void setEmail(String email) {
        this.email = email;
    }
    @Override
    public void setCardno(int cardnumber) {
        this.cardnumber = cardnumber;
    }
}

和JSF/HTML

    <div id="forgotPasswordDialog" title="Forgot Password">
        <div class="textBox">
            <input id="emailLookupval" type="text" />
            <input id="cardNoval" type="text" />
            <button onclick="resetPassword(jQuery('#emailLookupval').val(),jQuery('#cardNoval').val())" type="button">Reset</button>
            <a4j:form id="forgotPassword">
                <a4j:jsFunction name="resetPassword" 
                        action="#{forgotPasswordActions.resetPassword}"
                        oncomplete="jQuery('#forgotPasswordDialog').dialog('open')">
                    <a4j:actionparam name="userEmail" assignTo="#{forgotPasswordActions.email}"  />
                    <a4j:actionparam name="userCardno" assignTo="#{forgotPasswordActions.cardnumber}" />
                </a4j:jsFunction>
            </a4j:form>
        </div>
    </div>

我不知道为什么它不设置这个bean属性??任何帮助,感谢!

您的setter被称为setCardno(),而setCardnumber()是视图所期望的。#{bean.property}与bean中的属性名无关。它与getter/setter方法名有关。有两种方法可以解决这个问题:

  • 重命名setter方法:

    public void setCardnumber(int cardnumber) {
        this.cardnumber = cardnumber;
    }
    
  • 或者,重命名view属性:

    assignTo="#{forgotPasswordActions.cardno}"
    

相关内容

  • 没有找到相关文章

最新更新