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

actionsupport too slow in VF page


I need to hide/show fields based on picklist. I have used actionsupport for this. when picklist value is 'urgent'; i need to show two fields (one is picklist and one is long text area). When picklist value is 'Non-Urgent'; I need to hide these two fields. My code is like below:

<apex:outputPanel id="UrgentFields" rendered="{!NOT(ISNULL(}">  
                 <apex:pageblocksection title="Urgency" showheader="true" columns="1">
                 <apex:pageBlockSectionItem >
                        <apex:outputLabel value="{!$ObjectType.Vendor_Mgmnt__c.fields.Urgency__c.label}" for="Urgency"/>
                        <apex:actionRegion immediate="true">                  
                            <apex:inputfield id="Urgency"  value="{!Vendor_Mgmnt__c.Urgency__c}" required="true">
                            <apex:actionSupport event="onchange" rerender="UrgentFields"/>
                   <apex:pageBlockSectionItem rendered="{!Vendor_Mgmnt__c.Urgency__c=='Urgent'}" >
                        <apex:outputLabel value="{!$ObjectType.Vendor_Mgmnt__c.fields.Impact__c.label}" for="Impact"/>
                        <apex:inputfield id="Impact" value="{!Vendor_Mgmnt__c.Impact__c}"  required="true"/>
                   <apex:pageBlockSectionItem rendered="{!Vendor_Mgmnt__c.Urgency__c=='Urgent'}" >
                        <apex:outputLabel value="{!$ObjectType.Vendor_Mgmnt__c.fields.Reason__c.label}" for="Reason"/>
                        <apex:inputfield id="Reason" value="{!Vendor_Mgmnt__c.Reason__c}" style="width:550px" required="true"/>            

The rendering of the fields is working exactly as expected. But the problem is rendering is slow. So what happens is when user selects picklist value as 'Non-Urgent' and quickly hits on save button then 'Mandatory field' validation error appears for the 'Impact' and 'Reason' fields because they are mandatory fields. Actually, these fields should have been hidden. So, I think validation happens before my ajax request complets. Any idea how can I solve this?
Instead of using <apex:pageBlockSectionItem rendered="{!Vendor_Mgmnt__c.Urgency__c=='Urgent'}" > try using <Apex:OutputPanel>  and see how it behaves now! Hope this would solve your issue..