You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mihir Solanki <mi...@patni.com> on 2005/04/06 15:53:14 UTC

passing arguments to backed bean methods

Hi all,

 

I  want to pass arguments to the backed bean method using JSF EL.

Can anyone tell me how can I do this?

 

Basically I have two list boxes in my page.

 

List Box: A

List Box: B

 

There are two managed beans I have configured in my faces context fie.

 

Bean: A

Bean: B

 

Now List Box A is being filled by one of the method of Bean A (this method
does not have any argument).

Now upon the change action on List Box A I have to fill up the List Box B
(as per the selected value of A).

I have created one method in Bean B which is taking an argument (basically
it would be selected value of List Box A).

 

So how can I pass selected value of List Box A to the method of Bean B?

 

Both the beans have scope equals to session.

 

Below is my JSF file looks like.

 

<h:form id="selectForm">

<h:selectOneListbox id="selectA" value="#{BeanA.ID}"
onchange="document.forms['selectForm'].submit() ;">

<f:selectItems value="#{BeanA.listA}" />

</h:selectOneListbox>

 

<h:selectOneListbox id="selectB" value="#{BeanB.ID}">

<f:selectItems value="#{BeanB.listB..????????}" />

</h:selectOneListbox>

</h:form>

 

Regards,

Mihir

  _____  

Patni Computer Systems Ltd.

Tel : 91 79 23240905 Ext : 413

 


http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail. 
_____________________________________________________________________

Re: passing arguments to backed bean methods

Posted by Heath Borders <he...@gmail.com>.
You could do that as well, but don't ValueChangeListeners always fire after 
the Process Validators phase runs, regardless of whether the Update Model 
Values Phase will run?

 On Apr 6, 2005 9:15 AM, Sean Schofield <se...@gmail.com> wrote: 
> 
> What about having BeanB be a ValueChangeListener for BeanA?
> 
> sean
> 
> 
> On Apr 6, 2005 10:06 AM, Heath Borders <he...@gmail.com> wrote:
> > Unfortunately, there is no way to pass arguments through the EL (well,
> > actually there is a way to pass String arguments into Map getters, but 
> that
> > can lead to extreme hacking). Your best bet is to pass an instance of 
> Bean
> > A to Bean B when Bean B is constructed (you can specify this in your
> > faces-config.xml), and then utilize Bean A's value from inside Bean B's
> > constructor.
> >
> >
> >
> > On Apr 6, 2005 8:53 AM, Mihir Solanki <mi...@patni.com> wrote:
> > >
> > >
> > >
> > > Hi all,
> > >
> > >
> > >
> > > I want to pass arguments to the backed bean method using JSF EL.
> > >
> > > Can anyone tell me how can I do this?
> > >
> > >
> > >
> > > Basically I have two list boxes in my page.
> > >
> > >
> > >
> > > List Box: A
> > >
> > > List Box: B
> > >
> > >
> > >
> > > There are two managed beans I have configured in my faces context fie.
> > >
> > >
> > >
> > > Bean: A
> > >
> > > Bean: B
> > >
> > >
> > >
> > > Now List Box A is being filled by one of the method of Bean A (this 
> method
> > does not have any argument).
> > >
> > > Now upon the change action on List Box A I have to fill up the List 
> Box B
> > (as per the selected value of A).
> > >
> > > I have created one method in Bean B which is taking an argument 
> (basically
> > it would be selected value of List Box A).
> > >
> > >
> > >
> > > So how can I pass selected value of List Box A to the method of Bean 
> B?
> > >
> > >
> > >
> > > Both the beans have scope equals to session.
> > >
> > >
> > >
> > > Below is my JSF file looks like…
> > >
> > >
> > >
> > > <h:form id="selectForm">
> > >
> > > <h:selectOneListbox id="selectA" value="#{BeanA.ID}"
> > onchange="document.forms['selectForm'].submit() ;">
> > >
> > > <f:selectItems value="#{BeanA.listA}" />
> > >
> > > </h:selectOneListbox>
> > >
> > >
> > >
> > > <h:selectOneListbox id="selectB" value="#{BeanB.ID}">
> > >
> > > <f:selectItems value="#{BeanB.listB….????????}" />
> > >
> > > </h:selectOneListbox>
> > >
> > > </h:form>
> > >
> > >
> > >
> > > Regards,
> > >
> > > Mihir
> > > ________________________________
> >
> > >
> > >
> > > Patni Computer Systems Ltd.
> > >
> > >
> > > Tel : 91 79 23240905 Ext : 413
> > >
> > >
> > > http://www.patni.com
> > > World-Wide Partnerships. World-Class Solutions.
> > >
> > _____________________________________________________________________
> > >
> > > This e-mail message may contain proprietary, confidential or legally
> > privileged information for the sole use of the person or entity to whom 
> this
> > message was originally addressed. Any review, e-transmission 
> dissemination
> > or other use of or taking of any action in reliance upon this 
> information by
> > persons or entities other than the intended recipient is prohibited. If 
> you
> > have received this e-mail in error kindly delete this e-mail from your
> > records. If it appears that this mail has been forwarded to you without
> > proper authority, please notify us immediately at netadmin@patni.com and
> > delete this mail.
> > >
> > _____________________________________________________________________
> >
> >
> >
> > --
> > -Heath Borders-Wing
> > hborders@mail.win.org
> 



