Flex/LCDS服务器对数据源的分页

39
我正在尝试设置一个服务器来作为分页服务的数据源。我已经将所有内容都设置好了,以至于我的汇编程序被调用并且返回值,但是我没有收到“分页”调用。
具体来说:
public Collection fill(List fillArgs, int begin, int rows)

始终使用 begin == -1rows == -1 调用,而不是获取真实值进行分页。此外:

public boolean useFillPage(List fillParameters)

我的实现总是对所有参数返回true,这个方法从未被调用。看起来它从未被调用是因为JavaAdapter没有从Flex客户端接收到pageSize标头。

这是我的目标配置:

<destination id="invoiceListDataService">
  <adapter ref="java-dao" />
  <properties>
    <scope>session</scope>
    <source>com.williams.finance.invoice.dao.InvoiceReviewListAssembler</source>
    <network>
      <paging enabled="true" pageSize="100" />
    </network>
    <metadata>
      <identity property="invoiceNumber"/>
    </metadata>
  </properties>
</destination>

我调用数据服务的 Flex 代码:

myDataService = new DataService("invoiceListDataService");
myDataService.autoSyncEnabled=false;
myDataService.fill(invoiceReviewListModel.invoiceList, params);

我有什么遗漏吗?有什么建议可以开始查找吗?


我会首先查看那个 params 变量。它应该是一个包含“begin”和“rows”信息的实例吗?也许您的 flex DataService 忽略了该参数。 - bug-a-lot
1
@Travis,你之前问过这个问题。你找到解决方法了吗?顺便说一句:我强烈推荐使用Charles Proxy来满足你的网络调试需求。它是一个非常好用的调试工具,可以帮助你找出Flex和服务器之间实际发送和接收的内容。 - Jacob Eggers
2个回答

1

您的目标配置看起来是完整的。

请确保您的汇编程序扩展自AbstractAssembler:

public class InvoiceReviewListAssembler extends AbstractAssembler 

并且您至少需要覆盖以下内容:

@Override
public int count(List arg0) {
    return -1; // or return the collection length.
}

@Override
public boolean useFillPage(List fillParameters) {       
    return true;
}

@Override
public Collection fill(List fillParameters,
                       PropertySpecifier ps,
                       int startIndex,
                       int numItems) {
   // TODO
}

1

首先,你的适配器定义是什么?尝试这个:

<adapters>
    <adapter-definition class="flex.data.adapters.JavaAdapter" 
        id="java-dao"></adapter-definition>
</adapters>

其次,在您的分页(paging)属性中添加custom="true"属性。

<paging enabled="true" pageSize="100" custom="true"/> 

第三步,可能需要将您的范围更改为应用程序
第四步,在目标定义中,添加adapter="java-dao"而不是引用它。
<destination adapter="java-dao"  id="invoiceListDataService">

第五步,确保您覆盖了必要的方法(使用useFillPage、Collection fill等)。

@Override
public boolean useFillPage(List fillParameters)
{
    // enabling paged-fill for all fills
    return true;
}

看看这个帖子,它对类似问题给出了一些有用的回复: http://www.mail-archive.com/flexcoders@yahoogroups.com/msg111746.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接