【问题标题】:command link reRender in salesforceSalesforce 中的命令链接重新渲染
【发布时间】:2012-06-15 11:22:57
【问题描述】:

我正在为 force.com 网站开发一个 visualforce 页面。我正在使用 apex 命令链接执行一些操作。代码如下:

    <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>

但不会使用类方法 processOnSelected()。它给出了js错误

actionUrl.indexOf 不是函数

下面是我的控制器方法代码:

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;
    }

}

这是给出错误的 JS 文件: http://invoicedetails.dev.cs16.force.com/faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript?rel=1339862070000

并且在这一行出现错误

var ask=actionUrl.indexOf('?')

我的代码有什么问题。请任何人帮助我。

【问题讨论】:

    标签: javascript ajax salesforce apex-code visualforce


    【解决方案1】:

    请发布 processOnSelected 方法的控制器代码。 我可以假设这个方法没有参数或者它是私有的。

    尝试改变

    public void processOnSelected() {
    ...
    }
    

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

    【讨论】:

    • 它仍然无法正常工作。那个 processOnSelected() 函数没有被调用,我已经在调试中检查了。
    • 即使没有参数? public PageReference processOnSelected()
    • 或者尝试使用&lt;apex:commandButton而不是&lt;apex:commandLink。我认为您以错误的方式使用&lt;apex:paramTry this link
    猜你喜欢
    • 2018-05-06
    • 2011-09-03
    • 2021-12-18
    • 2017-05-25
    • 2011-10-10
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 2021-12-28
    相关资源
    最近更新 更多