-- 
-Heath Borders-Wing
hborders@mail.win.org

RE: passing arguments to backed bean methods

Posted by Mihir Solanki <mi...@patni.com>.
Sean,

Thanks for your suggestion.

I have implemented ValueChangeListner to my BeanA and now I am getting the
changes and basically storing the new value into the session. Doing this I
am now able access changed value to BeanB.

Now my further question is, can I explicitly fire the valueChangeEvent? 
If yes how? 

Because here what is happening is when my ListA is being populated I am
getting the first item in the list selected, but I did not get the event
fired so my session remains empty and hence I can not get that selected
value in Bean B.

Thanks & Regards,
Mihir

-----Original Message-----
From: Sean Schofield [mailto:sean.schofield@gmail.com] 
Sent: Wednesday, April 06, 2005 7:46 PM
To: MyFaces Discussion; hborders@mail.win.org
Subject: Re: passing arguments to backed bean methods

What about having BeanB be a ValueChangeListener for BeanA?

sean


On Apr 6, 2005 10:06 AM, Heath Borders <he...@gmail.com> wrote:
> Unfortunately, there is no way to pass arguments through the EL (well,
> actually there is a way to pass String arguments into Map getters, but
that
> can lead to extreme hacking).  Your best bet is to pass an instance of
Bean
> A to Bean B when Bean B is constructed (you can specify this in your
> faces-config.xml), and then utilize Bean A's value from inside Bean B's
> constructor.
> 
> 
>  
> On Apr 6, 2005 8:53 AM, Mihir Solanki <mi...@patni.com> wrote: 
> > 
> > 
> > 
> > Hi all, 
> > 
> >   
> > 
> > I  want to pass arguments to the backed bean method using JSF EL. 
> > 
> > Can anyone tell me how can I do this? 
> > 
> >   
> > 
> > Basically I have two list boxes in my page. 
> > 
> >   
> > 
> > List Box: A 
> > 
> > List Box: B 
> > 
> >   
> > 
> > There are two managed beans I have configured in my faces context fie. 
> > 
> >   
> > 
> > Bean: A 
> > 
> > Bean: B 
> > 
> >   
> > 
> > Now List Box A is being filled by one of the method of Bean A (this
method
> does not have any argument). 
> > 
> > Now upon the change action on List Box A I have to fill up the List Box
B
> (as per the selected value of A). 
> > 
> > I have created one method in Bean B which is taking an argument
(basically
> it would be selected value of List Box A). 
> > 
> >   
> > 
> > So how can I pass selected value of List Box A to the method of Bean B? 
> > 
> >   
> > 
> > Both the beans have scope equals to session. 
> > 
> >   
> > 
> > Below is my JSF file looks like. 
> > 
> >   
> > 
> > <h:form id="selectForm"> 
> > 
> > <h:selectOneListbox id="selectA" value="#{BeanA.ID}"
> onchange="document.forms['selectForm'].submit() ;"> 
> > 
> > <f:selectItems value="#{BeanA.listA}" /> 
> > 
> > </h:selectOneListbox> 
> > 
> >   
> > 
> > <h:selectOneListbox id="selectB" value="#{BeanB.ID}"> 
> > 
> > <f:selectItems value="#{BeanB.listB..????????}" /> 
> > 
> > </h:selectOneListbox> 
> > 
> > </h:form> 
> > 
> >   
> > 
> > Regards, 
> > 
> > Mihir 
> > ________________________________
>  
> > 
> > 
> > Patni Computer Systems Ltd. 
> > 
> > 
> > Tel : 91 79 23240905 Ext : 413 
> > 
> >  
> > http://www.patni.com
> > World-Wide Partnerships. World-Class Solutions. 
> >
> _____________________________________________________________________
> > 
> > This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to whom
this
> message was originally addressed. Any review, e-transmission dissemination
> or other use of or taking of any action in reliance upon this information
by
> persons or entities other than the intended recipient is prohibited. If
you
> have received this e-mail in error kindly delete this e-mail from your
> records. If it appears that this mail has been forwarded to you without
> proper authority, please notify us immediately at netadmin@patni.com and
> delete this mail. 
> >
> _____________________________________________________________________
> 
> 
> 
> -- 
> -Heath Borders-Wing
> hborders@mail.win.org



