You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by kevin_zhai <ja...@gmail.com> on 2006/11/13 01:49:56 UTC

help,use t:commandButton pass some parameter to back bean

hi expert:
            If I use t:commandButton pass some parameter to back bean
excepte use t:inputHidden,
    can I use some other method implements?
    I try use f:attribute,but it's not support EL expression.

thanks
-- 
View this message in context: http://www.nabble.com/help%2Cuse-t%3AcommandButton-pass-some-parameter-to-back-bean-tf2619256.html#a7309750
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: help,use t:commandButton pass some parameter to back bean

Posted by Gerald Müllan <bi...@gmail.com>.
Yes this is a probably other way, but you have to invest little bit more work.

Under the hood updateActionListener works something like this but is
more convenient.

cheers,

Gerald

On 11/13/06, Richard Capraro <ri...@gmail.com> wrote:
> Hello Kevin,
> maybe you could use the "param" tag, like this
>
>  <h:commandButton id="validate" action="#{userAction.validateUser}">
>   <h:outputText value="#{msg.validate}"/>
>   <f:param name="id" value="#{user.id}"/>
> </h:commandLink>
>
> To get the parameter "id" in your bean, use:
>
> FacesContext context = FacesContext.getCurrentInstance();
> Map map = context.getExternalContext().getRequestParameterMap();
> String employeeID = (String) map.get("id");
>
> Hope it helps you,
>
> Regards,
> Richard Capraro
>
> 2006/11/13, kevin_zhai <ja...@gmail.com>:
> >
> > hi expert:
> >            If I use t:commandButton pass some parameter to back bean
> > excepte use t:inputHidden,
> >    can I use some other method implements?
> >    I try use f:attribute,but it's not support EL expression.
> >
> > thanks
> > --
> > View this message in context: http://www.nabble.com/help%2Cuse-t%3AcommandButton-pass-some-parameter-to-back-bean-tf2619256.html#a7309750
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: help,use t:commandButton pass some parameter to back bean

Posted by Richard Capraro <ri...@gmail.com>.
Hello Kevin,
maybe you could use the "param" tag, like this

 <h:commandButton id="validate" action="#{userAction.validateUser}">
  <h:outputText value="#{msg.validate}"/>
  <f:param name="id" value="#{user.id}"/>
</h:commandLink>

To get the parameter "id" in your bean, use:

FacesContext context = FacesContext.getCurrentInstance();
Map map = context.getExternalContext().getRequestParameterMap();
String employeeID = (String) map.get("id");

Hope it helps you,

Regards,
Richard Capraro

2006/11/13, kevin_zhai <ja...@gmail.com>:
>
> hi expert:
>            If I use t:commandButton pass some parameter to back bean
> excepte use t:inputHidden,
>    can I use some other method implements?
>    I try use f:attribute,but it's not support EL expression.
>
> thanks
> --
> View this message in context: http://www.nabble.com/help%2Cuse-t%3AcommandButton-pass-some-parameter-to-back-bean-tf2619256.html#a7309750
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: help,use t:commandButton pass some parameter to back bean

Posted by Richard Capraro <ri...@gmail.com>.
Thanks Gerald,
indeed your method is simpler and cleaner than mine.

Hope it will help Kevin

Regards,
Richard

2006/11/13, Gerald Müllan <bi...@gmail.com>:
> Hi,
>
> in MyFaces the best way to pass some parameters to a backing bean is
> the usage of t:updateActionListener:
>
> <h:commandLink value="delete entry" action="#{managedBean.deleteEntry}">
>          <t:updateActionListener
> property="#{managedBean.idOfEntryToDelete}"   value="#{entry.id}"/>
> </h:commandLink>
>
> The attribute "idOfEntryToDelete" gets the entry-id and following you
> can use it for instance in the "deleteEntry" action method to find the
> entry object.
>
> cheers,
>
> Gerald
>
> On 11/13/06, kevin_zhai <ja...@gmail.com> wrote:
> >
> > hi expert:
> >             If I use t:commandButton pass some parameter to back bean
> > excepte use t:inputHidden,
> >     can I use some other method implements?
> >     I try use f:attribute,but it's not support EL expression.
> >
> > thanks
> > --
> > View this message in context: http://www.nabble.com/help%2Cuse-t%3AcommandButton-pass-some-parameter-to-back-bean-tf2619256.html#a7309750
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>
>
> --
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>

Re: help,use t:commandButton pass some parameter to back bean

Posted by Gerald Müllan <bi...@gmail.com>.
Hi,

in MyFaces the best way to pass some parameters to a backing bean is
the usage of t:updateActionListener:

<h:commandLink value="delete entry" action="#{managedBean.deleteEntry}">
          <t:updateActionListener
property="#{managedBean.idOfEntryToDelete}"   value="#{entry.id}"/>
</h:commandLink>

The attribute "idOfEntryToDelete" gets the entry-id and following you
can use it for instance in the "deleteEntry" action method to find the
entry object.

cheers,

Gerald

On 11/13/06, kevin_zhai <ja...@gmail.com> wrote:
>
> hi expert:
>             If I use t:commandButton pass some parameter to back bean
> excepte use t:inputHidden,
>     can I use some other method implements?
>     I try use f:attribute,but it's not support EL expression.
>
> thanks
> --
> View this message in context: http://www.nabble.com/help%2Cuse-t%3AcommandButton-pass-some-parameter-to-back-bean-tf2619256.html#a7309750
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces