How to pass parameter value a4j: jsFunction

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

This is my code:

page 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> 

And this is the bean support 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; } 

When selected from a popup menu, the method in my backingbean is called, but newGuarantorId is null and setNewGuarantorId never called.

Is there a solution to my problem?

+6
source share
3 answers

Hmm .. this is strange, nothing looks wrong. Not the answer to your question, but try this workaround - instead of setting the value to GuarantorId, save the parameter as <a4j:param name="param1"/> and in the actionListener method select this parameter1 from the request as String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().โ€Œโ€‹get("param1"); . And then convert this parameter to int and use it further. This should work

+5
source

Try switching from actionListener to action :

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

It is recommended to read here : a4j: jsFunction

+3
source

I think you can try the following:

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

And in a managed bean, define the setNewGuarantor method as follows:

 public void setNewGuarantor(int newGuarantorId) { guarantor = newGuarantorId; } 
+1
source

Source: https://habr.com/ru/post/904910/


All Articles