0

I am trying to rerender an input field based on the event 'onchange' specific other input field which is of type multiselect picklist.

vf page

<apex:inputField value="{!MyObject__c.myField__c}">
<apex:actionSupport action="{!myMethod}" rerender="idToRender" event="onchange"/>
</apex:inputField>
<apex:inputField id="idToRender" value="{!MyObject__c.toBeRenderedField__c}" rendered="{!myBool}"/>

apex class

myMethod()
{
myBool = true;
}
1

<apex:inputField id="idToRender" value="{!MyObject__c.toBeRenderedField__c}" rendered="{!myBool}"/>

Instead of this you need to do this

<apex:outputpanel  id="idToRender">
<apex:inputField value="{!MyObject__c.toBeRenderedField__c}" rendered="{!myBool}"/>

</apex:outputpanel >

Because when first time page load this inputfield is rendered= false so it is not available on page so you can't rerender it. In that case we need to rerender the parent component.

4
  • error: that we cannot have duplicate 'ids' in the page
    – Surya
    Sep 13 '16 at 12:52
  • @Surya remove the inputfield Id Sep 13 '16 at 13:00
  • when I place <apex:inputField> tags inside an <apex:actionFunction> the title of the inputField is missing and it is not aligning with the other inputfield tags.Can you please help me on this?
    – Surya
    Sep 13 '16 at 13:19
  • @Surya you need to handle that using css or better solution instead of adding a outputpanel rerender your form or some top level component so you don't need this panel. Sep 13 '16 at 13:36
0

It should be

<apex:actionSupport action="{!myMethod}" rerender="idToRender" event="onchange"/>

unless you also have a function that returns the string 'idToRender'

1
  • it's my fault while posting the question, the 'rerender' is just as the way you specified. It's not working.
    – Surya
    Sep 13 '16 at 12:52

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.