You need to sign in to do that
Don't have an account?

Potential bug with inputHidden in a custom component
I'm having a problem with a Visualforce custom component where upon invoking Save, a numeric value is changing from null to zero.
One of my custom objects has a numeric field called Q1Status. This is marked as not required and has no default value.
After creating an empty object in the database, the value Q1Status is null. I can show this by executing a query in the System Log.
15:20:57 DEBUG - Executing: System.debug( [SELECT Id, Opportunity__c, Q1Status__c FROM MSO_Process__c WHERE Opportunity__c='0068000000OPGlbAAH'] ); 15:20:58 INFO - 20090821142059.532:AnonymousBlock: line 1, column 15: SOQL query with 1 row finished in 22 ms 20090821142059.532:AnonymousBlock: line 1, column 1: (MSO_Process__c:{Opportunity__c=0068000000OPGlbAAH, Id=a0980000003cgj3AAA})
(Q1Status is missing from the returned data, so I'm assuming this means it is null)
On my Visualforce edit page I am invoking my custom component like this:
<c:MSO_Status_Colour value="{!MSO_Process__c.Q1Status__c}" selName="Colour1"/>
The component looks like this:
<apex:component> <apex:attribute name="value" description="Status field" type="Double" required="true"/> <apex:attribute name="selName" description="Selection tag name" type="String" required="true"/> <apex:attribute name="readonly" description="Read-only or edit control" type="Boolean" default="false"/> <apex:OutputPanel rendered="{!!readonly}"> <apex:inputHidden value="{!value}" id="statusValue" /> </apex:OutputPanel> </apex:component>
Clearly the component makes no change to the value passed in.
If I now open the edit page of the new object and inspect the HTML, I can see that the value being passed into the html input tag is null (or more specificly is not set).
If I click Save on the edit page and reinspect the database I find that the value of Q1Status is now 0.
14:18:09 DEBUG - Executing: System.debug( [SELECT Id, Opportunity__c, Q1Status__c FROM MSO_Process__c WHERE Opportunity__c='0068000000OPGlbAAH'] ); 14:18:10 INFO - 20090821131811.473:AnonymousBlock: line 1, column 15: SOQL query with 1 row finished in 11 ms 20090821131811.473:AnonymousBlock: line 1, column 1: (MSO_Process__c:{Q1Status__c=0, Opportunity__c=0068000000OPGlbAAH, Id=a0980000003cgY5AAI})
Can anyone say if this is working as intended or is just a bug? Is there a work around?
Interestingly, if I comment out the apex:inputHidden line, the problem goes away.
Many thanks.
- Andy