Hi.

Recently, I reported a JIRA concerning the texture passthrough element not 
working.  It was fixed in 2.2.8.  Thank you.

Now that the page can render, I’ve been testing 2.2.8-SNAPSHOT to see if I can 
now pass the value of the textarea passthrough element to my CDI-managed bean’s 
field.

However, the value is never set.

Can someone please help me figure out why?

I’m using TomEE 1.7.0 with the provided JSF 2.1 replaced by MyFaces 
2.2.8-SNAPSHOT, CDI, and EJB.  I’m using PrimeFaces and PrimeFaces Mobile, 
which are enabled in my web.xml and actively used in my production pages, 
however not for the following test facelet.

Here’s the facelet:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:f="http://xmlns.jcp.org/jsf/core";
      xmlns:h="http://xmlns.jcp.org/jsf/html";
      xmlns:pt="http://xmlns.jcp.org/jsf/passthrough";
      xmlns:jsf="http://xmlns.jcp.org/jsf";>
    <head jsf:id="head">
        <title>Email Test</title>
    </head>
    <body jsf:id="body">
        <form jsf:id="form">
            <input type="text" jsf:id="name"
                   placeholder="Enter name"
                   jsf:value="#{contactUs.fromName}"/>
            <br/>
            <br/>
            <input type="text" jsf:id="email-address"
                   placeholder="Enter email address"
                   jsf:value="#{contactUs.fromEmail}"/>
            <br/>
            <br/>
            <textarea jsf:id="contact-message"
                      name="comments"
                      placeholder="I wanna talk about..."
                      jsf:value="#{contactUs.message}"/>
            <br/>
            <br/>
            <button type="submit" jsf:action="#{contactUs.submit}">Send 
Email</button>
        </form>
    </body>
</html>



Here’s the CDI bean:

import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Chris Harris
 */
@Named
@RequestScoped
public class ContactUs implements Serializable {
    private static final long serialVersionUID = -8534566463384466624L;

    private String fromName, fromEmail, message;

    private @Inject MailService contactService;

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }
    public String getFromName() {
        return this.fromName;
    }
    public void setFromEmail(String fromEmail) {
        this.fromEmail = fromEmail;
    }
    public String getFromEmail() {
        return this.fromEmail;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public String getMessage() {
        return this.message;
    }

    public void submit() {
        StringBuilder bs = new StringBuilder();
        bs.append(fromName).append(" wrote...\n\n").append(message);
        contactService.sendMail(fromEmail, "Email message from blah.com", 
bs.toString());
    }
}




Here’s the EJB:

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 *
 * @author Chris Harris
 */
@Stateless
public class MailService {
    @Resource(name = "mail/Default")
    private Session mailSession;

    public void sendMail(String fromEmail, String subject, String body) {
try {
            MimeMessage msg = new MimeMessage(mailSession);
            Address fromAddress = new InternetAddress(fromEmail);
            msg.setFrom(fromAddress);
            msg.setRecipients(Message.RecipientType.TO, 
InternetAddress.parse(“email_addr...@blah.com"));
            msg.setText(body);
            msg.setSubject(subject);
            Transport.send(msg);
} catch (Exception mex) {
            mex.printStackTrace();
}
    }
}





As soon as I replace the textarea tag with:

<h:inputTextarea id="contact-message"
                      name="comments"
                      placeholder="I wanna talk about..."
                      value="#{contactUs.message}”/>

…the bean’s message field is populated with a value.


Am I not using the textarea passthrough element properly?


 - Chris
The information transmitted is intended only for the person(s) or entity to 
which it is addressed and may contain confidential and/or legally privileged 
material. Delivery of this message to any person other than the intended 
recipient(s) is not intended in any way to waive privilege or confidentiality. 
Any review, retransmission, dissemination or other use of, or taking of any 
action in reliance upon, this information by entities other than the intended 
recipient is prohibited. If you receive this in error, please contact the 
sender and delete the material from any computer.

For Translation:

http://www.baxter.com/email_disclaimer

Reply via email to