1 Reply Latest reply on May 12, 2008 7:00 PM by Pete Muir

    Add Row In DataTable

    Lee Theobald Newbie

      This isn't really a Seam question, more a general JSF one but I thought someone here could give me a shove in the right direction.


      At the moment I have a RichFaces datatable displaying some information on the page.  What I would like to do is to have a link just above the table along the lines of Add New XYZ.  When you click on this link, a new row is inserted at the start of the datatable containing input fields for you to enter data.  Here's an example of what I mean from my Remember The Milk to-do list


      Does anyone know of any easy way to do this?  So far best I have come up with is this:



      1. Have a commandLink that fires an action that sets an addmode boolean to true and then adds a blank item to the list that my datatable iterates over

      2. Have my datatable check that addmode is true and that the current row is the first (the new blank item).  If it is an edit box is displayed.  Otherwise plain text is displayed.



      This will probably work but it seems really messy.  I guess I could do it programmatically but I'd really rather avoid it if I can.