0

I have created a popup window against a command button in visualforce page. Now I want to perform an action for the same button in controller and showing the output in that popup. Now the problem is When I click on the button, the popup appears and vanishes after some time as the action function is executing in controller. Please help me. How can I fix the popup on the page. Please help me.

Here is my vf page:

<div class="col-xs-9 nopadding  pull-left text-left addAttachment hideOnClose" id="addBtnDiv1" style=' margin-top: 0px;  background-position: left 0px;'>
<input class="btn Frutiger55-13px btn-primary btn-cos" id="addBtnConfiden" type="button" value="Add Confidential Files(FTP)" style="margin-left: 32px;" action="{!getResponse}"/>
    </div>


<apex:form >
    <div id="ConfidentialFile" class="pop_container">
        <apex:outputText value="{!response}"/>
            </div>
        </apex:form>


        <script>
            $('#addBtnConfiden').click(
            function(e) {
                openAddConfidentialFile();
            }
        );

function openAddConfidentialFile(){
    fileList = '';
    $("#AttachmentTable").empty();
    $("#loading").hide();
    document.querySelector('#dropzone').value = '';
    $('#agreeCheck').prop('checked', false);
    attachmentList = [];
    $('#agreeError').css('display', 'none');
    $("#ConfidentialFile").dialog({
        autoOpen: false,
        modal: true,
        position: 'center',
        resizable: false,
        draggable: false,
        scrollable: true,
        cache: false,
        closeOnEscape: true,
        open: function(event, ui) {
            $('.ui-widget-overlay').bind('click', function() {
                $("#ConfidentialFile").dialog('close');
            });
        }

    });
    $('#ConfidentialFile').parent().addClass('attachFile-popup');
    $("#ConfidentialFile").dialog('open');
    $(document).scrollTop(0);
    return false;
}
</script>

My controller is:

public class COSCaseDetailController_Clone {
public HTTPResponse res{get; set;}
    public String resBody{get; set;}
    public String endpoint{get; set;}

    public String response{get; set;}
    public string pass{get; set;}

 public void getResponse()
     {
         /*-----Rest API call--------*/
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');                                    //Seting HttpRequest Method
        req.setTimeout(120000);
        req.setHeader('Accept', 'application/json');
        req.setEndpoint('https://cosprdapi.cadence.com/cdpaccess/Ldap_FolderUpload/CreateSearchUserServlet?uid=******&pwd=******');
        Http http = new Http();
        HTTPResponse res = http.send(req);                 // Executing web service call
        System.debug('STATUS:' + res.getStatus());
        System.debug('STATUS_CODE:' + res.getStatusCode());
        System.debug('::RESPONSE::'+res.getBody());
        System.debug(res.toString());
       // blob retFile = res.getBodyAsBlob();

        response = res.getBody();

     }
0

Instead of doing your way, You can do following way.

Write action function to call a controller method getResponse, when you click button instead of calling java function, call action function. it will execute first you controller method, Once execution is over, it is going call openAddConfidentialFile java-script function on complete of action function. No need explicit you have call those function. simply action function do for you.Your show model java-script function will call.

 // your code 
 <apex:form>
 <apex:actionFunction name="actionFunction" action="{!getResponse}" rerender="renderID" status="myStatus" oncomplete="openAddConfidentialFile();"/>
 <apex:actionStatus startText="Loading..."  stopText="" id="myStatus"/>

 // your code 

 <input class="btn Frutiger55-13px btn-primary btn-cos" id="addBtnConfiden" type="button" value="Add Confidential Files(FTP)" style="margin-left: 32px;" onClick="actionFunction();"/>
 </apex:form>

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.