title: Call a void method from JSF Page
body: <p>I am trying to implement a page where a user enters the Email address, the subject and the Message and then on send button, the message is sent together with an attachment. It seems My major Problem is calling the CommandButton to execute the Void Class Sending the Message. Here is My xhtml page:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"&gt;
      &lt;ui:composition template="./fros3.xhtml"&gt;
          &lt;ui:define name="top"&gt;
          &lt;/ui:define&gt;
          &lt;ui:define name="content"&gt;
          &lt;/ui:define&gt;
          &lt;ui:define name="bottom"&gt;
              &lt;h:form&gt;
                  &lt;p:growl id="msg" showDetail="true" sticky="true" /&gt;
                  &lt;p:panel header="Email ScreenShot" style=" width: 50%"&gt;
                      &lt;h:panelGrid columns="2"&gt;
                          &lt;h:outputLabel value="E-mail address:" styleClass="requiredLbl" /&gt;
                          &lt;p:inputText value="#{sendscreen.email}"
                                       id="username" required="true" label="username" /&gt;
                          &lt;h:outputLabel value="Subject:" styleClass="requiredLbl" /&gt;
                          &lt;p:inputText value="#{sendscreen.subject}"
                                       id="subject" required="true" /&gt;
                          &lt;h:outputLabel value="Message:" styleClass="requiredLbl" /&gt;
                          &lt;h:inputTextarea id="txt" value="#{sendscreen.message1}" required="True" style=" width: 250px; height: 100px"/&gt;
                          &lt;p:commandButton value="Send Email" ajax="false" action="#{sendscreen.sendemails()}" /&gt;
                          &lt;h:panelGroup/&gt;
                      &lt;/h:panelGrid&gt;
                  &lt;/p:panel&gt;
              &lt;/h:form&gt;
          &lt;/ui:define&gt;
      &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My Sending Class is this(Only the Mothod).</p>
  
  <pre><code>public void sendemails() {
          try {
              System.out.println("Sending ......");
              Message message = new MimeMessage(sm.getSession());
              message.setFrom(new InternetAddress(username));
              message.setRecipient(Message.RecipientType.CC, new InternetAddress(email));
              message.setSubject(Subject);
              message.setContent(message1, "text/plain");
              BodyPart messageBodyPart = new MimeBodyPart();
              messageBodyPart.setText(message1);
              Multipart multipart = new MimeMultipart();
              multipart.addBodyPart(messageBodyPart);
              message.setContent(multipart);
              MimeBodyPart attachmentBodyPart = new MimeBodyPart();
              DataSource source = new FileDataSource("C:/capture/screenShot.jpg");
              attachmentBodyPart.setDataHandler(new DataHandler(source));
              attachmentBodyPart.setFileName("screenShot.jpg");
              multipart.addBodyPart(attachmentBodyPart);
  
              Transport.send(message);
       }catch(Exception asd){
         System.out.println(asd.getMessage());
       }
  </code></pre>
  
  <p>I do not have any error showing on my logs and yet this method is not getting called. What is the Problem.</p>