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 

InputText Reset issue ???????

Hi All

 

Will Anybody let me know how to reset a apex:inputText  component . I have tried ajax to rerender the id of this textbox but nothing works for me .

 

<apex:inputText value="{!test}" id="123"/>

<apex:commandButton action="{!reset}" value="RESET" rerender="123"/>

 

controller

 

public string test {get;set;}

public PageReference reset(){

test = null;

retrun null;

}

 

thanks to all of you ..

 

rmehrmeh

Hi Manjeet,

 

I tried the same code. It works fine for me.

I am putting my code below, Please check

 

 

<apex:page controller="XYZ">
<apex:form >
	<apex:inputText value="{!test1}" id="test123"/>
	<apex:commandButton value="Test" action="{!resetAcc}" rerender="test123"/>
</apex:form>
</apex:page>


// Apex Code

public String test1{get;set;}
	public XYZ()
	{
	}
	public PageReference resetAcc()
	{
		test1 = '';
		return null;
	}

 

Are you using something else also on the page?

 

ManjeetManjeet

Yes the page contain many search fields including inputfiled of type text ,inputtext, inputfield of type pickList .

 

Input Text and input Filed of type Pick List are creating problem during reset .

rmehrmeh

Yes, you are right.

 

I think its because of inputField Picklist that your inputText is not resetting.

Are you also trying to reset your picklist?

And If yes, is it happening?

ManjeetManjeet

I am trying to reset all filter fields when user click on reset button . but only inputfield of type text reset its value ,not pickList and inputText .

rmehrmeh

Please can you post your code.

And if possible try not using inputfield for Picklist and inputText also, use custom picklists and inputText instead.

ManjeetManjeet

 

<apex:pageblockSectionItem >
                       <apex:outputLabel value="Prospect Ref No" for="kkk"/>                 
                       <apex:inputText value="{!prospectRefNo}" id="kkk" />           
            </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" action="{!Search}" value="Search" />
             <apex:commandButton reRender="Custom123,kkk,test" action="{!reset}" value="Reset" immediate="true"/>
        </apex:pageBlockSectionItem>

 Controller

 

 

 public PageReference reset(){
           
        Prospects.customer_name__c = null;
        Prospects.Prospect_Source__c = null;
        prospectRefNo = null;
        return null;
    
    }

 

is Reset is so complex on force.com . why they didnt make a simple solution for it ?

 

 

rmehrmeh

Hi Manjeet,

 

Please alter your code as follows:

If your inputField is of type picklist do the following:

 

 

<apex:selectList size="1" value="{!strAccountIndustry}" id="test456">
<apex:selectOptions value="{!accountIndustry}"/>
</apex:selectList>

<apex:commandButton value="Test" action="{!resetAcc}" rerender="test123, test456"/>

//Apex code

public List<SelectOption> getaccountIndustry(){
Schema.DescribeFieldResult F = Account(Sobject).Industry(Field of picklist Type).getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
List<SelectOption> options= new List<SelectOption>();
options.add(new SelectOption('','--All--'));
for(Integer i = 0; i < P.size(); i++){
options.add(new SelectOption(P[i].getValue(), P[i].getLabel()));
}
return options;
}

public PageReference resetAcc()
{
strAccountIndustry = null;
return null;
}

 Also instead of InputField of type inputText, use a normal inputText only.

 

This will definitely solve your issue.