VisualForce页面不显示记录列表或任何记录,但它可以显示列表大小

时间:2014-10-03 17:39:29

标签: salesforce visualforce controllers apex

VisualForce 页面没有显示记录列表 - 标题说明了一切。

如何让 VF 页面显示其显然正在计算的记录(因为它显示 1-15 7549 记录)。

看起来像这样:

http://i.imgur.com/KuChyJn.png - ' Wells '页

但是,这就是我们想要的样子(我们目前正在使用的那个!):

http://i.imgur.com/uwXOsHS.png - ' 调制解调器'页面(我把一些字段涂黑了,因为我们工作的公司可能不希望披露这些信息)

我的团队正在开发salesforce.com应用程序,我们有一个对象&#39; 调制解调器&#39;,其中包含大约 7,500 记录。< / p>

ModemController

我们已经创建了一个自定义控制器 ModemController

public class ModemController {

public apexpages.standardsetcontroller con {get;set;}
public Integer noOfRecords{get; set;}
public Integer size{get; set;}
public Modem__c modems {get; set;}

public List<Modem__c> AllSearchModems
{
    get
    {
        if (con!= null)
            return (List<Modem__c>)con.getRecords();
        else
            return null;
    }
    set;
}

public ModemController() {
    AllSearchModems = new List<Modem__c>();
    modems = new Modem__c();

    String Name = ApexPages.currentPage().getParameters().get('Name');
    List<Modem__c> modems = [SELECT Name FROM Modem__c WHERE ID= :Name];
}

public PageReference save()
{
    update modems;
    return new PageReference('/' + modems.Name);
}


public ApexPages.StandardSetController setCon {
    get{
        if(setCon == null){
            size = 15;
            string queryString = 'SELECT Name, ModemActive__c, ModemCarrier__c, ModemCarrierData__c, DataPlanName__c, ESNNumber__c, ModemICCID__c, IMEINumber__c, IMSINumber__c, ModemIPEXT__c, ModemJob__c, ModemManufacturer__c, ModemModel__c, ModemPhone__c, PortForwarding__c, ModemIPPort__c, SIMNumber__c, ModemIPSlave__c, ModemStaticIP__c, ModemFirmwareVersion__c FROM Modem__c ORDER BY Name';
            setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
            setCon.setPageSize(size);
            noOfRecords = setCon.getResultSize();
        }
        return setCon;
    }
    set;
}

public List<Modem__c> getModems()
{
    List<Modem__c> modemList = new List<Modem__c>();
    for(Modem__c w : (List<Modem__c>)setCon.getRecords())
       modemList.add(w);
    return modemList;
}

public PageReference refresh() {
    setCon = null;
    getModems();
    setCon.setPageNumber(1);
    return null;
}



public PageReference Search()
{
    if (modems.Name != null)
    {
        con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name, ModemActive__c,ModemCarrier__c,ModemCarrierData__c,DataPlanName__c,ESNNumber__c,ModemICCID__c, IMEINumber__c,IMSINumber__c,ModemIPEXT__c,ModemJob__c, ModemManufacturer__c,ModemModel__c,ModemPhone__c, PortForwarding__c, ModemIPPort__c,SIMNumber__c,ModemIPSlave__c,ModemStaticIP__c, ModemFirmwareVersion__c FROM Modem__c  Modem__c WHERE Name= :modems.Name]));  
        con.setPageSize(10);
    }
    else
    {
        con = null;
    }
    return null;
}

public Boolean hasNext {
    get {
        return setCon.getHasNext();
    }
    set;
}
public Boolean hasPrevious {
    get {
        return setCon.getHasPrevious();
    }
    set;
}

public Integer pageNumber {
    get {
        return setCon.getPageNumber();
    }
    set;
}

public void first() {
    setCon.first();
}

public void last() {
    setCon.last();
}

public void previous() {
    setCon.previous();
}

public void next() {
    setCon.next();
}
}

自定义 VF 页面&#39; Wells &#39;页

以下是&#39; Wells &#39;的自定义 visualforce 页面。页:

<apex:page controller="ModemController">
<apex:form >
    <apex:pageBlock id="pb">          
        <apex:pageBlockTable value="{!Modems}" var="m">    
            <apex:column value="{!m.Name}" />   
            <apex:column value="{!m.ModemManufacturer__c}"/>
            <apex:column value="{!m.ModemModel__c}"/> 
            <apex:column value="{!m.ModemICCID__c}"/> 
            <apex:column value="{!m.ModemIPEXT__c}"/>
            <apex:column value="{!m.ModemCarrier__c}"/>
            <apex:column value="{!m.ModemActive__c}"/>
        </apex:pageBlockTable>
         <apex:panelGrid columns="7">
            <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
            <apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
            <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
            <apex:outputPanel style="color:#4AA02C;font-weight:bold">
            <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
            </apex:outputPanel>
        </apex:panelGrid>           

    </apex:pageBlock>
</apex:form>

