1

我有一个普通的数据表,其中包含编辑按钮,它会打开一个弹出窗口。

 <h:form id="creditcard_configuration_form">
  <rich:dataTable id="test" width="100%"
    value="#{creditcardConfigurationService.cardsList}"
    iterationStatusVar="it" var="card">
    <rich:column>
      <a4j:commandLink execute="@this" ajaxSingle="true"
        oncomplete="#{rich:component('test123')}.show()">
        <h:graphicImage value="../../resources/images/edit.gif"
          alt="edit" />
        <a4j:param value="#{it.index}"
          assignTo="#{creditcardConfigurationAction.currentIndex}" />
      </a4j:commandLink>
    </rich:column>
  </rich:dataTable>

  <rich:popupPanel id="test123"
    header="#{creditcardConfigurationAction.currentIndex}"
    onmaskclick="#{rich:component('test123')}.hide()">
        asdf
  </rich:popupPanel>
</h:form>

在打开弹出窗口之前,我在我的 bean 中设置了一个索引变量。但是,JSF 在打开弹出窗口时不会调用 getter 方法来获取indexof a4j:param(或者至少现在不会了)。我发现,在呈现页面时调用了 getter-method,但在那之后就再也没有了。(意味着,对于弹出窗口,索引始终显示为 0)。

包含索引 var 的 bean 是视图范围的,而服务 bean 是会话范围的。我正在使用最新版本的 RichFaces (4.3.2 Final) 和 JSF 2.0.6。

4

1 回答 1

0

你的问题有点令人困惑,所以我证明了我预测为你的问题的解决方案的两个解决方案,

答案1:
首先参考这个richfaces show case的链接,
这里有demo它的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <h:form>
        <rich:panel>
            <h:panelGrid columns="2">
                <a4j:commandButton value="Set Name to Alex" render="rep">
                    <a4j:param value="Alex" assignTo="#{userBean.name}" />
                </a4j:commandButton>

                <a4j:commandButton value="Set Name to John" render="rep">
                    <a4j:param value="John" assignTo="#{userBean.name}" />
                </a4j:commandButton>
            </h:panelGrid>
        </rich:panel>
        <br />
        <rich:panel>
            <h:outputText id="rep" value="Selected Name:#{userBean.name}" />
        </rich:panel>
    </h:form>
</ui:composition>

如您所见,您需要render任何组件(此处使用rep),其中name调用了变量的 getter setter(在请求范围内设置的页面提交参数值不调用 getter-setter,它仅在页面加载时调用 getter)。

2:
首先检查您的数据是否与0数据库中的所有参数数据不同,您可以在使用 in时将其放在outputtext后面button的值进行检查。 还有一个预测,如示例所示更改您的,然后重试它可能会起作用。#{it.index}param
commandLinkcommandButton

于 2013-06-26T11:42:06.770 回答