+ Start a Discussion

Adding rows to a table

Next question,

I'd like to use a rerender to allow me to add rows to a table I'm building on a page.  This is the standard type of "you get one line of blank fields, and after you fill it out, you click 'new X' to get a new row to fill in"

I have the table backed by a list, and I can get it to render the row properly.  However, I can't figure out how to call an action on the controller to add the row before I do the rerender.  My first guess was to try:

<apex:commandlink action="addShift" reRender="shiftable" >Add Shift</apex:commandlink>

(where shifttable is an output panel wrapped around the datatable, and addShift is a controller action that adds a new object to the list of objects that the table iterates on)  But what happens, and what I see in Firebug, is that it just does a normal rerender on the datatable without calling the action.  Any hints on how I should do this?


Ok, I figured this one out (mostly).  I was using some double and integer backing variables, and it was making the submit fail.  Changed them all to string, and it works.

Which still leaves me with the "How do you do in-action validations and errors" question.  I can't find anything in the doc about it.

AFawcett (CODA)AFawcett (CODA)
Hello, I'm trying to do roughly the same thing, can you share some code and/or explain what you mean by "double and integer backing variables"? Cheers!
The issue with non-string value bindings has been fixed in Winter '08.