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

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.

  • Even first time also it's not rerendering. – Vijay Kumar Dec 27 '17 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'}" – Tushar Sharma Dec 27 '17 at 6:43
  • 1
    Thanks now i am getting inputfield first time after changing the rendered condition. – Vijay Kumar Dec 27 '17 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>
  • 1
    Instead of code dumps you should also add what did you changed and how it will be helpful. – Tushar Sharma Dec 27 '17 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!!! – Naveen Dhanaraj Dec 27 '17 at 7:22

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.