You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Csík Norbert <cs...@freemail.hu> on 2005/03/31 18:52:09 UTC

commandButton's action vs rendered

Hi!

I have a h:commandButton with a simple action in the backing bean. It's a delete button, so it should be visible if there is a row in the backing bean (ie. the code of the row exists). I use the rendered attribute of the commandButton to decide wether or not to display the component. The problem is, when the rendered attribute is set, JSF doesn't call the action method in the backing bean. When I delete the rendered property, it works fine (but the button is visible all the time).

What's wrong?

Here's my button's code:

<h:commandButton
	value="#{globalBundle.deleteButtonLabel}"
	action="#{UserBean.delete}"
	rendered="#{UserBean.userCode != ''}"
/>

thnx,

-- 
 Norbert Csík 

Re: commandButton's action vs rendered

Posted by Csík Norbert <cs...@freemail.hu>.
I've made a property named "loaded" (boolean type, with set/is methods), and the result was the same: the button rendered as I expected (rendered when the loaded is true, not rendered when it is false), but a click on the button has no effect, the referenced method in the backing bean didn't invoked.

Matthias Wessendorf írta:
> ok...
> 
> please test
> 
> private boolean shouldButtonBeVisible = false;
> 
> set / is  method
> 
> and then use:
> 
> rendered="#{UserBean.shouldButtonBeVisible}"
> 


-- 
 Csík Norbert

Re: commandButton's action vs rendered

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
ok...

please test

private boolean shouldButtonBeVisible = false;

set / is  method

and then use:

rendered="#{UserBean.shouldButtonBeVisible}"

