3

I have a pageblock section .. and a button Clear Details This button should refresh the pageblocksection and show blank values

<apex:pageBlockSection columns="1" id="Test">
    <apex:inputField value="{!Test1.Title__c}" />
    <apex:inputField value="{!Test1.Name__c}" />
</apex:pageblocksection>
<apex:pageBlockButtons >
    <apex:commandButton value="Clear" action="{!clearDetails}" rerender="Test"/>
    <apex:commandButton value="Save Details" Action="{!save}" />
</apex:pageBlockButtons>

Apex Code:-

 public PageReference clearDetails()
 {
        PageReference pageRef = null;
        return pageRef;
 }
1
  • 1
    You appear to be on the good way, what is it you're having trouble with ? Commented Oct 22, 2013 at 11:42

2 Answers 2

2

You need to re-initialize the Test1 object as well:

public PageReference clearDetails()
{
    Test1 = new Test1();    
    return null;
}
1
  • good catch didnt notice that. I didnt use the provided apex when i tested Commented Oct 22, 2013 at 11:46
1

You can wrap the fields in an outputPanel and refresh that panel as well

<apex:pageBlockSection columns="1" id="Test">

    <apex:outputPanel id="panel">
        <apex:inputField value="{!Test1.Title__c}" />
        <apex:inputField value="{!Test1.Name__c}" />
    </apex:outputPanel>

</apex:pageblocksection>
<apex:pageBlockButtons >
    <apex:commandButton value="Clear" action="{!clearDetails}" rerender="Test,panel"/>
    <apex:commandButton value="Save Details" Action="{!save}" />
</apex:pageBlockButtons>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .