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
AveleenaAveleena 

Pass Values from VisualForce Page to Custom Controller

Hi,

 

I need an urgent help.

I have a input field on my visualforce page which is wrapped in an action function. The field is a checkbox. Once the user clicks on the checkbox i have method in my controller. The issue that i am facing is, the checkbox value is always false in my controller.

Can anyone please help me out and let me know why this is happening.

 

Thanks in advance!

Ashish_SFDCAshish_SFDC

Hi Avaleena, 

 

Was this working fine before or it is recently coded?

 

In the controller, did you mention the by default option of the checkbox? 

 

And can you post your code so that the community members can identify if there is any issue. 

 

Regards,

Ashish

 

AveleenaAveleena

Hey Ashish,

 

It was working fine before.

<apex:pageBlockSectionItem >
                                              <apex:actionRegion >
                                                    <apex:inputfield value="{!quote.Check_If_the_address_is_same_as_above__c}">
                                                        <apex:actionSupport event="onclick"
                                                            action="{!copyoverAddress}" rerender="cobuyer"/>
                                                        </apex:inputfield>
                                               </apex:actionRegion>
                                                <apex:outputLabel styleClass="labelCol ">Check if the address is same as above</apex:outputLabel>
                                            </apex:pageBlockSectionItem>

 

public void copyoverAddress(){
   
   //quote.Check_If_the_address_is_same_as_above__c =true;
   System.debug('quote.Check_If_the_address_is_same_as_above__c is '+quote.Check_If_the_address_is_same_as_above__c);
   if(quote.Check_If_the_address_is_same_as_above__c ){
       System.debug('clicked');
       quote.Address_Line_1_CoBuyer__c = quote.Address_Line_1__c; 
       System.debug('@@@@1 '+quote.Address_Line_1__c);
       quote.Address_Line_2_CoBuyer__c = quote.Address_Line_2__c;
       System.debug('@@@@2 '+quote.Address_Line_2__c);
       quote.City_CoBuyer__c = quote.city__c;
       System.debug('@@@@3 '+quote.city__c);
       quote.Country_CoBuyer__c = quote.Country__c;
       System.debug('@@@@4 '+quote.Country__c);
       quote.State_CoBuyer__c = quote.State__c;
       quote.Zip_CoBuyer__c = quote.Zipcode__c;
       System.debug('@@@@5 '+quote.Zipcode__c);
   }else{
       
       quote.Address_Line_1_CoBuyer__c =quote.Address_Line_1__c;
       quote.Address_Line_2_CoBuyer__c='test';
       quote.City_CoBuyer__c='test';
       quote.Country_CoBuyer__c='test';
       quote.State_CoBuyer__c='test';
       quote.Zip_CoBuyer__c='test';     
      }
  }

 

Ashish_SFDCAshish_SFDC

Hi Aveleena, 

 

You can give attribute ‘rendered’ in <apex:inputCheckbox rendered = “{! IF(showcheck == 1,true,false)}”>  AND give the value 1 & 0 in controller wherever you want to check  and uncheck the checkbox.

 

http://boards.developerforce.com/t5/Visualforce-Development/Setting-default-value-on-Checkbox/td-p/192707

 

Also see the link below for more info, 

 

http://stackoverflow.com/questions/15041259/maintaining-checkbox-status-in-apex-controller

 

Regards,

Ashish

 

AveleenaAveleena

I am still not able to figure out what the problem is, if i move the checkbox field to a different pageblock it is able to pass the correct value to the controller.

 

Does it look like some reRender issue that i might be missing,  this code was working fine few weeks back.

Anil SavaliyaAnil Savaliya

Hi,

 

Remove Action region tag

 

<apex:pageblock id = "abc">\

----------------

<apex:actionsupport ........................    rendeded= "abc">

-------------------

<apex:pageblock>

 

I had same proble,It was working some browser but not in anther.

 

 

AveleenaAveleena


I have tried that already, does'nt work

Ashish_SFDCAshish_SFDC

Hi Aveleena, 

 

Try the rerender code in the below post if that works, 

 

http://boards.developerforce.com/t5/Visualforce-Development/Passing-Parameters-from-Visualforce-Page-to-Controller-methods/td-p/103958

 

Regards,

Ashish

Sugandhi VermaSugandhi Verma
hii ashish,

the link is not working.