我想從一個託管bean傳遞一些參數到另一個。我看到了類似的問題並應用了他們的解決方案,但無效。下面是代碼:在託管bean之間傳遞參數
在我moneytransfer.xhtml文件:
<h:commandButton action="#{moneyTransferBean.transferAccounts()}" value="Continue">
<f:param name="sender" value="#{extTableSelectionBean.sender}" />
</h:commandButton>
我extTableSelectionBean:
@ManagedBean
@ViewScoped
public class ExtTableSelectionBean implements Serializable {
private Account sender;
public void setSender(Account sender){
this.sender=sender;
}
public Account getSender(){
return sender;
}
和moneyTransferBean:
@ManagedBean
@ViewScoped
public class MoneyTransferBean {
@ManagedProperty("#{extTableSelectionBean .sender}")
private Account sender;
//NO SETTER-GETTER FOR sender here
public void transferAccounts() throws IOException {
if (sender != null)
{
FacesContext.getCurrentInstance().getExternalContext().redirect("transferaccount.xhtml");
}
}
}
我看到,在extTableSelectionBean, 「發件人」已成功設置。問題是,當我到達moneyTransferBean時,發件人變爲空。我應該怎麼做,我做錯了什麼?
謝謝
謝謝你的答案 – yrazlik
歡迎您。 – erencan