You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by pdt_p <pi...@gmail.com> on 2007/10/22 04:43:53 UTC

how to set CoreCommandButton action programmatically?

Hi...

I have a button (CoreCommandButton), this button I create it
programatically. How do i set the action for that button? 

Basically, I try to create a button progamatically that will match with
creating a button in this jsp code like:
<tr:commandButton text="MyButton" action="ThisButtonAction" />

There is a method in CoreCommandButton called setAction and it accepting
MethodBinding as parameter. 
but in order to create a method binding through Application, I have to
create specify the EL expression. But in my case I don't have any managebean
to handle the action but I know the return value for the action.

Any idea how I to do that?

thank you

Pdt

-- 
View this message in context: http://www.nabble.com/how-to-set-CoreCommandButton-action-programmatically--tf4668410.html#a13335936
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: how to set CoreCommandButton action programmatically?

Posted by pdt_p <pi...@gmail.com>.
Hi  Mike & Andrew ...

Thank you for your tips... That's useful tips for me.

Regards,

Pdt


Andrew Robinson-5 wrote:
> 
> The MyFaces UICOmponentTagBase just uses this:
> 
> UIComponentTagUtils.setActionProperty(getFacesContext(), component,
> action);
> 
> Where the action can be a "normal" string or an "EL" string.
> 
> On 10/21/07, pdt_p <pi...@gmail.com> wrote:
>>
>> Hi...
>>
>> I have a button (CoreCommandButton), this button I create it
>> programatically. How do i set the action for that button?
>>
>> Basically, I try to create a button progamatically that will match with
>> creating a button in this jsp code like:
>> <tr:commandButton text="MyButton" action="ThisButtonAction" />
>>
>> There is a method in CoreCommandButton called setAction and it accepting
>> MethodBinding as parameter.
>> but in order to create a method binding through Application, I have to
>> create specify the EL expression. But in my case I don't have any
>> managebean
>> to handle the action but I know the return value for the action.
>>
>> Any idea how I to do that?
>>
>> thank you
>>
>> Pdt
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-set-CoreCommandButton-action-programmatically--tf4668410.html#a13335936
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-set-CoreCommandButton-action-programmatically--tf4668410.html#a13357519
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: how to set CoreCommandButton action programmatically?

Posted by Andrew Robinson <an...@gmail.com>.
The MyFaces UICOmponentTagBase just uses this:

UIComponentTagUtils.setActionProperty(getFacesContext(), component, action);

Where the action can be a "normal" string or an "EL" string.

On 10/21/07, pdt_p <pi...@gmail.com> wrote:
>
> Hi...
>
> I have a button (CoreCommandButton), this button I create it
> programatically. How do i set the action for that button?
>
> Basically, I try to create a button progamatically that will match with
> creating a button in this jsp code like:
> <tr:commandButton text="MyButton" action="ThisButtonAction" />
>
> There is a method in CoreCommandButton called setAction and it accepting
> MethodBinding as parameter.
> but in order to create a method binding through Application, I have to
> create specify the EL expression. But in my case I don't have any managebean
> to handle the action but I know the return value for the action.
>
> Any idea how I to do that?
>
> thank you
>
> Pdt
>
> --
> View this message in context: http://www.nabble.com/how-to-set-CoreCommandButton-action-programmatically--tf4668410.html#a13335936
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: how to set CoreCommandButton action programmatically?

Posted by Mike Kienenberger <mk...@gmail.com>.
You can implement your own MethodBinding if you want to directly call java code.

               updateUICommand.setActionListener(new
IndirectMethodBinding(new IndirectMethodBindingHolder()
                {
                    public void invoke(Object[] args)
                    {

rowAndColumnRelationshipsPage.update((ActionEvent)args[0]);
                    }
                }));


You can find the classes IndirectMethodBinding and
IndirectMethodBindingHolder in this old MyFaces JIRA issue attachment:

https://issues.apache.org/jira/secure/attachment/12311217/RowAndColumnRelationshipComponent.zip




On 10/21/07, pdt_p <pi...@gmail.com> wrote:
>
> Hi...
>
> I have a button (CoreCommandButton), this button I create it
> programatically. How do i set the action for that button?
>
> Basically, I try to create a button progamatically that will match with
> creating a button in this jsp code like:
> <tr:commandButton text="MyButton" action="ThisButtonAction" />
>
> There is a method in CoreCommandButton called setAction and it accepting
> MethodBinding as parameter.
> but in order to create a method binding through Application, I have to
> create specify the EL expression. But in my case I don't have any managebean
> to handle the action but I know the return value for the action.
>
> Any idea how I to do that?
>
> thank you
>
> Pdt
>
> --
> View this message in context: http://www.nabble.com/how-to-set-CoreCommandButton-action-programmatically--tf4668410.html#a13335936
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>