commandButton with window.confirm() and disabled

UI Components for JSF
Post Reply
designpattern
Posts: 5
Joined: 29 Aug 2010, 04:43
Location: Germany
Contact:

30 Jul 2011, 17:56

I would like to use a commandButtonin combination with the window.confirm() dialog like this:

Code: Select all

        <p:commandButton id="delete"
                         value="#{msgs['button.delete']}"
                         onclick="return confirm('#{msgs.confirm} Categoria Entrata?')"
                         action="#{categorieEntrateForm.delete}"
                         disabled="#{empty categorieEntrateForm.categorieEntrate.idCategoria}"
                         ajax="false" 
                         />
This button does never reach the categorieEntrateForm.delete method.

When I remove the disabled=".." attribute, or replace it by a simple true value, everything works fine. (idCategoria is used to distinguished new and edited records and is null or a long value). The disabled attribute works as expected (button disabled for null values, active for non nulls).

Am I doing something wrong or is this a bug?

(i do not want to use the primefaces confirmDialog, it would be overkill just to ask a simple yes/no question.)
(This worked fine with PF 2.1, I'm upgrading to 2.2.1 and experiencing this problem)
JSF-2.0, mojarra-2.0.2-FCS, PrimeFaces-2.2.1

designpattern
Posts: 5
Joined: 29 Aug 2010, 04:43
Location: Germany
Contact:

15 Aug 2011, 18:51

I found a solution to this problem.

It tourned out that the disabled attribute caused an extra request after the confirm dialog had been shown (btw: not nice).
Since I used request scope only, the value was always null on this request. And PF failed in some way instead of processing the request (not nice).
JSF-2.0, mojarra-2.0.2-FCS, PrimeFaces-2.2.1

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

16 Aug 2011, 00:07

I never use the window.confirm anymore since it does not style with the app. So I never have these (in your terms 'not nice') issues anymore. I Use the http://www.primefaces.org/showcase-labs ... Dialog.jsf

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests