1 Reply Latest reply on Nov 10, 2008 9:54 PM by Thai Dang Vu

    Possible to use a session bean seam component to host a valueChangeListener method?

    Thai Dang Vu Apprentice

      I modify a little bit the Message example of Seam reference. This is the messages.xhtml:

          <h:outputText value="No messages to display" rendered="#{messages.rowCount == 0}"/>
          <h:dataTable value="#{messages}" rendered="#{messages.rowCount > 0}" var="message">
                  <f:facet name="header"><h:outputText value="Read" /></f:facet>
                  <h:selectBooleanCheckbox value="#{message.read}" valueChangeListener="#{messageManager.markMessage}"/>
                  <f:facet name="header"><h:outputText value="Title" /></f:facet>
                  <h:commandLink value="#{message.title}" action="#{messageManager.select}"/>
                  <f:facet name="header"><h:outputText value="Date/Time" /></f:facet>
                  <h:outputText value="#{message.datetime}">
                      <f:convertDateTime type="both" dateStyle="medium" timeStyle="short"/>
                  <h:commandButton value="Delete" action="#{messageManager.delete}"/>
          <h3><h:outputText value="#{message.title}" /></h3>
          <h:outputText value="#{message.text}"/>

      I added a valueChangeListener method to the check boxes. In the MessagesManageBean, I added a method to catch the valueChangeListener event.

      public class MessageManagerBean implements Serializable, MessageManager {
          private final Log log = LogFactory.getLog(getClass());
          private List<Message> messages;
          @Out(required = false)
          private Message message;
          @PersistenceContext(type = PersistenceContextType.EXTENDED)
          private EntityManager entityManager;
          public void findMessage() {
              messages = entityManager.createQuery("select m from Message m order by m.datetime desc")
          public void select() {
          public void delete() {
              message = null;
          public void markMessage(ValueChangeEvent event) {
              log.debug(new StringBuilder("Check if Seam intercepts the valueChangeListener:\n")
                      .append("Old value: ").append(defaultIfNull(event.getOldValue(), "null")).append("--> new value")
                      .append(defaultIfNull(event.getNewValue(), "null")).append('\n').append("Message: ")
                      .append(defaultIfNull(message, "no message title because the message is null")));
          public void destroy() {

      I noticed that the markMessage wasn't called although there's no exception!