You need to sign in to do that
Don't have an account?
GoForceGo
Does re-render NOT work on an inputField component?
1. The scoring_pick_list__c field is not displayed when I pick the 'Picklist' value in the question type.
2. I tried replacing it with a pageBlockSectionItem with outputLabel and inputLabel and re-rendering the child components, it still does not work.
3. If I wrap inputField or the pageBlockSectionItem (from #2) in an outputPanel, it works, but them the styling is all messed up, since it is not a direct child of pageBlockSection.
<apex:page standardController="Survey_Question__c" >
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Question" id="question" >
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.Survey_Question__c.fields.Question_Type__c.label}" for="qtype"/>
<apex:inputField value="{!Survey_Question__c.Question_Type__c}" required="true" id="qtype">
<apex:actionSupport event="onchange" rerender="spicklist"/>
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:inputField value="{!Survey_Question__c.Scoring_Pick_List__c}" rendered="{!Survey_Question__c.Question_Type__c = 'Picklist'}" id="spicklist"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Even I have experienced similar behaviour while re-rendering, I tries using main page blocks and having few sub pageblocks or panels. I'm not sure about reason behind it.
No. I guess there is a bug/conflict into the configuration. Try using Javascript to hide your blocks or put the inputfield section into iframe.
It appears that anything that has a rendered attribute cannot be a direct target of rerender.
Try rerendering the <apex:pageBlockSection> instead
Is your inputfield rendered the first time that you access the page? If not, then you won't be able to make it appear through rerendering, as you can't rerender something that isn't present. You have to wrap the conditionally rendered item in a container (e.g. outputPanel) that is rendered in all cases.
I wrote a blog post explaining this in more detail at:
http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html
Thanks Bob. As you correctly pointed out, you cannot re-render something that does not exist.
The problem with using outputPanel is that it messes up the styling of the pageBlockSectionItem.
I think I might try using a pageBlockSectionItem and using outputPanel wrapped around outputLabel and inputField.
Yes, the outputpanel will mess up the styling, as it introduces extra div/span tags to allow the grouped content to be available via javascript. I usually end up re-rendering a large chunk of the page to ensure my styling is retained, even if I really only want to rerender one or two elements.
The following works. Essentially I am wrapping the label and inputfield in an output panel and I re-render scorelabel and scorevalue.
In my original post, I had removed some elements to make the example smaller. Here is the updated example with essential elements which now works.
Why I cannot re-render a large section (pageBlockSection or pageBlock):
This atttribute logicallly belongs within this pageBlockSection. This pageBlockSection has a few required fields (e.g question name) As a result, I had to wrap the questionType in actionRegion. I cannot re-render the entire pageBlockSection, because I would loose any values entered in other parts of this section (e.g the question name) on the actionSupport event, since actionRegion only sends value of question type.