没有页面重定向的命令链接

问题描述:

我想单击一个图像(commandLink),它重定向到一个控制器,计算点击次数并更新对象中的一个字段返回我不希望重定向页面,但弹出窗口应该出现让用户从文档下载文件。没有页面重定向的命令链接

这是我的代码。有人可以告诉我如何获得输出链接工作..但我的柜台工作正常。

<apex:pageBlockTable value="{!Docs}" var="d" rendered="{!if(Docs.size>0,true,false)}"> 

<apex:column >     
<apex:commandLink action="{!incrementCounter}"> 
<apex:image url="{!URLFOR($Resource.LibraryImages)}" title="Click to Download" /> 
<apex:param assignTo="{!SelectedId}" name="selId" value="{!d.Id}"/> 
<apex:outputLink value="/servlet/servlet.FileDownload?file={!d.Document_Id__c}"/>    
</apex:commandLink> 
</apex:column> 

<apex:column headerValue="Downloaded" > 
    <apex:outputText value="{!d.Counter__c}" /> 
    </apex:column> 

</apex:pageBlockTable> 

------------------------------------------- 

public pagereference incrementCounter() 
    { 

UpdateCount = [select id, counter__c from Document_Details__c where id =:SelectedId]; 

    Decimal num= updatecount.counter__c; 
    updatecount.counter__c=num+1; 
    update updatecount; 

Docs.clear(); 
    // to get the updated values from the object 

Docs=[Select id, Name__c, Document_Id__c,  counter__c,Uploaded_by__c,Type__c,Description__c,Document_Created_On__c,My_Library__c From 

Document_Details__c where My_Library__c=: MyLib.id]; 


return null; 

} 

我试图用outputLink的,行动的支持和重新呈现局部刷新页面,但没有工作,所以我想到了用commandlink的。

元素如<apex:actionStatus><apex:commandLink>有您可以利用执行这种事情JavaScript事件,所以我会做这样的事情在你的页面如下:

<apex:commandLink action="{!incrementCounter}" 
    oncomplete="window.open('/servlet/servlet.FileDownload?file={!d.Document_Id__c}');"> 
    <apex:image url="{!URLFOR($Resource.LibraryImages)}" title="Click to Download" /> 
    <apex:param assignTo="{!SelectedId}" name="selId" value="{!d.Id}"/> 
</apex:commandLink> 

这样,你打电话给你的方法增加计数器,一旦完成,按需要在新窗口中打开文档。