java - Passing parameters between managed beans -


i trying pass parameters 1 managed bean another. saw similar question , applied solutions not work. here code:

in moneytransfer.xhtml file:

<h:commandbutton action="#{moneytransferbean.transferaccounts()}" value="continue">    <f:param name="sender" value="#{exttableselectionbean.sender}" /> </h:commandbutton> 

my exttableselectionbean:

@managedbean @viewscoped public class exttableselectionbean implements serializable {     private account sender;      public void setsender(account sender){         this.sender=sender;     }       public account getsender(){         return sender;     } 

and moneytransferbean:

@managedbean @viewscoped public class moneytransferbean {      @managedproperty("#{exttableselectionbean .sender}")      private account sender;      //no setter-getter sender here       public void transferaccounts() throws ioexception {                   if (sender != null)          {                facescontext.getcurrentinstance().getexternalcontext().redirect("transferaccount.xhtml");          }      } } 

i see in exttableselectionbean, "sender" succesfully set. problem is, when moneytransferbean, sender becomes null. should it, doing wrong?

thanks

two things mixed here. injecting bean bean , adding parameter commandbutton.

account sender tried inject moneytransferbean, there no action performed since there no getter setter, injection failed.

sender tried set through commandbutton send parameter, there no implementation it. @managedproperty annotation should changed reading parameter command button. assume sender set in place before submitting of commandbutton

@managedproperty(value="#{param.sender}") private account sender; 

there further methods send or set data in managed beans. please read balusc answer.

related post

https://stackoverflow.com/a/4994833/892994


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -