如何通过一个参数值A4J:jsFunction [英] How to pass a parameter value to a4j:jsFunction

查看:916
本文介绍了如何通过一个参数值A4J:jsFunction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网页我有在打开一个弹出的项目列表的按钮。当我在列表中选择1个项目,我要项目的ID传递给我的第一页的backingbean。可能吗?它试图用 A4J做到这一点:jsFunction A4J:参数,但一点儿也不工作。

On my page I have a button that opens a list of items in a popup. When I select 1 item in the list, I want to pass the id of the item to the backingbean of my first page. Is it possible? It tried to do it with a4j:jsFunction and a4j:param but it does'nt work.

这是我的code:

第1页:

<a4j:jsFunction name="renderGuarantor" render="guarantor" actionListener="#{prospectDetail.setNewGuarantor}">
  <a4j:param name="param1" assignTo="#{prospectDetail.newGuarantorId}" />  
</a4j:jsFunction>

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>

这是支持bean code为第一页

And this is the backing bean code for the first page

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

public Integer getNewGuarantorId() {
    return newGuarantorId;
}

public void setNewGuarantorId(Integer newGuarantorId) {
    this.newGuarantorId = newGuarantorId;
}

在弹出的选择当我backingbean调用该方法,但 newGuarantorId 为空和 setNewGuarantorId 从不调用。

有没有解决我的问题?

推荐答案

嗯..那奇怪的,没有什么看起来wrong..Not解答您的问题,但尝试这种解决办法 - 而不是它们的值赋给guarantorId,保持参数为&LT; A4J:参数名称=参数1/&GT; 的ActionListener 方法检索此参数1从要求为字符串参数1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().‌​get("param1");. 然后转换这个参数为int,并进一步利用它。这应该工作

Hmm.. thats strange, nothing looks wrong..Not an answer to your question but try this workaround - instead of assigning the value to guarantorId, keep the param as <a4j:param name="param1"/> and in the actionListener method retrieve this param1 from the request as String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().‌​get("param1");. And then convert this param to int and utilize it further. That should work

这篇关于如何通过一个参数值A4J:jsFunction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