Csík Norbert wrote:
> yes. the only difference between the two cases is the existence of the 
> rendered property.
> 
> Slawek írta:
> 
>> sure that in case 1 your button is inside somme form?:P
>> thats my favorite bug;)
>>
>> slawek
>>
>>> Yes I've tried, but nothing happend. The button is still does 
>>> nothing. The action method is uncalled.
>>>
>>> Heath Borders írta:
>>>
>>>> Yeah, that's what I meant.
>>>>
>>>>
>>>> On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
>>>> <ma...@matthias-wessendorf.de> wrote:
>>>>
>>>>> Have you tried somthing like
>>>>>
>>>>> rendered="#{UserBean.shouldButtonBeVisible}"
>>>>>
>>>>> ?
>>>>>
>>>>> That was that what Heath was meaning... I guess
>>>>>
>>>>> Csík Norbert wrote:
>>>>>
>>>>>> Sorry, maybe I wasn't clear enough. When the rendered property is 
>>>>>> set as
>>>>>> in the example below, the button renders correctly. It is on the page
>>>>>> when the condition is true. The problem is that, when I click on the
>>>>>> button (at this time the condition is true, 'cause I can click on the
>>>>>> button) nothing happens.
>>>>>>
>>>>>> CASE 1:
>>>>>>
>>>>>> <h:commandButton
>>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>>      action="#{UserBean.delete}"
>>>>>>      rendered="#{UserBean.userCode != ''}"
>>>>>> />
>>>>>>
>>>>>> The button is only visible when the condition is true, but when I 
>>>>>> click
>>>>>> on it, nothing happens (the action isn't called). This is my problem.
>>>>>>
>>>>>> CASE 2:
>>>>>>
>>>>>> <h:commandButton
>>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>>      action="#{UserBean.delete}"
>>>>>> />
>>>>>>
>>>>>> The button is always visible, and the action is called when I 
>>>>>> click on
>>>>>> the button.

Re: commandButton's action vs rendered

Posted by Csík Norbert <cs...@freemail.hu>.
yes. the only difference between the two cases is the existence of the rendered property.

Slawek írta:
> sure that in case 1 your button is inside somme form?:P
> thats my favorite bug;)
> 
> slawek
> 
>> Yes I've tried, but nothing happend. The button is still does nothing. 
>> The action method is uncalled.
>>
>> Heath Borders írta:
>>
>>> Yeah, that's what I meant.
>>>
>>>
>>> On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
>>> <ma...@matthias-wessendorf.de> wrote:
>>>
>>>> Have you tried somthing like
>>>>
>>>> rendered="#{UserBean.shouldButtonBeVisible}"
>>>>
>>>> ?
>>>>
>>>> That was that what Heath was meaning... I guess
>>>>
>>>> Csík Norbert wrote:
>>>>
>>>>> Sorry, maybe I wasn't clear enough. When the rendered property is 
>>>>> set as
>>>>> in the example below, the button renders correctly. It is on the page
>>>>> when the condition is true. The problem is that, when I click on the
>>>>> button (at this time the condition is true, 'cause I can click on the
>>>>> button) nothing happens.
>>>>>
>>>>> CASE 1:
>>>>>
>>>>> <h:commandButton
>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>      action="#{UserBean.delete}"
>>>>>      rendered="#{UserBean.userCode != ''}"
>>>>> />
>>>>>
>>>>> The button is only visible when the condition is true, but when I 
>>>>> click
>>>>> on it, nothing happens (the action isn't called). This is my problem.
>>>>>
>>>>> CASE 2:
>>>>>
>>>>> <h:commandButton
>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>      action="#{UserBean.delete}"
>>>>> />
>>>>>
>>>>> The button is always visible, and the action is called when I click on
>>>>> the button.
>>>>>
>>>>>
>>>>
>>>
>>>
>>
> 
> 

-- 
 Csík Norbert

Re: commandButton's action vs rendered

Posted by Csík Norbert <no...@csik.net>.
yes. the only difference between the two cases is the existence of the rendered property.

Slawek írta:
> sure that in case 1 your button is inside somme form?:P
> thats my favorite bug;)
> 
> slawek
> 
>> Yes I've tried, but nothing happend. The button is still does nothing. 
>> The action method is uncalled.
>>
>> Heath Borders írta:
>>
>>> Yeah, that's what I meant.
>>>
>>>
>>> On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
>>> <ma...@matthias-wessendorf.de> wrote:
>>>
>>>> Have you tried somthing like
>>>>
>>>> rendered="#{UserBean.shouldButtonBeVisible}"
>>>>
>>>> ?
>>>>
>>>> That was that what Heath was meaning... I guess
>>>>
>>>> Csík Norbert wrote:
>>>>
>>>>> Sorry, maybe I wasn't clear enough. When the rendered property is 
>>>>> set as
>>>>> in the example below, the button renders correctly. It is on the page
>>>>> when the condition is true. The problem is that, when I click on the
>>>>> button (at this time the condition is true, 'cause I can click on the
>>>>> button) nothing happens.
>>>>>
>>>>> CASE 1:
>>>>>
>>>>> <h:commandButton
>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>      action="#{UserBean.delete}"
>>>>>      rendered="#{UserBean.userCode != ''}"
>>>>> />
>>>>>
>>>>> The button is only visible when the condition is true, but when I 
>>>>> click
>>>>> on it, nothing happens (the action isn't called). This is my problem.
>>>>>
>>>>> CASE 2:
>>>>>
>>>>> <h:commandButton
>>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>>      action="#{UserBean.delete}"
>>>>> />
>>>>>
>>>>> The button is always visible, and the action is called when I click on
>>>>> the button.
>>>>>
>>>>>
>>>>
>>>
>>>
>>
> 
> 

-- 
 Csík Norbert          http://norbert.web.elte.hu/
 Programtervező matematikus
 Trilobita Informatikai Rt. - rendszertervező fejlesztőmérnök
___ keep sm:)ing _________________________ooo__C( O O )L__ooo__
http://www.aion.hu/ - A csik.NET otthona
http://www.spreadfirefox.com/ - Rediscover the web
Légy pontos: Mérj mikro-milliméterben! Jelölj krétával! Vágj baltával!