http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail. 
_____________________________________________________________________

Re: passing arguments to backed bean methods

Posted by Sean Schofield <se...@gmail.com>.
What about having BeanB be a ValueChangeListener for BeanA?

sean


On Apr 6, 2005 10:06 AM, Heath Borders <he...@gmail.com> wrote:
> Unfortunately, there is no way to pass arguments through the EL (well,
> actually there is a way to pass String arguments into Map getters, but that
> can lead to extreme hacking).  Your best bet is to pass an instance of Bean
> A to Bean B when Bean B is constructed (you can specify this in your
> faces-config.xml), and then utilize Bean A's value from inside Bean B's
> constructor.
> 
> 
>  
> On Apr 6, 2005 8:53 AM, Mihir Solanki <mi...@patni.com> wrote: 
> > 
> > 
> > 
> > Hi all, 
> > 
> >   
> > 
> > I  want to pass arguments to the backed bean method using JSF EL. 
> > 
> > Can anyone tell me how can I do this? 
> > 
> >   
> > 
> > Basically I have two list boxes in my page. 
> > 
> >   
> > 
> > List Box: A 
> > 
> > List Box: B 
> > 
> >   
> > 
> > There are two managed beans I have configured in my faces context fie. 
> > 
> >   
> > 
> > Bean: A 
> > 
> > Bean: B 
> > 
> >   
> > 
> > Now List Box A is being filled by one of the method of Bean A (this method
> does not have any argument). 
> > 
> > Now upon the change action on List Box A I have to fill up the List Box B
> (as per the selected value of A). 
> > 
> > I have created one method in Bean B which is taking an argument (basically
> it would be selected value of List Box A). 
> > 
> >   
> > 
> > So how can I pass selected value of List Box A to the method of Bean B? 
> > 
> >   
> > 
> > Both the beans have scope equals to session. 
> > 
> >   
> > 
> > Below is my JSF file looks like… 
> > 
> >   
> > 
> > <h:form id="selectForm"> 
> > 
> > <h:selectOneListbox id="selectA" value="#{BeanA.ID}"
> onchange="document.forms['selectForm'].submit() ;"> 
> > 
> > <f:selectItems value="#{BeanA.listA}" /> 
> > 
> > </h:selectOneListbox> 
> > 
> >   
> > 
> > <h:selectOneListbox id="selectB" value="#{BeanB.ID}"> 
> > 
> > <f:selectItems value="#{BeanB.listB….????????}" /> 
> > 
> > </h:selectOneListbox> 
> > 
> > </h:form> 
> > 
> >   
> > 
> > Regards, 
> > 
> > Mihir 
> > ________________________________
>  
> > 
> > 
> > Patni Computer Systems Ltd. 
> > 
> > 
> > Tel : 91 79 23240905 Ext : 413 
> > 
> >  
> > http://www.patni.com
> > World-Wide Partnerships. World-Class Solutions. 
> >
> _____________________________________________________________________
> > 
> > This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to whom this
> message was originally addressed. Any review, e-transmission dissemination
> or other use of or taking of any action in reliance upon this information by
> persons or entities other than the intended recipient is prohibited. If you
> have received this e-mail in error kindly delete this e-mail from your
> records. If it appears that this mail has been forwarded to you without
> proper authority, please notify us immediately at netadmin@patni.com and
> delete this mail. 
> >
> _____________________________________________________________________
> 
> 
> 
> -- 
> -Heath Borders-Wing
> hborders@mail.win.org

