0
votes

I am developing a visualforce page for force.com site. I am using apex command link for do some action. the code is given below:

    <ul>
    <li class="pill-none"><span>
            <apex:commandLink action="{!processOnSelected}" reRender="windowOpenPanel">Print
            <apex:param name="commandAtt" value="print"/>
            </apex:commandLink>
   </span>
   <apex:outputPanel id="windowOpenPanel">
    <apex:outputPanel rendered="{!isOpen}">
    <script type="text/javascript">
        window.open('http://invoicedetails.dev.cs16.force.com/EnterCode/InvoicePDF?invoiceId={!idString}');
    </script>
    </apex:outputPanel>
</apex:outputPanel>

</li></ul>

but is not going to class method processOnSelected(). It is giving js error

actionUrl.indexOf is not a function

below is my controller method code:

public void processOnSelected () {

    String command = Apexpages.currentPage().getParameters().get('commandAtt');
    idString = '';
    isOpen=true;
    Set<Id> selectedIdSet = new Set<Id>();
    if (command=='print' || command=='payment') {

        //wfdList = new List<WrapForDescription>();
        //System.debug('__wfdList__'+wfdList); 
        for(WrapForDescription tmpList : wfdList) {

           if(tmpList.checked) {
               //WrapForDescription selected = new WrapForDescription();
               //selected.wrapOpp = tmpList.wrapOpp;
               //wfdList.add(selected);
               selectedIdSet.add(tmpList.wrapOpp.Id);
               idString+= tmpList.wrapOpp.Id+',';
               //System.debug('__True__');
           }
        }
        idString = idString.substring(0, idString.length()-1);
    }
    else if (command=='onePDF') {

        idString = id;
    }

    Blob idBlob = Blob.valueOf(idString);
    idString = Encodingutil.base64Encode(idBlob);

    System.debug('__idString__'+idString);
    System.debug('__selectedIdSet__'+selectedIdSet);

    if (command=='payment') {

        page = 'beforePaymentAll';
        AggregateResult oppSumAmount = [select SUM(Amount) total from Opportunity where Id IN :selectedIdSet];
        //accObj = [select Name, convertCurrency(Unpaid_Opportunity_Amount__c), convertCurrency(Paid_Opportunity_Amount__c) from Account where Id =:accId];
        unpaid_amount = (Decimal)oppSumAmount.get('total');
        oppList = [Select Id, Name, convertCurrency(Opportunity.Amount), Opportunity.CloseDate, Opportunity.CurrencyIsoCode, Opportunity.SecretCode__c From Opportunity o where Id IN :selectedIdSet order by CloseDate desc];
        oppListSize = oppList.Size();
        System.debug('__oppLineList__'+oppList);
        isOpen=false;
    }

}

This is the JS file which is giving error: http://invoicedetails.dev.cs16.force.com/faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript?rel=1339862070000

and error is giving in this line

var ask=actionUrl.indexOf('?')

what is wrong in my code. anybody please help me.

1

1 Answers

1
votes

Please, post a controller code for processOnSelected method. I can assume that this method doesn't have params or it is private.

Try to change

public void processOnSelected() {
...
}

to

public PageReference processOnSelected(string commandAtt) {
...
return null;
}