function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MickJMickJ 

dataTable object binding update

I have a list of a custom object that I display on a VisualForce page using a dataTable. The dataTable has four columns. The first is outputText, the second and third inputText, and the fourth inputCheckbox. The user modifies the contents of the inputText and inputCheckbox and then saves (updates). Initially everything works as expected. However after a few successful saves I always get the following error message:

<apex:inputText> element value must resolve to a String type!

If I log out, close the browser, and then return to the page I still get the error. I've read a few articles related to this type of functionality and my code seems to be using the correct approach.

Any thoughts on this?

Here is the code:

Code:
public class UpdateContractUsageStats {
 
        private final List<Contract_Usage_Data__c> ContractUsageData;
        
        public UpdateContractUsageStats() {
   
   ContractUsageData = [Select Id, Usage_Report_Interval_Label__c, Usage_Report_Date__c, UsageLives__c, UsageAmount__c, Usage_Report_Certified__c From Contract_Usage_Data__c Where Contract__c=: ApexPages.currentPage().getParameters().get('cid')];
        }
        
  public PageReference save() {
   try{
    update ContractUsageData;
   }
   catch(DmlException ex){
    ApexPages.addMessages(ex);
   }
   return null;
  }
        
        public List<Contract_Usage_Data__c> getContractUsageData(){
                return ContractUsageData;
        }
}

 
Code:
<apex:page controller="UpdateContractUsageStats">
 <apex:messages />
    <apex:form >
        <apex:dataTable value="{!ContractUsageData}" var="intervalData" id="theTable" rowClasses="odd,even" styleClass="tableClass">
            <apex:column width="25%">
                    <apex:facet name="header">Interval</apex:facet>
                    <apex:outputText value="{!intervalData.Usage_Report_Interval_Label__c}"/>
            </apex:column>
            <apex:column >
                    <apex:facet name="header">Usage Lives</apex:facet>
                    <apex:inputText value="{!intervalData.UsageLives__c}" disabled="{!intervalData.Usage_Report_Certified__c}"/>
            </apex:column>
            <apex:column >
                    <apex:facet name="header">Usage Amount</apex:facet>
                    <apex:inputText value="{!intervalData.UsageAmount__c}" disabled="{!intervalData.Usage_Report_Certified__c}"/>
            </apex:column>
            <apex:column >
                    <apex:facet name="header">Certified</apex:facet>
                    <apex:inputCheckbox value="{!intervalData.Usage_Report_Certified__c}" disabled="{!intervalData.Usage_Report_Certified__c}"/>
            </apex:column>
        </apex:dataTable>
        <apex:commandButton value="Update Statistics" id="theButton" action="{!save}"/>
    </apex:form>
</apex:page>

 


dchasmandchasman
Your page/controller look fine to me. We have a fix for an  issue with iteration components (e.g. apex:dataTable, apex:repeat, etc) and input components (e.g. apex:inputText) that I believe will fix this issue. This fix is being deployed tonight.



MrutyunjayMrutyunjay
Hi
Please make a different getter and setter for this text box and return the amount in string type variable ,I mean return type should be string.

Thanks
Mrutyunjay
MickJMickJ
dchasman - do you know if the fix was pushed to production? I tried the functionality this morning and the problem still exists.

Mrutyunjay - I tried you suggestion with no luck. Thanks for the suggestion.
dchasmandchasman
The fix I was referring to was deployed to all instances except AP0 last night but now that I am looking at this a bit more I doubt that was ever your issue. unfortunately I have been unable to reproduce the behavior you describe so far.
MickJMickJ
Thanks for the update.

I think we'll work around the issue by populating a listbox with the values from the first column and use a single set of inputs to capture user input.
MiddhaMiddha
I am also gettng the same error. This error only comes when you try to submit a form with one or more "disabled" field. Seems like, Visualfroce form submit does not accept any disabled field.

If you enable all your fields on the form, it works fine. Did you found any workaround on this?

GreatG
DiceManDiceMan

Ran into the same problem. It's appears to be narrower than GreatG says though. Ordinarily you can bind a numeric field to an inputText element, but if an inputText element is bound to a numeric field and disabled then the error is displayed on submitting.

 

I can proabably knock up a minimal page with the error if required.

SiriusBlackOpSiriusBlackOp
I encountered this same issue.  I had a search Text Input box that stayed enabled, but had disabled a few controls in a single table row. One of the controls that I had set to disabled in the table row was also a text input.  This situation produce the error above when trying to enter text into the search text box and search, however... to fix the error I only had to keep the text input in the table row enabled... all other controls were fine to keep disabled in the table row.  So, I assume it has something to do with the disabling of one textbox affecting all other textboxes.
eliotstock2eliotstock2
I have the same problem. Could someone from Salesforce please acknowledge this is a bug and let us when/whether it will be fixed?
Silabs AdminSilabs Admin

wow! the forum dates to 2008 and it is still not resolved in 2012 !!! 

Mitesh SuraMitesh Sura
Here is the workaround.. do not use "disabled" attribute. 
 
//Make fields read only based on profile
            $('.readOnly').each(function(i){               
                element = $(document.getElementById(this.id)); 
                element.attr('readOnly', true); 
                element.css({'background-color' : '#DFD8D1'});
                element.attr('title','Insufficient Privileges');
            });