<p:growl id="growl" showDetail="true" showSummary="true" globalOnly="false"> <p:autoUpdate /> </p:growl> <pe:inputPhone id="txtPhone" initialCountry="us" value="#{basicInputPhoneController.phoneNumber}" formatOnDisplay="true" formatAsYouType="false" autoPlaceholder="off" placeholder="(201) 566-1711 x9876" dir="ltr"> </pe:inputPhone> <p:commandButton value="Submit" update="txtPhone" actionListener="#{basicInputPhoneController.submit}" styleClass="ml-2" />
@Named @ViewScoped public class BasicInputPhoneController implements Serializable { private static final long serialVersionUID = 1L; private String phoneNumber; private Map<String, String> localizedCountries; @PostConstruct protected void init() { localizedCountries = new HashMap<>(); localizedCountries.put("nl", "Nederland"); localizedCountries.put("be", "België"); localizedCountries.put("de", "Duitsland"); } public void onCountrySelect(final SelectEvent<Country> event) { final Country country = event.getObject(); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Selected " + country.getName(), null)); } public void submit() { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Phone Number " + phoneNumber, null)); } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(final String phoneNumber) { this.phoneNumber = phoneNumber; } public Map<String, String> getLocalizedCountries() { return localizedCountries; } }