You need to sign in to do that
Don't have an account?
prazon
Urgent help required: cannot save value of radio button in the object
Hi I have done the following code the value is not saving in the database. Please help me
<apex:outputText value="{!$ObjectType.Flag_Reporter__c.fields.Flag_for_Editorial__c.label}: " style="color:black;font-size:14px"/> <apex:selectRadio value="{!editorial}" required="true"> <apex:actionSupport event="onchange" action="{!EditMethod}"/> <apex:selectOptions value="{!items}"/> </apex:selectRadio> </td>
class is here
public String editorial{get;set;} public void EditMethod(){ flagReport[0].Flag_for_Editorial__c = this.editorial; } public Pagereference save(){ Boolean edited = false; if(flagReport[0].Flag_for_Editorial__c!= NULL){ edited = true; } try{ if(edited == true){ update flagReport; } }
You have immediate="true" on your commandbuttons - that discards any changes you have made and refreshes the page with the original values. If you remove those it should start working.
All Answers
Can you tell us the error that you are seeing?
It is not saving the data I have set in the database, it is coming null
Have you added debug to see if your EditMethod is being invoked?
On selection it is getting refreshed..but whether I choose onselect or onchange this is not working...please help me which can save value to the database
You may need to supply a rerender attribute for the onchange event - I've seen odd behaviour around that sort of thing in the past.
Also, can you post some more of your code - for instance, how the flagReport list is created?
Hi Bob,
I don't want to render any portion of the page but save the value selected in the database...please help me...
Here it is
So rather than carrying out ajax requests, why don't you simply check the value when the save method is invoked - something like:
and in the controller, you can check the value of editorial, as it will be populated via the postback:
This was the code earlier
where I put this in the save method
I assume you posted this because you had an issue with that code?
Yupe...this one was the original....please tell me where it gone wrong
Have you checked the debug logs to confirm you aren't getting an exception - at the moment you are just swallowing it if one occurs.
I am checking Flag_Reporter__c object..values are not chaning
changing*
Hi Bob,
checked it in debug, it is coming null as confirmed
So you aren't getting an exception but the values aren't being posted back either? That sounds very odd. Can you post the full page and controller?
page:
header of the page
<apex:page standardStylesheets="false" standardController="Account" extensions="Account_Flag_Status_Controller">
You have immediate="true" on your commandbuttons - that discards any changes you have made and refreshes the page with the original values. If you remove those it should start working.
tried javascript too....why this value is not carrying it on the class?
Removed immediate=true, but still it is not working :(
I can't really work out what the page is doing now. You should not require javascript for this - by setting the value of the input component to a controller property, that will be filled in by the postback.
It worked ultimately..thanks Bob :) ....take a bow
Glad to hear it.