Re: passing arguments to backed bean methods

Posted by Heath Borders <he...@gmail.com>.
Unfortunately, there is no way to pass arguments through the EL (well, 
actually there is a way to pass String arguments into Map getters, but that 
can lead to extreme hacking). Your best bet is to pass an instance of Bean A 
to Bean B when Bean B is constructed (you can specify this in your 
faces-config.xml), and then utilize Bean A's value from inside Bean B's 
constructor.

On Apr 6, 2005 8:53 AM, Mihir Solanki <mi...@patni.com> wrote: 
> 
>  Hi all,
> 
>  I want to pass arguments to the backed bean method using JSF EL.
> 
> Can anyone tell me how can I do this?
> 
>  Basically I have two list boxes in my page.
> 
>  List Box: A
> 
> List Box: B
> 
>  There are two managed beans I have configured in my faces context fie.
> 
>  Bean: A
> 
> Bean: B
> 
>  Now List Box A is being filled by one of the method of Bean A (this 
> method does not have any argument).
> 
> Now upon the change action on List Box A I have to fill up the List Box B 
> (as per the selected value of A).
> 
> I have created one method in Bean B which is taking an argument (basically 
> it would be selected value of List Box A).
> 
>  So how can I pass selected value of List Box A to the method of Bean B?
> 
>  Both the beans have scope equals to session.
> 
>  Below is my JSF file looks like…
> 
>  <h:form id="selectForm">
> 
> <h:selectOneListbox id="selectA" value="#{BeanA.ID}" onchange="
> document.forms['selectForm'].submit() ;">
> 
> <f:selectItems value="#{BeanA.listA}" />
> 
> </h:selectOneListbox>
> 
>  <h:selectOneListbox id="selectB" value="#{BeanB.ID}">
> 
> <f:selectItems value="*#{BeanB.listB….????????}*" />
> 
> </h:selectOneListbox>
> 
> </h:form>
> 
>  Regards,
> 
> Mihir
>  ------------------------------
>  
> *Patni Computer Systems Ltd.*
>  
> *Tel** **:** 91 79 23240905 **Ext** **:** 413*
> 
> 
> http://www.patni.com
> World-Wide Partnerships. World-Class Solutions. 
> _____________________________________________________________________ 
> 
> This e-mail message may contain proprietary, confidential or legally 
> privileged information for the sole use of the person or entity to whom this 
> message was originally addressed. Any review, e-transmission dissemination 
> or other use of or taking of any action in reliance upon this information by 
> persons or entities other than the intended recipient is prohibited. If you 
> have received this e-mail in error kindly delete this e-mail from your 
> records. If it appears that this mail has been forwarded to you without 
> proper authority, please notify us immediately at netadmin@patni.com and 
> delete this mail. 
> _____________________________________________________________________ 




-- 
-Heath Borders-Wing
hborders@mail.win.org