primefaces-extensions / primefaces-extensions.github.com

Organization repo, only for homepage, wiki and issue tracker
https://primefaces-extensions.github.io/
68 stars 22 forks source link

Add single click renderer for CommandButton #760

Closed jepsar closed 4 years ago

jepsar commented 4 years ago

See https://github.com/primefaces/primefaces/issues/2521

jepsar commented 4 years ago

@melloware do you have an idea how we could load the Javascript? I don't want to introduce a new component, just the renderer.

One option I see is to make it part of the documentation that you should load some (the PFE core?) Javascript if you want to use the renderer.

Rapster commented 4 years ago

Why don't you write JS code inline?

melloware commented 4 years ago

I don't know the spec but are we not allowed to use ResourceDependencies on Renderer's?

@ResourceDependencies({
        @ResourceDependency(library = "primefaces", name = "jquery/jquery.js"),
})

Because it would be nice just to have it in primefaces-extensions core.js so its not inline on the page and it gets compressed and cached.

jepsar commented 4 years ago

@Rapster I'd like to keep the outputted bytes to a minimum. But inline JS would be an option.

@melloware I think we are too late in the renderer to add resources.

Rapster commented 4 years ago

If you don't go on inline route then, you'll have to create a CommandButtonSingleClick component which only set a new @ResourceDependency

melloware commented 4 years ago

OK understood. that would be my preference vs inlining? @Rapster have any angst about that?

melloware commented 4 years ago

Plus it would allow for prototype overriding in JS if someone wanted to do something special or different in these methods as an added bonus.

Rapster commented 4 years ago

No, I have nothing against it but I think inline JS would be simpler: "PF(" + ((CommandButton) component).getWidgetVar() + ").enable();";

@jepsar Regarding confirmation, not sure why there is a special case on this, but you could use Confirmable#requiresConfirmation instead

jepsar commented 4 years ago

We don't need an exception on the buttons that require confirmation, but the confirmation buttons (the ones in the dialog).

melloware commented 4 years ago

I tested this morning with PrimeFaces.CSP = true and everything works great with this feature with Content Security Policy enabled.