You need to sign in to do that
Don't have an account?
trailhead 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"
type="date"/>
<apex:selectList label="Fields" value="{!selectedLocationId}" multiselect="false" size="1" >
<apex:selectOptions value="{!LocationSelections}" />
</apex:selectList>
In Warranty?<apex:selectList id="WarrantyStatusId" value="{!WarrantyStatus}" size="1">
<apex:selectOption itemValue="true" itemLabel="Yes"/>
<apex:selectOption itemValue="false" itemLabel="No"/>
</apex:selectList>
<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"/>
</apex:outputPanel>
Controller:
============
public PageReference verifyAsset(){
resetError();
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;
}
if(hasErrors){
assetError = true;
return null;
}
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"
type="date"/>
<apex:selectList label="Fields" value="{!selectedLocationId}" multiselect="false" size="1" >
<apex:selectOptions value="{!LocationSelections}" />
</apex:selectList>
In Warranty?<apex:selectList id="WarrantyStatusId" value="{!WarrantyStatus}" size="1">
<apex:selectOption itemValue="true" itemLabel="Yes"/>
<apex:selectOption itemValue="false" itemLabel="No"/>
</apex:selectList>
<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"/>
</apex:outputPanel>
Controller:
============
public PageReference verifyAsset(){
resetError();
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;
}
if(hasErrors){
assetError = true;
return null;
}
reRender="apexform"
To
Hope this helps!!
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.
Thanks!