1
我想單擊一個圖像(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的。