0 Replies Latest reply on Oct 30, 2008 4:52 PM by Gerardo Segura

    DataModelSelection initial value

    Gerardo Segura Newbie

      Hello, I'd like to know if DataModelSelection default behavior is to be initialized to last object in DataModel.

      See: I have a page with a rich:dataTable filled with Contact objects. Below that, there is a a4j:region which will reRender upon selection of a Contact.

      The thing is: even on first display of the page the DataModelSelection object is not null (it is equal to the last Contact displayed on dataTable). 
      Is this normal behavior?
      Here is relevant code:

      public class ContactListBean implements ContactList {
          List<Contact> contacts ;
          Contact selectedContact;
          //this method called with a a4j:commandLink rendered in each row
          public void selectContact() {
              log.info("selectedContact: {0}",selectedContact) ;
          public Contact getContact() {
              log.info("getSelectedContact(): {0}",selectedContact) ;
              return selectedContact;
          public void setContact(Contact selectedContact) {
              log.info("setSelectedContact({0})",selectedContact) ;
              this.selectedContact = selectedContact;

      //THIS IS EntityHome<Contact>
      public class ContactHome extends EntityHome<Contact> {
          @In ContactList contactList;
          public void create() {
              log.info("[contactHome.create()] contact: #{contactList.contact}");
              if(contactList!=null && contactList.getContact()!=null)
                  contactId = contactList.getContact().getId();

      I can see that even on first call to ContactHome.create() contactList.contact is already initalized despite no call of contactList.selectContact() has been made.

      I can imagine a couple of workarounds for this, but it would be great to know real cause of DataModelSelection been set. 

      best regards