我有一個頭問題,我似乎無法找到解決方案。在報告循環中傳遞的Salesforce/Apex參數
我做了VisualForce頁面作爲客戶端的PDF,這基本上是一個整齊的格式的報告,沒有輸入文本框等,以及我無法訪問某些數據 - 即附件。
附件通常是機會的一部分,然而,這是一個相當個性化設置,以便我們有什麼是掛了存儲數據的機遇表中的兩個自定義對象。我已經從圖像附件中檢索了所有常規數據。
基本上機會有一個自定義對象SFDC_520_Quote__c客戶端調用一個'房間',每個房間然後有一個選擇SFDC_520_QuoteLine__c對象連接到它有產品等的鏈接,我可以做。
但是,附在這個'房間'級別的圖像被賦予SFDC_520_Quote__c.id字段的ParentID,這使得我很難一起獲取SOQL語句來讀取數據,因爲在SFDC_520_Quote__c之間沒有定義的關係和附件。
我知道我可以添加一個字段,但我不知道我會如何提供給我的時間更新現有的數據,因爲我從別人留下回升。
我在visualforce頁面中需要做的是在重複循環中傳遞一個參數給控制器類,然後調用另一個可以對其執行操作的getter,但是我在控制器端設置變量時遇到了問題。
例(重截斷):
<apex:page renderAs="pdf" standardController="Opportunity" extensions="myController">
<apex:repeat value="{!allRooms}" var="room">
<h1>{!room.Name}</h1>
<apex:repeat value="{!room.QuoteLines__r}" var="ql">
<p>{!ql.Product2__r.Name}: {!ql.Product2__r.Description} - {!ql.Description__c}</p>
</apex:repeat>
</apex:repeat>
</apex:page>
我的控制器:
public class myController {
public List<SFDC_520_Quote__c> getAllRooms() {
List<SFDC_520_Quote__c> roomWithQuoteList = [select id, Name, Quote_Amount__c, Quote__c,
(select Item_Order__c, Product2__r.ProductCode, Product2__r.Name, Product2__r.Description, Description__c from QuoteLines__r order by Item_Order__c)
from SFDC_520_Quote__c where Opportunity__c =: ApexPages.currentPage().getParameters().get('id')];
return roomWithQuoteList;
}
}
以上工作正常,但之後的第一個內我需要的附件。附件基於room.id,因此理想情況下,我需要將room.id傳遞給getAttachments之類的某個getter,但不能將參數傳遞給visualforce中的getter。
因此,它可能看起來像:
<apex:page renderAs="pdf" standardController="Opportunity" extensions="myController">
<apex:repeat value="{!allRooms}" var="room">
--> something to call a setter with value from {!room.id} <--
<h1>{!room.Name}</h1>
<apex:repeat value="{!room.QuoteLines__r}" var="ql">
<p>{!ql.Product2__r.Name}: {!ql.Product2__r.Description} - {!ql.Description__c}</p>
</apex:repeat>
<apex:repeat value="{!allAttachments}" var="attachment">
<apex:image height="200px" value="{!URLFOR($Action.Attachment.Download, attachment.Id)}"/>
</apex:repeat>
</apex:repeat>
</apex:page>
,然後加入到控制器:
private String oppParentID;
public void setParentID(string theID) {
oppParentID = theID;
}
public List<Attachment> getAllAttachments() {
List<Attachment> theAttachments = [select Id, Name, ContentType, .... from Attachment where parentiD =: oppParentID];
return theAttachments;
}
也就是說,還是有辦法)來修改我原來getAllRooms(方法做上述在一次去,沒有關係領域,我無法弄清楚如何做一個WHERE編譯正確的子選擇。
我見過大量的例子,都談論使用查詢字符串參數,但沒有形式參與,沒有刷新,只是一個VF頁面的調用。
請幫忙。
更新:它被認爲是唯一的方法來做到這一點_may_可以與一個頂點componen Ť – JamesB 2012-04-04 17:39:53