You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madhav Bhargava <Ma...@infosys.com> on 2006/12/21 16:20:20 UTC

Bind a custom component with an action method of a model bean of the component

Hi All,



I am in the process of developing a custom component. The component will
have the following:



1.	Name of the currently logged in user - HtmlOutputText
2.	Drop down containing all the roles that the user plays -
HtmlSelectOneMenu
3.	Command button along with the drop down which will enable the
user to change the role - HtmlCommandButton



I have created a model bean for this component which will contain the
following:



1.	Name of the user
2.	selected role
3.	role collection



When the user clicks on the command button after changing the role then
I need it to be handled within the component which will then change some
session parameters and cause the entire screen to refresh with the
changed view.



How do I define and bind the action method to the HtmlCommandButton
component that I have as a child of this custom component?



Any help will be appreciated!



Rgds,

Madhav



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Re: Bind a custom component with an action method of a model bean of the component

Posted by Madhav Bhargava <un...@gmail.com>.
Thanks for your comments.

The problem was that i was having two command buttons in the custom
component. That made me think of how to handle multiple actions out of a
component.

For now i have removed one command button and now things are a lot more
simpler. I have done the following:

1. In the Tag class i have defined action and actionListener properties.
Also in setProperties i have bound them to the component
2. I have made the component class implement ActionSource and i have
provided implementation for all the methods.

So now things are working. But i am still wondering how one can manage 2
actions out of a single component

Any pointers will be appreciated.

Rgds,
Madhav

On 12/23/06, Andrew Robinson <an...@gmail.com> wrote:
>
> Something like:
>
> button.setAction(
> FacesContext.currentInstance().getApplication().createMethodBinding("#{
> yourBean.changeRole}"))
>
> On 12/21/06, Madhav Bhargava <Ma...@infosys.com> wrote:
> >
> >  Hi All,
> >
> >
> >
> > I am in the process of developing a custom component. The component will
> > have the following:
> >
> >
> >
> >    1. Name of the currently logged in user - HtmlOutputText
> >    2. Drop down containing all the roles that the user plays -
> >    HtmlSelectOneMenu
> >    3. Command button along with the drop down which will enable the
> >    user to change the role - HtmlCommandButton
> >
> >
> >
> > I have created a model bean for this component which will contain the
> > following:
> >
> >
> >
> >    1. Name of the user
> >    2. selected role
> >    3. role collection
> >
> >
> >
> > When the user clicks on the command button after changing the role then
> > I need it to be handled within the component which will then change some
> > session parameters and cause the entire screen to refresh with the changed
> > view.
> >
> >
> >
> > How do I define and bind the action method to the HtmlCommandButton
> > component that I have as a child of this custom component?
> >
> >
> >
> > Any help will be appreciated!
> >
> >
> >
> > Rgds,
> >
> > Madhav
> >  **************** CAUTION - Disclaimer *****************
> > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> > solely for the use of the addressee(s). If you are not the intended
> > recipient, please notify the sender by e-mail and delete the original
> > message. Further, you are not to copy, disclose, or distribute this e-mail
> > or its contents to any other person and any such actions are unlawful. This
> > e-mail may contain viruses. Infosys has taken every reasonable precaution to
> > minimize this risk, but is not liable for any damage you may sustain as a
> > result of any virus in this e-mail. You should carry out your own virus
> > checks before opening the e-mail or attachment. Infosys reserves the right
> > to monitor and review the content of all messages sent to or from this
> > e-mail address. Messages sent to or from this e-mail address may be stored
> > on the Infosys e-mail system.
> > ***INFOSYS******** End of Disclaimer ********INFOSYS***
> >
>
>


-- 
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do

Re: Bind a custom component with an action method of a model bean of the component

Posted by Andrew Robinson <an...@gmail.com>.
Something like:

button.setAction(
FacesContext.currentInstance().getApplication().createMethodBinding("#{
yourBean.changeRole}"))

On 12/21/06, Madhav Bhargava <Ma...@infosys.com> wrote:
>
>  Hi All,
>
>
>
> I am in the process of developing a custom component. The component will
> have the following:
>
>
>
>    1. Name of the currently logged in user - HtmlOutputText
>    2. Drop down containing all the roles that the user plays -
>    HtmlSelectOneMenu
>    3. Command button along with the drop down which will enable the
>    user to change the role - HtmlCommandButton
>
>
>
> I have created a model bean for this component which will contain the
> following:
>
>
>
>    1. Name of the user
>    2. selected role
>    3. role collection
>
>
>
> When the user clicks on the command button after changing the role then I
> need it to be handled within the component which will then change some
> session parameters and cause the entire screen to refresh with the changed
> view.
>
>
>
> How do I define and bind the action method to the HtmlCommandButton
> component that I have as a child of this custom component?
>
>
>
> Any help will be appreciated!
>
>
>
> Rgds,
>
> Madhav
>  **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely for the use of the addressee(s). If you are not the intended
> recipient, please notify the sender by e-mail and delete the original
> message. Further, you are not to copy, disclose, or distribute this e-mail
> or its contents to any other person and any such actions are unlawful. This
> e-mail may contain viruses. Infosys has taken every reasonable precaution to
> minimize this risk, but is not liable for any damage you may sustain as a
> result of any virus in this e-mail. You should carry out your own virus
> checks before opening the e-mail or attachment. Infosys reserves the right
> to monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be stored
> on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>