【问题标题】:Client-side caching in JSF 1.2 / RichFaces 3.3.xJSF 1.2 / RichFaces 3.3.x 中的客户端缓存
【发布时间】:2011-12-01 14:43:56
【问题描述】:

我觉得这违背了 JSF 的一般范式,但我想我会问这是否可能。

我有一个正在呈现的<rich:dataTable>,并且对于每次迭代(行),都需要进行数据库查找以确定 bean 是否可编辑。问题是我需要知道 bean 在几个位置是否可编辑,让它成为 n

问题来了,我必须 n 重复调用数据库。

这让我问一个问题:是否可以在迭代期间缓存函数调用客户端的结果?

<rich:dataTable>
    <rich:column>
        <f:facet name="header">
        <h:outputText value="Name"/>
    </f:facet>
        <h:outputText value="#{bean.name}"/>
    </rich:column>
    <rich:column>
        <f:facet name="header">
        <h:outputText value="Editable"/>
    </f:facet>
        <!-- Cache the result of the 'isEditable' function call -->
        <h:outputText value="#{mylib:isEditable(bean) ? 'Yes' : 'No'}"/>
    </rich:column>
    <!-- More content which requires the editable value -->
</rich:dataTable>

非常感谢任何帮助。

【问题讨论】:

    标签: java jsf richfaces


    【解决方案1】:

    如果这个值在 bean 对象中可用,那么这可能适用:

        <h:outputText value="Yes" rendered="#{bean.isEditable=='YES'}" />
        <h:outputText value="No" rendered="#{bean.isEditable=='NO'}" />
    

    【讨论】:

      猜你喜欢
      • 2011-05-26
      • 2011-12-12
      • 2014-02-26
      • 2023-04-07
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多