1

I have a very strange issue with one of my forms.

I have a form that registers a user and sends him/her an email. Wanted to replace my old captcha with the new primefaces one. Everything was going fine, but when i click on the submit button(and the captcha is correctly entered), the data is saved in the database, the email is sent, but i dont get redirected to the destination page. Ill show you just a bit of code so you know what i am talking about:

This is the component i just added inside my form

<p:captcha label="Captcha" language="en" theme="white" publicKey="6Ld7pMESAAAAAHd1VihJkqPUXAJVwU3Cghc8fzrq"/> 
            <h:commandButton value="Registruj"
                    actionListener="#{registrationControllerBuyer.doRegisterBuyer}"/>

also i added a couple of configurations at the web.xml:

<!-- keys gotten from recaptcha -->
<context-param>
    <param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
    <param-value>6Ld7pMESAAAAAHd1VihJkqPUXAJVwU3Cghc8fzrq</param-value>
</context-param>

<context-param>
    <param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
    <param-value>6Ld7pMESAAAAAMhr5WSk5bcRrff8Y08NtDi8Buoq</param-value>
</context-param>

And this is the bit of java for the button handler:

public String doRegisterBuyer() throws Exception {
    Buyer buyer = new Buyer();
    buyer.setName(getName());
    buyer.setSecondName(getSecondName());
    buyer.setNickName("not specified");
    buyer.setEmail(getEmail());
    buyer.setPassword(getPassword());
    buyer.setAcceptedTermsAndConditions(isAcceptedTermsAndConditions());
    buyer.setNewsletterSubscription(isNewsletterSubscription());
    buyer.setAccountStatus(AccountStattus.CREATED.toString());      

    Buyer tmpBuyer = tmpBuyer = buyersRegistratorEJB.createBuyer(buyer);

    // Send activation link to user
    emailServiceEJB.sendAccountActivationLinkToBuyer(tmpBuyer.getEmail()
            .trim(), tmpBuyer.getName());
    return "registrationSucceded.xhtml";
}

The captcha seems to work perfectly: -If i give wrong input to the captcha the method doRegisteredBuyer() don't gets executed -If i get right input to the captcha the method doRegisteredBuyer() does get executed BUT i dont get redirected to registrationSucceded.xhtml

Why is that(the name of the page is correct, already checked that a few times :) )?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
javing
  • 12,307
  • 35
  • 138
  • 211
  • Please note that I edited my answer because I totally misread the code snippet. I saw a `` where you actually posted ``. It's Friday... – BalusC Apr 08 '11 at 16:34
  • :) i did read it. It is ok now. It works now. i get an error but this is not related to the captcha hehe..: java.lang.RuntimeException: com.sun.mail.smtp.SMTPSendFailedException: 550 5.4.5 Daily sending quota exceeded. z18sm1730598bkf.20 You are right it is Friday, i think i finish my working for today. Thanks have a nice day. – javing Apr 08 '11 at 16:39

1 Answers1

2

You need action, not actionListener.

<h:commandButton value="Registruj" action="#{registrationControllerBuyer.doRegisterBuyer}"/>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555