0

I want to invoke a method from command button. But it doesn't work and there's no anyone error's message. How is this caused and how can I solve it?

<p:commandButton value="Submit" action="#{contactMB.sendEmail()}"/>
public void sendEmail() {

    System.out.println("sendEmail method is invoked");

}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Can you [edit] to include any relevant logs in `/var/log/maillog` or the Windows equivalent? – durron597 Aug 12 '15 at 14:41
  • and don't use answers either! – Alex Aug 12 '15 at 15:01
  • @PauloHenriqueDutra Those don't appear to be mail logs, they appear to be servlet logs – durron597 Aug 12 '15 at 15:04
  • 1
    "But in Java EE doesn't work and there's no anyone error's message" - Translated: when I call it in a completely different Java application that is deployed and run in an entirely different way, nothing happens. The easiest answer is at this point is: the method is actually never called. Did you try setting a breakpoint in that method or adding some logging to see that this method is ever actually invoked? I see primefaces in the logs, so this might just be a good old problem of a button not actually invoking the backing bean action method. – Gimby Aug 12 '15 at 15:22
  • Indeed. Is the `sendEmail()` method itself called or not? If not, then this has **completely nothing** to do with sending a mail. You would have exactly the same problem when you replaced the entire method body by a single `System.out.println("Method invoked!");` line. Verify and confirm this so we can exclude a simple misinterpretation of the problem from being the cause. – BalusC Aug 12 '15 at 15:30
  • Indeed. the method sendEmail() isn't even being called. I don't understand why – Paulo Henrique Dutra Aug 12 '15 at 16:16
  • Because whatever should call it, has a problem. Its as simple as that, now you just need to figure out what it is and I can safely assume it is going to be something silly like not having a h:form or forgetting to make an action binding into a proper el with #{}. If you want help, edit your question and put in the relevant bits from the xhtml and the backing bean. – Gimby Aug 13 '15 at 09:03
  • Thanks Gimby. I remade the xhtml code and it works, but I didn't find what was the problem. I've edited my question and put the code anyway. thanks for your support. – Paulo Henrique Dutra Aug 13 '15 at 12:38

0 Answers0