如何将参数值传递给a4j:jsFunction

roe*_*oel 6 ajax jsf richfaces ajax4jsf jsf-2

在我的页面上,我有一个按钮,用于打开弹出窗口中的项目列表.当我在列表中选择1项时,我想将项目的ID传递给我的第一页的后台.可能吗?它试图用它做a4j:jsFunction,a4j:param但它不起作用.

这是我的代码:

第1页:

<a4j:jsFunction name="renderGuarantor" render="guarantor" actionListener="#{prospectDetail.setNewGuarantor}">
  <a4j:param name="param1" assignTo="#{prospectDetail.newGuarantorId}" />  
</a4j:jsFunction>
Run Code Online (Sandbox Code Playgroud)

popuppage:

<h:outputLink value="" onclick="window.opener.renderGuarantor(#{applicant.deposit_id});window.close();">
  <h:graphicImage style="padding:0 1px; border:0"  value="${path.staticRootUrl}images/confirm.gif"  alt="${msg.applicantslist_select}" title="${msg.applicantslist_select}"/>
</h:outputLink>
Run Code Online (Sandbox Code Playgroud)

这是第一页的支持bean代码

private Integer newGuarantorId;
public void setNewGuarantor()  {
    guarantor = newGuarantorId;
}

public Integer getNewGuarantorId() {
    return newGuarantorId;
}

public void setNewGuarantorId(Integer newGuarantorId) {
    this.newGuarantorId = newGuarantorId;
}
Run Code Online (Sandbox Code Playgroud)

在弹出窗口中选择时,我的backingbean中的方法被调用,但是newGuarantorId为null并且setNewGuarantorId从不被调用.

我的问题有解决方案吗?

Nik*_*hil 5

嗯..这很奇怪,没有什么看起来有问题.没有回答你的问题,但尝试这个解决方法 - 而不是将值分配给guarantorId,保持param as <a4j:param name="param1"/>和在actionListener方法中从请求中检索此param1 String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().??get("param1");.然后将此参数转换为int并进一步利用它.这应该工作