1 Reply Latest reply on Dec 20, 2007 6:19 AM by Pete Muir

    How to select item in DataTable populated with @Unwrap?

    Mark Teichmann Newbie

      I like to use the Seam Manager Component pattern in Seam 2.0.0.GA and provide a list using @Unwrap:

      @Name("holidayRequestByApproverList")
      
      public class HolidayRequestByApproverList {
      
       @Unwrap
       public List<HolidayRequest> getHolidayRequestByApproverList() {
      
       ...
       return myList;
       }
      }


      In a datatable I display the list :

      <rich:dataTable id="dtHolidayRequestList" var="holidayRequest"
       value="#{holidayRequestByApproverList}"
       rendered="#{not empty holidayRequestByApproverList}">
      ...
      <h:column>
       <f:facet name="header">
       <s:span styleClass="columnHeader">Nr</s:span>
       </f:facet>
       #{holidayRequest.id}
       </h:column>
      <h:column>
       <f:facet name="header">Action</f:facet>
      
       <s:button value="Reject"
       action="#{holidayApprovalAction.reject(holidayRequest)}">
       </s:button>
       </h:column>


      But in my action I always get null instead of holidayRequest that I selected in datatable.

      @Stateful
      @Name("holidayApprovalAction")
      @Scope(ScopeType.SESSION)
      public class HolidayApprovalActionImpl implements HolidayApprovalAction {
      
       private static final long serialVersionUID = 6068522266849679060L;
      
      
       @PersistenceContext(type = PersistenceContextType.EXTENDED)
       EntityManager entityManager;
      
       @Begin
       public void reject(HolidayRequest hr) {
       ...
       entityManager.persist(hr);
       }
      


      I read chapter 30.1 of Seam Reference 2.0.0.GA several times and maybe some limitations occur when using JSF but I also tried using facelets and also got 'null' instead of my selected item.

      Also in chapter 30.1.1 it is told in a note that you cannot use objects as arguments therefore I also tried using holidayRequest.id as parameter but then I got 0 instead of the id of the selected item.

      I used DataModel and DataModelSelection before but then the displayed data in rich table was not refreshed correctly. Therefore I tried to use Unwrap which works perfectly but now I cannot select an item and paa it to my bean.