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
TehNrdTehNrd 

Stuck on a simple clear button (bug?)

I have a pick list and I am trying to create a clear button that clears the value. This is pretty simple but I can't seem to figure it out.

Here is the simple code to reproduce:

Code:
PAGE:
<apex:page controller="clearCon" action="{!load}">
    <apex:form>
        <apex:pageBlock >
           <apex:pageBlockButtons location="bottom">
               <apex:commandButton value="Clear Criteria" action="{!clear}" rerender="industry"/>
           </apex:pageBlockButtons>
           <apex:pageBlockSection columns="2" id="industry">
               <apex:inputField value="{!acct.Industry}"/>
           </apex:pageBlockSection>
       </apex:pageBlock>
   </apex:form>
</apex:page>

Controller:
public class clearCon {

    public Account acct {get; set;}
     
    public PageReference load() {
        acct = new Account();
        return null;
    }
    
    public PageReference clear(){
        acct.Industry = null;
        return null;
    }

}

 



Message Edited by TehNrd on 10-07-2008 08:52 AM
DS777DS777
try
 
 <apex:commandButton value="Clear Criteria" immediate="true" action="{!clear}" rerender="industry"/>
TehNrdTehNrd
Adding immediate="true" made no difference.
ShamSham
Use this code,this might work.
Code:
<apex:pageBlockSectionItem>
                 <apex:outputLabel value="Industry" />
                 <apex:inputField value="{!acct.Industry}"/>
</apex:pageBlockSectionItem>

 may be a new bug in Winter 09.

TehNrdTehNrd
So I tried that and it only works once. If you select a value and then hit "Clear" it will clear it. If you then select another value and hit clear it will not work. This is starting to look like a bug, maybe more than one.


Message Edited by TehNrd on 10-07-2008 08:52 AM
dkraun123dkraun123
take off the immediate=true that you added and you should be fine.
TehNrdTehNrd

dkraun123 wrote:
take off the immediate=true that you added and you should be fine.

Whoops, totally forgot that was still there.

Taking a normal inputField and creating a pageBlockSectionItem seems like a lot of extra work especially if there are many fields. I discovered that If i rerender the inputField itself this will work as well but I was hoping I could rerender a pageBlockSection and clear many fields at once.


Message Edited by TehNrd on 10-07-2008 02:13 PM
dkraun123dkraun123
yeah, I ran into this same issue a while back. I was told that this is a known issue in vf rendering and that they will be trying to fix it in a later release.