+ Start a Discussion
Howard WeinsteinHoward Weinstein 

Issue Saving Data from Custom Controller Using InputTextArea

I have a large form with many different entries that the user is able to make entries for. Each item has its own save button. See example below
input area
My issue is that I am using a table structure for my custom so that every category has the same fields and is differentiated by the field values
data sample
In my method I am filtering through to idenitfy the current period entry for the category and placing it in an inputtextarea
method
Then in my apex page I display the data
vf code page
I then have a Save function in the controller that should save the current info to update the record but I am having several issues:
1) the data is not getting updated to any record in the list
2) the current record is not differentiated by the different categories

I can't figure out how to let the controller receive the current inputtextarea the user is updating from the VFpage. If I was able to isolate that I think I could then pass that back to the controller so it knows what to update

 
James LoghryJames Loghry
It's hard to say exactly where you're going wrong without seeing additional Apex or Visualforce.

I will say this though, if you have multiple forms that are the same or very similar, this is an excellent candidate for a Visualforce component.  Visualforce components can have their own controllers (and also you could easily make it so that each component has it's own "scope" with a save button for the form).

So here's something you could try (again I'm making an assumption here since I haven't seen much of your VF or Apex):
  1. Move the text area and save button into a Visualforce component with its own controller.  
  2. The controller would contain a "save" method of its own that saves a single instance of SDR_Answer__c.
  3. The commandButton that performs the save, uses the rerender attribute to rerender that specific component / form row / input text area.
  4. In your visualforce page, you loop through the list of SDR_Answer__c records, and for every instance you call the Visualforce component, passing in the instance as a parameter in your component.
If you're still having issues getting your logic to work, a good first step is adding System.debug statements to your controller methods, and opening a debug log (Setup->Monitoring->Debug Log), which will help narrow down any errors that occur.
Howard WeinsteinHoward Weinstein
I was able to figure out the issue which was really just Apex being a little quirky it seemed I did not really change anything but somehow it started working. I have to say my code is very inefficient so I will look into the Visualforce Component option to see if that makes the code more efficient.