You need to sign in to do that
Don't have an account?
NicGaller
InputText inside of DataTable lost on rerender when immediate=true
Hello,
Here is the scenario:
I set up a simple example with a contact edit page... here is the page, I put an "Add" and an "Add-Immediate" button, the "Add" button works but the "Add-Immediate" resets edited contacts:
and the controller:
I appreciate any insight.
Here is the scenario:
- I want to edit multiple records on a page inside of a table
- Most of the edits are done via <apex:inputField> components and those work great
- I have a few fields that need to be edited with custom controls instead (so I use <apex:inputText> then decorate them with javascript)
- I have a button for saving the table. This works great.
- I have a button at the bottom of the list for adding a new record. On that button I set immediate=true, since I did not want validation rules to be applied until the user was ready to commit their work. When they click that button, the <inputField> values are persisted, but the <inputText> values are getting reset.
- I can set immediate=false on that "add" button and everything appears to work fine, even when some records are incomplete, so maybe I am just misunderstanding what it does?
I set up a simple example with a contact edit page... here is the page, I put an "Add" and an "Add-Immediate" button, the "Add" button works but the "Add-Immediate" resets edited contacts:
<apex:page controller="GridEditController"> <apex:form > <apex:dataTable id="tbl" value="{!contacts}" var="c"> <apex:column value="{!c.Id}"/> <apex:column headerValue="Department"> <apex:inputText value="{!c.Department}"/> </apex:column> </apex:dataTable> <apex:commandButton value="Add" action="{!addToList}" rerender="tbl" immediate="false"/> <apex:commandButton value="Add-Immediate" action="{!addToList}" rerender="tbl" immediate="true"/> <apex:commandButton value="Save" action="{!save}" /> </apex:form> </apex:page>
and the controller:
public class GridEditController { public List<Contact> contacts { get; set; } public GridEditController(){ contacts = [select Id, Department from Contact]; } public PageReference addToList(){ contacts.add(new Contact()); return null; } public PageReference save(){ upsert contacts; return null; } }
I appreciate any insight.
Setting up immediate=true doesn't post back to controller and setters don't work, if you want data to post back you should use <apex:actionreigon>
Simple Example: