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

Checkbox causes a refrash



I have a table with the first column being a checkbox.

When checked this checkbox causes a refrash of the page and I want to avoid it.

I'm using the onclick event (with no call to the controller) but when I remove it the check is not saved to the controller and my logic is not working properly.


Need help, This is my code:



<apex:page Controller="SearchCheckedOutBooksController" showHeader="false" Tabstyle="Library_Order__c">
  <apex:sectionHeader subtitle="ECI Information Center Portal"/>
      .activeTab {background-color: #2369FF; color:white; background-image:none}
      .inactiveTab { background-color: lightgrey; color:black; background-image:none}
   <apex:tabPanel switchType="client" selectedTab=" tabCard" id="InfoCenterTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">   
      <apex:tab label="News" name="News" id="tabnews">
         <apex:detail relatedList="false" title="true"/>
      <apex:tab label="My Library Card" name="Card" id="tabCard">
            <apex:pageBlock title="Search My Library Orders" mode="edit">         
                <apex:form >                       
                    <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subscriber ID to query&nbsp;</label>
                    <apex:inputText value="{!subscriberId}"/>
                    <apex:commandButton action="{!searchOrders}" value="Search" rerender="orderResults"/>                  
           <!-- The results for each call are handled here. -->              
            <apex:outputPanel layout="block" id="orderResults">
                <apex:outputPanel rendered="{!IF(hasError == false,true,false)}"> 
                    <apex:pageBlock title="Search Results">
                        <apex:pageBlockButtons >
                            <apex:form >        
                                <apex:commandButton value="Cancel Selected Orders" action="{!cancelOrder}"/>
                        <apex:pageBlockSection title="Pending Orders">
                        <apex:form >        
                            <apex:pageBlockTable width="50%" value="{!myPendingOrders}" var="entry">
                                <apex:column headerValue="Select">
                                    <apex:inputCheckbox id="checkedone" value="{!entry.isSelected}" disabled="{!entry.disable}"/>
                                    <apex:actionSupport event="onclick" />
                                <apex:column value="{!entry.order.Name}" headerValue="Order ID"/> 
                                <apex:column value="{!entry.order.Type__c}" headerValue="Type"/> 
                                <apex:column value="{!entry.order.Status__c}" headerValue="Order Status"/> 
                                <apex:column value="{!entry.title}" headerValue="Title"/>
                                <apex:column value="{!entry.order.Order_Date__c}" headerValue="Order Date"/>
                                <apex:column value="{!entry.order.Fulfillment_Date__c}" headerValue="Checkout Date"/>
                                <apex:column value="{!entry.order.Return_By__c}" headerValue="Return By"/>







Best Answer chosen by Admin (Salesforce Developers) 

I suspect things are getting confused as you have several apex:form tags on your page - the advice in the docs is only to have one.


Try putting the whole page into a single form - that should propagate your changes.  

All Answers


This is documented behaviour - the Visualforce Developer's Guide has this to say about the actionsupport action attribute:


--- snip ---


If an action is not specified, the page simply refreshes.


--- snip ---


Can you explain a bit more about what you are trying to do?  e.g. do you need to update values in the controller in order to redraw part of the page?  


I got the same behaviour when I specified an action (I removed it in the code I posted).

In the controller I'm "collecting" all the checked rows executing some APEX code, here the method that does that when an action button is clicked:



    public void searchOrders(){
	        Library_Sunscriber__c sub = [SELECT ID, Name, Subscriber_ID__c, Email_address__c,
	                                         (SELECT ID, Name, Type__c, Status__c, Title__r.Name, Information_Retrieval__r.Name, 
	                                                         Order_Date__c, Fulfillment_Date__c, Return_By__c
	                                          FROM Library_Orders__r)
	                                     FROM Library_Sunscriber__c
	                                     WHERE Subscriber_ID__c =: subscriberId]; 
	        for(Library_Order__c order :sub.Library_Orders__r){
	            if(order.Status__c == 'Pending'){
	            	myPendingOrders.add(new tableEntry(order));	
	            	if(order.Status__c == 'Fulfilled' && 
		               order.Type__c != 'Information Retrieval'){                     
		               		myCheckedoutOrders.add(new tableEntry(order)); 
		            	myOlderOrders.add(new tableEntry(order));     
	        hasError = false;               
        catch(Exception e){
        	hasError = true;        



If I remove the actionSupport all together the code does not work at all (for some reason the isSelected is not being updated on the controller)




I suspect things are getting confused as you have several apex:form tags on your page - the advice in the docs is only to have one.


Try putting the whole page into a single form - that should propagate your changes.  

This was selected as the best answer

Many thanks


Now it works as expected.


I have another issue going though.


I have three tabs on this tab Panel. When I click on the Search button my tables are being populated but when I click on the Delete Order button along with the action being performed the page is refrashed and the 1st tab is being desplayed (I'm on the 2nd when I do it). Why does it jump to the 1st tab?

Why is the different behavior?




Your search button has a rerender attribute associated with it - the other actions don't so they cause the entire page to be refreshed.


Got it,


Thanks a lot