Re: commandButton's action vs rendered

Posted by Slawek <ss...@o2.pl>.
sure that in case 1 your button is inside somme form?:P
thats my favorite bug;)

slawek

> Yes I've tried, but nothing happend. The button is still does nothing. 
> The action method is uncalled.
>
> Heath Borders írta:
>> Yeah, that's what I meant.
>>
>>
>> On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
>> <ma...@matthias-wessendorf.de> wrote:
>>
>>> Have you tried somthing like
>>>
>>> rendered="#{UserBean.shouldButtonBeVisible}"
>>>
>>> ?
>>>
>>> That was that what Heath was meaning... I guess
>>>
>>> Csík Norbert wrote:
>>>
>>>> Sorry, maybe I wasn't clear enough. When the rendered property is set 
>>>> as
>>>> in the example below, the button renders correctly. It is on the page
>>>> when the condition is true. The problem is that, when I click on the
>>>> button (at this time the condition is true, 'cause I can click on the
>>>> button) nothing happens.
>>>>
>>>> CASE 1:
>>>>
>>>> <h:commandButton
>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>      action="#{UserBean.delete}"
>>>>      rendered="#{UserBean.userCode != ''}"
>>>> />
>>>>
>>>> The button is only visible when the condition is true, but when I 
>>>> click
>>>> on it, nothing happens (the action isn't called). This is my problem.
>>>>
>>>> CASE 2:
>>>>
>>>> <h:commandButton
>>>>      value="#{globalBundle.deleteButtonLabel}"
>>>>      action="#{UserBean.delete}"
>>>> />
>>>>
>>>> The button is always visible, and the action is called when I click on
>>>> the button.
>>>>
>>>>
>>>
>>
>>
>



Re: commandButton's action vs rendered

Posted by Csík Norbert <cs...@freemail.hu>.
Yes I've tried, but nothing happend. The button is still does nothing. The action method is uncalled.

Heath Borders írta:
> Yeah, that's what I meant.
> 
> 
> On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
> <ma...@matthias-wessendorf.de> wrote:
> 
>>Have you tried somthing like
>>
>>rendered="#{UserBean.shouldButtonBeVisible}"
>>
>>?
>>
>>That was that what Heath was meaning... I guess
>>
>>Csík Norbert wrote:
>>
>>>Sorry, maybe I wasn't clear enough. When the rendered property is set as
>>>in the example below, the button renders correctly. It is on the page
>>>when the condition is true. The problem is that, when I click on the
>>>button (at this time the condition is true, 'cause I can click on the
>>>button) nothing happens.
>>>
>>>CASE 1:
>>>
>>><h:commandButton
>>>      value="#{globalBundle.deleteButtonLabel}"
>>>      action="#{UserBean.delete}"
>>>      rendered="#{UserBean.userCode != ''}"
>>>/>
>>>
>>>The button is only visible when the condition is true, but when I click
>>>on it, nothing happens (the action isn't called). This is my problem.
>>>
>>>CASE 2:
>>>
>>><h:commandButton
>>>      value="#{globalBundle.deleteButtonLabel}"
>>>      action="#{UserBean.delete}"
>>>/>
>>>
>>>The button is always visible, and the action is called when I click on
>>>the button.
>>>
>>>
>>
> 
> 

-- 
 Csík Norbert

Re: commandButton's action vs rendered

Posted by Heath Borders <he...@gmail.com>.
Yeah, that's what I meant.


On Thu, 31 Mar 2005 20:03:37 +0200, Matthias Wessendorf
<ma...@matthias-wessendorf.de> wrote:
> Have you tried somthing like
> 
> rendered="#{UserBean.shouldButtonBeVisible}"
> 
> ?
> 
> That was that what Heath was meaning... I guess
> 
> Csík Norbert wrote:
> > Sorry, maybe I wasn't clear enough. When the rendered property is set as
> > in the example below, the button renders correctly. It is on the page
> > when the condition is true. The problem is that, when I click on the
> > button (at this time the condition is true, 'cause I can click on the
> > button) nothing happens.
> >
> > CASE 1:
> >
> > <h:commandButton
> >       value="#{globalBundle.deleteButtonLabel}"
> >       action="#{UserBean.delete}"
> >       rendered="#{UserBean.userCode != ''}"
> > />
> >
> > The button is only visible when the condition is true, but when I click
> > on it, nothing happens (the action isn't called). This is my problem.
> >
> > CASE 2:
> >
> > <h:commandButton
> >       value="#{globalBundle.deleteButtonLabel}"
> >       action="#{UserBean.delete}"
> > />
> >
> > The button is always visible, and the action is called when I click on
> > the button.
> >
> >
> 


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

Re: commandButton's action vs rendered

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Have you tried somthing like

rendered="#{UserBean.shouldButtonBeVisible}"

?

That was that what Heath was meaning... I guess

Csík Norbert wrote:
> Sorry, maybe I wasn't clear enough. When the rendered property is set as 
> in the example below, the button renders correctly. It is on the page 
> when the condition is true. The problem is that, when I click on the 
> button (at this time the condition is true, 'cause I can click on the 
> button) nothing happens.
> 
> CASE 1:
> 
> <h:commandButton
>       value="#{globalBundle.deleteButtonLabel}"
>       action="#{UserBean.delete}"
>       rendered="#{UserBean.userCode != ''}"
> />
> 
> The button is only visible when the condition is true, but when I click 
> on it, nothing happens (the action isn't called). This is my problem.
> 
> CASE 2:
> 
> <h:commandButton
>       value="#{globalBundle.deleteButtonLabel}"
>       action="#{UserBean.delete}"
> />
> 
> The button is always visible, and the action is called when I click on 
> the button.
> 
> 

Re: commandButton's action vs rendered

Posted by Csík Norbert <cs...@freemail.hu>.
Sorry, maybe I wasn't clear enough. When the rendered property is set as in the example below, the button renders correctly. It is on the page when the condition is true. The problem is that, when I click on the button (at this time the condition is true, 'cause I can click on the button) nothing happens.

CASE 1:

<h:commandButton
       value="#{globalBundle.deleteButtonLabel}"
       action="#{UserBean.delete}"
       rendered="#{UserBean.userCode != ''}"
/>

The button is only visible when the condition is true, but when I click on it, nothing happens (the action isn't called). This is my problem.

CASE 2:

<h:commandButton
       value="#{globalBundle.deleteButtonLabel}"
       action="#{UserBean.delete}"
/>

The button is always visible, and the action is called when I click on the button.


-- 
 Norbert Csík 

Re: commandButton's action vs rendered

Posted by Heath Borders <he...@gmail.com>.
The action methodBinding is only executed when that button is clicked.
 Obviously, if its not rendered, then it won't ever be clicked.

However, there is a limit to what you can put into the EL for your
rendered attribute, and I think you're outside that limit.  Just bind
the rendered property to a boolean getter on your backing bean, and
then you can do whatever you want in Java code.


On Thu, 31 Mar 2005 18:52:09 +0200, Csík Norbert <cs...@freemail.hu> wrote:
> Hi!
> 
> I have a h:commandButton with a simple action in the backing bean. It's a delete button, so it should be visible if there is a row in the backing bean (ie. the code of the row exists). I use the rendered attribute of the commandButton to decide wether or not to display the component. The problem is, when the rendered attribute is set, JSF doesn't call the action method in the backing bean. When I delete the rendered property, it works fine (but the button is visible all the time).
> 
> What's wrong?
> 
> Here's my button's code:
> 
> <h:commandButton
>        value="#{globalBundle.deleteButtonLabel}"
>        action="#{UserBean.delete}"
>        rendered="#{UserBean.userCode != ''}"
> />
> 
> thnx,
> 
> --
> Norbert Csík
> 


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