控制器适用于其他标签页(请参阅&#39; Wells &#39;页面,它使用相同的控制器,它可以正常工作!)但是不适用于&#39; 调制解调器&#39;页。

我们看到&#39; 调制解调器&#39;页面至少读取 7,549 记录(通过查看变量noOfRecords来计算有多少记录)但不显示它们。我甚至尝试将 LIMIT 添加到 SOQL 查询,但无济于事。 (限制为2,000,1999,1001,1000,999,甚至30,20和10)

我不认为记录的数量是问题,我可能是错的。

如果有人有任何提示,我们将不胜感激!

WellController

如果有人要求,这是&#39; Wells &#39;的工作代码。页面, VisualForce Apex 代码: WellController :     公共类WellController {

public apexpages.standardsetcontroller con {get;set;}
public Integer noOfRecords{get; set;}
public Integer size{get; set;}
public Well__c wellz {get; set;}

public List<Well__c> AllSearchWells
{
    get
    {
        if (con!= null)
            return (List<Well__c>)con.getRecords();
        else
            return null;
    }
    set;
}


public WellController() {
    AllSearchWells = new List<Well__c>();
    wellz = new Well__c();

    String Name = ApexPages.currentPage().getParameters().get('Name');
    List<Well__c> wellz = [SELECT Name FROM Well__c WHERE ID = :Name];
}

public PageReference save()
{
    update wellz;
    return new PageReference('/' + wellz.Name);
}


public ApexPages.StandardSetController setCon {
    get{
        if(setCon == null){
            size = 15;
            string queryString = 'SELECT Name, WellLocActivationDate__c, Active__c, AntennaType__c, WellLocBillTo__c, CompanyName__c, CompanyName_del__c, WellLocCompanyName__c, ConnectedCarrier__c, ContactReponsible__c, DataNetwork__c, WellLocSPOCDataPlan__c, WellSiteEquipHistory__c, WellLoclPD__c, WellLocKillDate__c, ModemConnectedTo__c, Name__c, WellLocModemSerial__c, SignalQuality__c, SignalStrength__c, SimCardNumber__c, TechResponsible__c, Action__c, ActionDate__c, WellLocName__c, WellLocOwningCompanyName__c FROM Well__c ORDER BY Name';
            setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
            setCon.setPageSize(size);
            noOfRecords = setCon.getResultSize();
        }
        return setCon;
    }
    set;
}

public List<Well__c> getWells()
{
    List<Well__c> wellList = new List<Well__c>();
    for(Well__c w : (List<Well__c>)setCon.getRecords())
        wellList.add(w);
    return wellList;
}

public PageReference refresh() {
    setCon = null;
    getWells();
    setCon.setPageNumber(1);
    return null;
}



public PageReference Search()
{
    if (wellz.Name != null)
    {
        con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name, WellLocActivationDate__c, Active__c, AntennaType__c, WellLocBillTo__c, CompanyName__c, CompanyName_del__c, WellLocCompanyName__c, ConnectedCarrier__c, ContactReponsible__c, DataNetwork__c, WellLocSPOCDataPlan__c, WellSiteEquipHistory__c, WellLoclPD__c, WellLocKillDate__c, ModemConnectedTo__c, Name__c, WellLocModemSerial__c, SignalQuality__c, SignalStrength__c, SimCardNumber__c, TechResponsible__c, Action__c, ActionDate__c, WellLocName__c, WellLocOwningCompanyName__c FROM Well__c  Well__c where Name = :wellz.Name]));  
        con.setPageSize(10);
    }
    else
    {
        con = null;
    }
    return null;
}

public Boolean hasNext {
    get {
        return setCon.getHasNext();
    }
    set;
}
public Boolean hasPrevious {
    get {
        return setCon.getHasPrevious();
    }
    set;
}

public Integer pageNumber {
    get {
        return setCon.getPageNumber();
    }
    set;
}

public PageReference make() 
{

  return Page.wellCreate;
}



public void first() {
    setCon.first();
}

public void last() {
    setCon.last();
}

public void previous() {
    setCon.previous();
}

public void next() {
    setCon.next();
}
}

VF 页面 - &#39; Wells &#39;

VisualForce 页面与&#39; Wells &#39;相关联对象:

<apex:page controller="WellController">
<apex:form >
    <apex:pageBlock title="Wells" id="pb">
        <apex:pageBlockSection >

        <apex:commandButton action="{!make}" value="Create New"/>

    </apex:pageBlockSection>
        <apex:pageBlockTable value="{!Wells}" var="w">
            <apex:column headerValue="Well Name">
                <apex:outputLink value="/apex/wellEdit?id={!w.id}">{!w.WellLocName__c}</apex:outputLink>
            </apex:column>
            <apex:column value="{!w.WellLocModemSerial__c}" />
            <apex:column value="{!w.WellLocCompanyName__c}" />
            <apex:column value="{!w.WellLocOwningCompanyName__c}" />
            <apex:column value="{!w.WellLocBillTo__c}" />
            <apex:column value="{!w.Active__c}" />
        </apex:pageBlockTable>
        <apex:panelGrid columns="7">
            <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
            <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
            <apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
            <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
            <apex:outputPanel style="color:#4AA02C;font-weight:bold">
            <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
            </apex:outputPanel>
        </apex:panelGrid>
    </apex:pageBlock>
</apex:form>

1 个答案:

答案 0 :(得分:0)

此处的问题可能是因为您登录的用户的个人资料无法访问Well__c对象上的任何字段。

使用<apex:outputField />绑定时,VF页面会强制执行字段级安全性,并会隐藏用户无权访问的字段。

如果您查看此对象的字段级安全性,我怀疑您会发现您的个人资料无法访问您在列中使用的任何字段。 Modem__c对象的安全性可能已正确设置为其字段。