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
ManjeetManjeet 

Plz help on Reset Issues

 

 <apex:pageblockSection columns="3" title="Search By" collapsible="false">
         
         
         <apex:pageblockSectionItem id="prospectRefId">
                   Prospect Ref No <apex:inputText id="txt12345" value="{!prospectRefNo}" />           
           </apex:pageblockSectionItem> 
            <apex:inputField value="{!Prospects.Customer_Name__c}" id="Custom123" />
            <apex:inputField value="{!Prospects.Prospect_Source__c}"  />
            <apex:inputField value="{!Prospects.Type_Of_Relationship__c}" />
            <apex:pageBlockSectionItem >
                 <apex:commandButton reRender="thePanel123,myId,thePanel" action="{!search}" value="Search" />
                 <apex:commandButton  reRender="Custom123,txt12345,thePanel" 
                     action="{!reset}" value="Reset" immediate="true" />
                 
            </apex:pageBlockSectionItem>
                
         
          </apex:pageblockSection>

 

 

I want to reset all fields . But only customer name is reset by my reset method .

 

 

reset method code :
public PageReference reset(){
Prospects.customer_name__c = null;
        Prospects.Prospect_Source__c = '';
        setProspectRefNo(null);
        return null;
}

 

thanks in advance .......

 

rmehrmeh

Hi Manjeet,

 

Try and put id=" " for all the attributes you need to reset in the inputField.

And then mention those id's in the command Button reRender attribute.

 

 

 
For example:

<apex:inputField value="{!Prospects.Prospect_Source__c}" id="txtProspect"/>
<apex:commandButton reRender="Custom123,txt12345,txtProspect,thePanel"
action="{!reset}" value="Reset" immediate="true" />

 Hope this works for you!!!

 

ManjeetManjeet

yah

Its working for inputField of type text but not for inputText and inputField having PickList dataType's list  .

 solutoin would be appreciated...

rmehrmeh

Hi Manjeet,

 

If you are encountering the problem in Resetting InputField of Picklist Type.

Try using custom picklists as shown below :

 

<apex:selectList value="{!strCustomerProspect}" id="txtCustomerProspect" size="1"> 					            			  <apex:selectOptions value="{!CustomerProspect}" />  				            								        			</apex:selectList>
apex:commandButton  reRender="Custom123,txt12345,txtCustomerProspect,thePanel" 
action="{!reset}" value="Reset" immediate="true" />


// Apex Code

public List<SelectOption> getCustomerProspect(){
Schema.DescribeFieldResult F = Sobjectname.FieldName.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','--All--')); // if required
for(Integer i = 0; i < P.size(); i++){
options .add(new SelectOption(P[i].getValue(), P[i].getLabel()));
}
return options ;
}

 and then in your Reset Function the property used in "SelectList" as null as shown in below code:

 

 public PageReference reset()

{

     strCustomerProspect = null;

}

 

 

This should work for you!!!

Hope this helps.