<apex:page standardController="Case" extensions="relevant">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 function toggleDiv1() {

        <apex:pageBlock id="block" mode="edit">

            <div style="overflow: scroll; height: 200px;">
                <apex:pageBlock title="Recommended Resolution">
                    <apex:outputPanel layout="none">
                        <apex:commandButton Value="Select Resolution" action="{!SelectResolution}" title="Selected Resolution will be copied in current Case resolution field" />
                        <apex:commandButton Value="View" rerender="null" onclick="toggleDiv1()" title="" />
                        <apex:commandButton id="btn1" Value="Back" reRender="block" title="" disabled="false" />

                    <apex:pageBlockSection id="cases" columns="1">
                        <apex:pageMessages id="showmsg" />
                        <apex:pageBlockTable rows="6" value="{!performcallout}" var="wrap" width="100%">
                            <apex:column headerValue="Select">
                                <input type="radio" name="<strong>selectRadio</strong>" id="radio">
                                <apex:actionSupport event="onclick" action="{!getSelected}" rerender="show,showmsg">
                                    <apex:param name="wrapid" value="{!wrap.name}" />
                            <apex:column headerValue="Case Id">
                                <apex:commandLink value="{!wrap.Name}" /> </apex:column>
                            <apex:column headerValue="Case Resolution">
                                <apex:outputText value="{!wrap.Email}" /> </apex:column>
                            <apex:column headerValue="Confidence Score">
                                <apex:outputText value="{!wrap.AccNumber}" /> </apex:column>


                <apex:outputPanel id="show">
                        <apex:pageBlockSection title="Resolution In Detail" rendered="{!IF(wrapid!=Null, true, false)}">
                            <!--<apex:pageBlockSection title="Resolution In Detail" id="Hide" > -->


Controller :

public with sharing class relevant {

    public List < consolewrap > ConsoleWrapperList {
    public String wrapid {
    public String Des {
    case currentRecord {
    public string currentCaseId {
    public Map < String, String > pairingmap = new Map < String, String > ();
    public relevant(ApexPages.StandardController controller) {
        currentCaseId = '5002800000X1ilT';
        system.debug('currentCaseId' + currentCaseId);
        currentRecord = [SELECT Id, Description FROM Case WHERE Id =: currentCaseId];


    public List < consolewrap > getperformcallout() {

        ConsoleWrapperList = new List < consolewrap > ();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();

        Http http = new Http();


        system.debug('req ' + req);

        res = http.send(req);
        system.debug('res' + res);
        system.debug('resbody' + res.getbody());
        if (res.getstatusCode() == 200 && res.getbody() != null) {

            ConsoleWrapperList = (List < consolewrap > ) json.deserialize(res.getbody(), List < consolewrap > .class);


        return consolewrapperlist;

    public void getSelected() {
        Abool = true;
        Bbool = false;
        System.debug('Entered Case selection block');
        wrapid = ApexPages.currentPage().getParameters().get('wrapid');
        system.debug('weaa' + wrapid);

        for (consolewrap cl: consolewrapperlist) {
            pairingmap.put(cl.name, cl.email);
            system.debug('@@@pairingmap' + pairingmap);

        currentRecord.Description = pairingmap.get(wrapid);
        Des = pairingmap.get(wrapid);
        system.debug('##des' + Des);

    public PageReference SelectResolution() {

        if (wrapid != null) {
            Update currentRecord;

        } else {

            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'You have not selected any resolution'));
            return null;

        PageReference pageRef = new PageReference('/' + currentCaseId);

        return pageRef;
    public string Back() {
        wrapid = null;

        return wrapid;


Currently if I click on any value then the second section "Resolution in Detail" is getting rendered but I click on view and then on back, I can see that selected radio button disappears but details are still there in the second section. I want that WrapId should be set to null and clicking Select Resolution should through a message that you have not selected any value.

Please let me know what is wrong in my code.Thanks in Advance !


1 Answer 1


Before going to the solutions I feel I have to explain apex:commandButtom:

apex:commandButton : is rendered as an HTML input element with the type attribute set to submit, reset, or image, depending on the tag's specified values. The button executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action.

CommandButtons in your code is default to Submit type. so If you will click on it, it will SUBMIT THE APEX:FORM WITH VALUES BIND TO APEX ELEMENTs ONLY to apex and will refresh the page. On Referesh you are going to LOST your selected radio button here as no binding and visualforce do not know your radio buttons.

You can use "reRender" attribute in you commandButton to make it an ajax call and stop page refresh. Specifying The ID of one or more components in this attribute will redrawn only those elements when the result of an AJAX update request returns to the client(As you are doing in back button). But still It does not care about your HTML inputs.

You are able to see values in second section with clicked radio button selected because you are not reRending first section("cases") in your actionSupport where you have the radio button. Somehow you have to set "Checked" attribute on the selected HTML radio to keep it selected.

One solution to this is, while creating your HTML radio button, Identify the selected WrapID in pageBlockTable and add HTML "checked" attribute to it only. You can do it as:

<apex:outputPanel rendered="{!wrap.name == wrapId}">
    <input type="radio" name="<strong>selectRadio</strong>" id="radio" checked="checked"></input>
<apex:outputPanel rendered="{!wrap.name != wrapId}">
    <input type="radio" name="<strong>selectRadio</strong>" id="radio">
        <apex:actionSupport event="onclick" action="{!getSelected}" rerender="show,cases">
            <apex:param name="wrapid" value="{!wrap.name}" />

Here in your actionSupport I have changed value for reRender attribute. I hope you got it why I did it. Your commandButtons will work perfectly with this.

Second solution to your problem is to stop your View commandButtons from Refreshing the page by returing false in your "onClick" javascript as:

<apex:commandButton Value="View" onclick="toggleDiv1() return false;" title="" />

I hope it make sense.

  • 4
    Could you please provide some explainations? Commented Sep 4, 2017 at 15:08
  • @MartinLezer - updated answer with some explanation. I hope it make sense. :) Commented Sep 5, 2017 at 8:26
  • @thatherahere Thank you for taking so much time and responding to it :)
    – user48539
    Commented Sep 5, 2017 at 12:06

You must log in to answer this question.

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