0

When i select the picklist Complaint_type__c value as 'others' then i need to rerender the output panel. I tried in different ways using Pageblocksections but no luck.

below is my code..

<div class="container">
    <div id="wrapper">
        <apex:form id="theform" >
            <apex:pageblock >
                <div>
                <apex:actionRegion >
                    <apex:inputfield value="{!ca.Complaint_type__c}" required="true" >
                        <apex:actionSupport event="onchange" rerender="otherpanel" />
                    </apex:inputfield>
                </apex:actionRegion>
                </div>
                <div>
                <apex:outputPanel id="otherpanel">
                    <apex:outputPanel rendered="if({!ca.Complaint_type__c} == 'Others',TRUE,FALSE)">
                        <apex:inputfield value="{!ca.Other_Type__c}" required="true" />
                    </apex:outputPanel> 
                </apex:outputPanel>
                </div>
            </apex:pageblock >
        </apex:form>
    </div>
</div>
1
  • Can you paste your code fully... Commented Dec 27, 2017 at 6:15

2 Answers 2

1

As this apex:inputfield is required

<apex:inputfield value="{!ca.Other_Type__c}" required="true" />

So your rerender will work for first time but next time when you rerender it again it will not work unless you fill this required field.

You can use apex:pagemessage and rerender it to get same error message on the visualforce page.

So now best solution is make it required in controller and this issue will be solved. If you don't want to use that then you need to use apex:actionRegion or Immediate="true" to check if they help you in your use case.

3
  • Even first time also it's not rerendering. Commented Dec 27, 2017 at 6:27
  • 1
    @VijayKumar does first time apex:inputfield coming on page. Also you can change rendered condition as rendered="{!ca.Complaint_type__c== 'Others'}" Commented Dec 27, 2017 at 6:43
  • 1
    Thanks now i am getting inputfield first time after changing the rendered condition. Commented Dec 27, 2017 at 6:55
0

Try Like This,

<div class="container">
<div id="wrapper">
    <apex:form id="theform" >
        <apex:pageblock >
                <apex:inputfield value="{!ca.Complaint_type__c}" required="true" >
                    <apex:actionSupport event="onchange" rerender="otherpanel" />
                </apex:inputfield>
                <apex:outputPanel id="otherpanel" >
                    <apex:inputfield value="{!ca.Other_Type__c}" rendered="{!ca.Complaint_type__c == 'Others'}" required="true" />
                </apex:outputPanel>
        </apex:pageblock >
    </apex:form>
</div>
</div>
2
  • 1
    Instead of code dumps you should also add what did you changed and how it will be helpful. Commented Dec 27, 2017 at 7:10
  • I had removed the [apex:outputpanel ] which has the id=otherpanel and Passed the id in the next line of outputpanel. In output panel tag I had Removed the If condition and modified like this rendered="{!ca.Complaint_type__c == 'Others'}".so when ever you choose value as others the output panel block will be rendered.. Hope This Helps!!! Commented Dec 27, 2017 at 7:22

You must log in to answer this question.

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