JSF不会在弹出窗口中调用getter方法

JSF不会在弹出窗口中调用getter方法,jsf,popup,getter,Jsf,Popup,Getter,我有一个普通的datatable,包含编辑按钮,可以打开一个弹出窗口 <h:form id="creditcard_configuration_form"> <rich:dataTable id="test" width="100%" value="#{creditcardConfigurationService.cardsList}" iterationStatusVar="it" var="card"> <rich:column&g

我有一个普通的datatable,包含编辑按钮,可以打开一个弹出窗口

 <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方法来获取a4j:param的索引,至少现在不会了。我发现,在呈现页面时会调用getter方法,但之后就不会调用了。意味着,对于弹出窗口,索引始终显示为0


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

您的问题有点让人困惑,因此我正在证明这两种解决方案,我预测这两种解决方案可以解决您的问题

答复1: 首先是指这个 这里是代码

正如您所看到的,您需要在这里使用rep呈现任何组件,其中name变量的getter setter在请求范围内的page submit param值集上被调用,而不是调用getter setter,它在页面加载时只调用getter

2: 首先检查您的数据与数据库中所有参数数据的0不同,您可以使用在参数中使用的值为{it.index}的按钮后放置一个outputtext进行检查。
还有一个预测,如示例所示,使用commandButton更改commandLink,然后重试。这可能会起作用。

很好,但这不会改变任何东西。哦!index var的意思是{it.index},它在param标记中,对吗?我预测你会谈论一些你放在popuppanel.Yep中的元素,索引var的值是{it.index},它在bean中被称为currentIndex,如你所见。我在popupPanel中有一些输入元素和按钮,但这并不重要,因为如果popupPanel是空的,它甚至不起作用,就像我在上面发布的示例中一样。所以在这种情况下,你可以在commandLink中使用action或actionlistner并从中获取索引值。哈哈,太愚蠢了。感谢您解决了此问题第一个解决方案解决了此问题:
<!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>