Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix#11814: Support DefaultCommand for submit button outside (but linked to) form #11878

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected void encodeMarkup(FacesContext context, CommandButton button) throws I
String type = button.getType();
boolean pushButton = ("reset".equals(type) || "button".equals(type));
Object value = button.getValue();
String form = button.getForm();
String icon = button.getIcon();
String title = button.getTitle();
String onclick = null;
Expand Down Expand Up @@ -107,6 +108,10 @@ protected void encodeMarkup(FacesContext context, CommandButton button) throws I
writer.writeAttribute("disabled", "disabled", "disabled");
}

if (!isValueBlank(form)) {
writer.writeAttribute("data-pf-form", form, null);
}

//icon
if (!isValueBlank(icon)) {
String defaultIconClass = button.getIconPos().equals("left") ? HTML.BUTTON_LEFT_ICON_CLASS : HTML.BUTTON_RIGHT_ICON_CLASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ PrimeFaces.widget.DefaultCommand = PrimeFaces.widget.BaseWidget.extend({
}

//attach keypress listener to parent form
var closestForm = this.jqTarget.closest('form');
var closestForm = this.jqTarget[0].hasAttribute('data-pf-form')
? $(PrimeFaces.escapeClientId(this.jqTarget[0].getAttribute('data-pf-form')))
: this.jqTarget.closest('form');

closestForm.off('keydown.' + this.id).on('keydown.' + this.id, {scopeEnter: false}, function (e, data) {
data = data || e.data;
if (($this.scope && data.scopeEnter && data.scopeDefaultCommandId === $this.id)
Expand Down