我有一个标准的查找字段的一个问题。 当我试图挽救它,它有null值当我使用自动完成或只需键入名字,但它的工作原理,当我点击查找图标使用查找弹出。
这是(部分)的代码。 (不是所有的,但即使是这样简单的控制器和页面无法正常工作......)控制器:
public with sharing class UnresolvedItemsController {
public list<TaskItem> myUnresolvedTaskItems {get;set;}
public class TaskItem {
public string taskId {get;set;}
public string subject {get;set;}
public datetime createdDate {get;set;}
public DummyObject__c dumObj {get;set;}
}
public UnresolvedItemsController(ApexPages.Standardcontroller controller) {
if (myUnresolvedTaskItems==null) {
myUnresolvedTaskItems = new list<TaskItem>();
list<Task> myUnresolvedTasks = [select id,subject,createdDate,Description from Task Where Status='Not Started' and isDeleted=false and isClosed=false and isArchived=false and OwnerId=:UserInfo.getUserId() and subject like 'Unresolved Email:%' limit 10];
TaskItem tmp = new TaskItem();
for (task myT:myUnresolvedTasks) {
myUnresolvedTaskItems.add(getInfoFromTask(myT));
}
}
}
public TaskItem getInfoFromTask(Task myTask) {
TaskItem returnTaskItem = new TaskItem();
returnTaskItem.subject = myTask.Subject.replace('Unresolved Email: ','');
returnTaskItem.createdDate = myTask.createdDate;
returnTaskItem.taskId = myTask.Id;
returnTaskItem.dumObj = new DummyObject__c();
return returnTaskItem;
}
public pagereference save() {
system.debug('1-----'+myUnresolvedTaskItems);
return null;
}
}
视图:
<apex:page standardcontroller="Task" extensions="UnresolvedItemsController">
<apex:form >
<apex:pageblock >
<apex:pageblockbuttons >
<apex:commandbutton action="{!Save}" value="{!$Label.Save}" />
<apex:commandbutton action="{!Cancel}" value="{!$Label.Cancel}" />
</apex:pageblockbuttons>
<apex:pageblocktable value="{!myUnresolvedTaskItems}" var="ti">
<apex:column >
<apex:facet name="header">Subject</apex:facet>
<a href="/{!ti.taskId}">{!ti.subject}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Date</apex:facet>
{!ti.createdDate}
</apex:column>
<apex:column >
<apex:facet name="header">Assign to salesforce.com objects</apex:facet>
<apex:inputfield value="{!ti.dumObj.Contact__c}" />
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>
该dummyObject是有几个查找字段的对象。 (Contact_ C到联系,账户 1c至账户,等...)
我不实际保存它。 但是,当你system.debug它不应该是空 ...