+ Start a Discussion
trailhead solutions 10trailhead solutions 10 

VF Page Refresh not working with rerender

Hello All

Please find the below,   controller and a part of VF Page. Here the refresh not working when User clicks on Verify Asset button, the new one , which User has to enter is populating 3 Fields (Location, Warranty, Date) with the Previous entered Values. Please someone help in change of code or where have to change to get empty of those 3 fields on addition of new?

Thanks in Advance!
TrialHead Aspirant

VF Page:

 <apex:outputPanel rendered="{!renderAddAsset}">
                Model Number:<apex:inputText value="{!modelNumber}"/> 
                Serial Number:<apex:inputText value="{!serialNumber}"/>
                Install Date:<apex:input value="{!installDate}" 
                    html-placeholder="Install Date" 
                <apex:selectList label="Fields" value="{!selectedLocationId}" multiselect="false" size="1" >
                     <apex:selectOptions value="{!LocationSelections}" />
                In Warranty?<apex:selectList id="WarrantyStatusId" value="{!WarrantyStatus}" size="1">
                    <apex:selectOption itemValue="true" itemLabel="Yes"/>
                    <apex:selectOption itemValue="false" itemLabel="No"/>
                 <apex:commandButton action="{!verifyAsset}" value="Verify Asset" reRender="apexform" status="spinnerStatus" styleclass="slds-button slds-button_brand"/>
                <apex:commandButton action="{!cancelAddAsset}" value="Cancel" reRender="apexform" status="spinnerStatus" styleclass="slds-button slds-button_brand"/>

public PageReference verifyAsset(){
        Boolean hasErrors = false;
        if(modelNumber == '' || modelNumber == null){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Please enter model number.')); 
            hasErrors = true;
        if(selectedLocationId == 'Select service location' ){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Please select a location.')); 
            hasErrors = true;
        if(!string.isBlank(modelNumber)  && !modelNumber.isAlphanumeric() ){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Model Number can only contain alphanumeric characters.')); 
            hasErrors = true;
            assetError = true;
            return null;
        User-added image
Dushyant SonwarDushyant Sonwar
You are getting some error in rerender.  To check for the errors , you need to add
<apex:pagemessages id="pg"/>



Hope this helps!!
trailhead solutions 10trailhead solutions 10
Hello Dushyant Sonwar

The Code still not working and the same mentioned as above, the button not working actually.

Can you please suggest me on this to resolve.

Dushyant SonwarDushyant Sonwar
Please share your whole vf page code. I think you didn't implemented the solution  correctly.