Skip to content

Commit

Permalink
primefaces-extensions#1751 InputPhone Revert default event
Browse files Browse the repository at this point in the history
  • Loading branch information
jepsar committed Nov 23, 2024
1 parent c7ca90d commit a17a39e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ public String getFamily() {
return COMPONENT_FAMILY;
}

@Override
public String getDefaultEventName() {
return EVENT_COUNTRY_SELECT;
}

@Override
public String getInputClientId() {
return getClientId() + INPUT_SUFFIX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
package org.primefaces.extensions.component.inputphone;

import static org.primefaces.extensions.component.inputphone.InputPhone.EVENT_COUNTRY_SELECT;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -113,7 +115,8 @@ public Object getConvertedValue(final FacesContext context, final UIComponent co
else {
inputPhone.setInitialCountry(country);
}
if (PrimeExtensionsEnvironment.getCurrentInstance(context).isLibphonenumberAvailable()) {
if (needsValidation(context)
&& PrimeExtensionsEnvironment.getCurrentInstance(context).isLibphonenumberAvailable()) {
PhoneNumberUtilWrapper.validate(value, country.toUpperCase(), inputPhone.getValidatorMessage());
}
else {
Expand All @@ -122,6 +125,13 @@ public Object getConvertedValue(final FacesContext context, final UIComponent co
return value;
}

protected boolean needsValidation(final FacesContext context) {
final String eventName = context.getExternalContext()
.getRequestParameterMap()
.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
return !EVENT_COUNTRY_SELECT.equals(eventName);
}

protected void encodeMarkup(final FacesContext context, final InputPhone inputPhone, final String valueToRender)
throws IOException {
final ResponseWriter writer = context.getResponseWriter();
Expand Down

0 comments on commit a17a39e

Please sign in to comment.