I have a page with a form. My question is, if when I rerender a part of the form, its input values can simply be populated by '' or null.

                <apex:pageBlockSection id="generalInfo" columns="2">
                   <apex:inputField label="Name" value="{!newName}" required="true"/>
                   <apex:inputField label="Date" value="{!newDate}" onfocus="DatePicker.pickDate(false, this , false);" required="true" }
           <apex:pageBlockSection id="placeType" title="Additional Information" columns="2">
                    <apex:pageBlockSectionItem >
                    <apex:outputLabel for="place">Place</apex:outputLabel>  
                    <apex:actionRegion >
                        <apex:selectRadio value="{!place}" id="place">                           
                            <apex:selectOptions value="{!items}"/>                            
                            <apex:actionSupport event="onchange" rerender="placeType" status="status"/>                           
                    <apex:inputField label="The type" value="{!newType}" required="true"/>

The problem is, the !newType field is populated before the page is rendered... It's like if I only need for the page to fetch this value the first time, when it renders, and then ignore it's previous value and render as blank.

Best regards.

  • I don't really understand what you are asking here.
    – dphil
    Feb 14 '14 at 15:07
  • Edited the question.
    – Rui Rocha
    Feb 14 '14 at 15:16
  • Ok, so are you saying that when you rerender that field, you want it to automatically become blank?
    – dphil
    Feb 14 '14 at 15:21
  • Yes. The first time, it appears the value it had. On rerender, always be blank.
    – Rui Rocha
    Feb 14 '14 at 15:23

Assuming that you want 'anytime the field containing {!newType} is rerendered, you want to clear the current value'.

There are 2 ways to do this. 1 way could be to use either javascript or jQuery in order to fetch the field and clear it each time your 'onchange' event fires.

Another option is to force a call to an actionFunction which calls a method in your controller to run code to set 'newType = null;'.

Either option should work. Mostly depends if you wish to have the work server side or client side.

  • My preference would be to use the action method in your controller to set the value to null. Feb 14 '14 at 15:43
  • Yeah, I kinda knew it had to be done through one of these days. I was trying to avoid it because it's actually more than one value (like 5 or 6 p/different form) so I wanted to turn it to be more automatic. Thanks the help everyone.
    – Rui Rocha
    Feb 14 '14 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.