And the formitting is not Wicket's one.
E.g. the opening { should be on the next line.Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Wed, Dec 21, 2016 at 9:14 AM, Martin Grigorov <[email protected]> wrote: > Hi Tobias, > > Some feedback inline: > > On Tue, Dec 20, 2016 at 8:19 PM, <[email protected]> wrote: > >> Repository: wicket >> Updated Branches: >> refs/heads/master aedb98764 -> bcd55813b >> >> >> WICKET-6299 >> >> Project: http://git-wip-us.apache.org/repos/asf/wicket/repo >> Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/bcd55813 >> Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/bcd55813 >> Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/bcd55813 >> >> Branch: refs/heads/master >> Commit: bcd55813b3afbccb5675096930aee6281c5cba3a >> Parents: aedb987 >> Author: Tobias Soloschenko <[email protected]> >> Authored: Tue Dec 20 20:15:42 2016 +0100 >> Committer: Tobias Soloschenko <[email protected]> >> Committed: Tue Dec 20 20:15:42 2016 +0100 >> >> ---------------------------------------------------------------------- >> .../html/form/AutoCompleteAddressType.java | 56 ++++ >> .../markup/html/form/AutoCompleteBuilder.java | 170 ++++++++++++ >> .../markup/html/form/AutoCompleteContact.java | 77 ++++++ >> .../html/form/AutoCompleteContactBuilder.java | 38 +++ >> .../html/form/AutoCompleteContactDetails.java | 102 +++++++ >> .../markup/html/form/AutoCompleteFields.java | 272 >> +++++++++++++++++++ >> .../apache/wicket/markup/html/form/Form.java | 14 + >> .../wicket/markup/html/form/TextField.java | 14 + >> .../wicket/markup/html/form/FormTest.java | 39 +++ >> .../wicket/markup/html/form/TextFieldTest.java | 23 +- >> 10 files changed, 803 insertions(+), 2 deletions(-) >> ---------------------------------------------------------------------- >> >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteAddressType.java >> ---------------------------------------------------------------------- >> diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteAddressType.java b/wicket-core/src/main/java/or >> g/apache/wicket/markup/html/form/AutoCompleteAddressType.java >> new file mode 100644 >> index 0000000..6123053 >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteAddressType.java >> @@ -0,0 +1,56 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * Auto completion address type according to the whatwg specification. >> + * >> + * @author Tobias Soloschenko >> + * >> + * @see <a href= >> + * "https://html.spec.whatwg.org/multipage/forms.html">https:// >> html.spec.whatwg.org/multipage/forms.html</a> >> + * >> + */ >> +public enum AutoCompleteAddressType { >> + >> + /** >> + * Meaning the field is part of the shipping address or contact >> information >> + */ >> + SHIPPING("shipping"), >> + >> + /** >> + * meaning the field is part of the billing address or contact >> information >> + */ >> + BILLING("billing"); >> + >> + private String value; >> + >> + private AutoCompleteAddressType(String value) >> + { >> + this.value = value; >> + } >> + >> + /** >> + * Gets the address type value >> + * >> + * @return the value of the address type >> + */ >> + public String getValue() >> + { >> + return value; >> + } >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteBuilder.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoCompleteBuilder.java >> b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteBuilder.java >> new file mode 100644 >> index 0000000..a3b64cd >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteBuilder.java >> @@ -0,0 +1,170 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * The auto complete builder is used to build the corresponding >> attribute for form and input tags. >> + * To use the auto completion just open the autofill options within your >> browser. In chrome for >> + * example it is accessed with the following URL: >> + * <a href="chrome://settings/autofillEditAddress">chrome://settin >> gs/autofillEditAddress</a> >> + * >> + * @author Tobias Soloschenko >> + * >> + * @since 8.0.0 >> + * >> + */ >> +public class AutoCompleteBuilder implements AutoCompleteContactBuilder >> +{ >> + /** >> + * The section prefix specificed by the whatwg standard >> + */ >> + public static final String SECTION_PREFIX = "section-"; >> + >> + private String sectionName; >> + >> + private AutoCompleteAddressType addressType; >> + >> + private AutoCompleteFields field; >> + >> + private AutoCompleteContact contact; >> + >> + private AutoCompleteContactDetails contactDetail; >> + >> + private boolean empty; >> + >> + /** >> + * Initializes a new auto complete builder >> + * >> + * @return the auto complete builder >> + */ >> + public static AutoCompleteBuilder init() >> + { >> + return new AutoCompleteBuilder(); >> + } >> + >> + /** >> + * Empties out the autocomplete outcome >> + * >> + * @return the auto complete builder >> + */ >> + public AutoCompleteBuilder empty() >> + { >> + this.empty = true; >> > > The way 'empty' works seems incomplete. > Each `with**` method should set it to 'false'. > > >> + return this; >> + } >> + >> + /** >> + * Applies a section to the auto completion field >> + * >> + * @param sectionName >> + * the name of the section >> + * @return the auto complete builder itself >> + */ >> + public AutoCompleteBuilder withSection(String sectionName) >> + { >> + this.sectionName = sectionName; >> > > Such assignments need check for non-emptiness. > If the value is "" then it will pass the check for '!= null' in toString() > and produce wrong output. > > >> + return this; >> + } >> + >> + /** >> + * Assigns the auto completion to a specific address type >> + * >> + * @param addressType >> + * the auto completion address type >> + * @return the auto complete builder itself >> + */ >> + public AutoCompleteBuilder forAddressType(AutoCompleteAddressType >> addressType) >> + { >> + this.addressType = addressType; >> + return this; >> + } >> + >> + /** >> + * Applies the field to the autocomplete attribute >> + * >> + * @param field >> + * the field >> + * @return the auto complete builder >> + */ >> + public AutoCompleteBuilder forField(AutoCompleteFields field) >> + { >> + this.field = field; >> + return this; >> + } >> + >> + /** >> + * Applies the contact information to the autocomplete attribute >> + * >> + * @param contact >> + * the contact information are going to be applied to >> + * @return the auto complete builder >> + */ >> + public AutoCompleteContactBuilder forContact(AutoCompleteContact >> contact) >> + { >> + this.contact = contact; >> + return this; >> + } >> + >> + /** >> + * @see {@link AutoCompleteContactBuilder} >> + */ >> + @Override >> + public AutoCompleteContactBuilder forField(AutoCompleteContactDetails >> contactDetail) >> + { >> + this.contactDetail = contactDetail; >> + return (AutoCompleteContactBuilder)this; >> + } >> + >> + /** >> + * Builds the attribute string >> + * >> + * @return the attribute content in the right order >> + */ >> + @Override >> + public String toString() >> + { >> + StringBuilder stringBuilder = new StringBuilder(); >> + if (!empty) >> + { >> + if (sectionName != null) >> + { >> + stringBuilder.append(SECTION_PREFIX); >> + stringBuilder.append(sectionName); >> + stringBuilder.append(" "); >> > > Append char instead, i.e. ' '. > > >> + } >> + if (addressType != null) >> + { >> + stringBuilder.append(addressT >> ype.getValue()); >> + stringBuilder.append(" "); >> + } >> + if (field != null) >> + { >> + stringBuilder.append(field.getValue()); >> + } >> + else >> + { >> + if (contact != null) >> + { >> + stringBuilder.append(contact. >> getValue()); >> + stringBuilder.append(" "); >> + } >> + stringBuilder.append(contactD >> etail.getValue()); >> > > Is it allowed to have contactDetail without a contact ? > > >> + } >> + } >> + return stringBuilder.toString(); >> + } >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteContact.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoCompleteContact.java >> b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContact.java >> new file mode 100644 >> index 0000000..cbf86a5 >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContact.java >> @@ -0,0 +1,77 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * Auto completion contact according to the whatwg specification. >> + * >> + * @author Tobias Soloschenko >> + * >> + * @see <a href= >> + * "https://html.spec.whatwg.org/multipage/forms.html">https:// >> html.spec.whatwg.org/multipage/forms.html</a> >> + * >> + */ >> +public enum AutoCompleteContact { >> + >> + /** >> + * meaning the field is for contacting someone at their residence >> + */ >> + HOME("home"), >> + >> + /** >> + * meaning the field is for contacting someone at their workplace >> + */ >> + WORK("work"), >> + >> + /** >> + * meaning the field is for contacting someone regardless of >> location >> + */ >> + MOBILE("mobile"), >> + >> + /** >> + * meaning the field describes a fax machine's contact details >> + */ >> + FAX("fax"), >> + >> + /** >> + * meaning the field describes a pager's or beeper's contact >> details >> + */ >> + PAGER("pager"); >> + >> + private String value; >> + >> + /** >> + * Creates an auto completion contact with the given value >> + * >> + * @param value >> + * the value of the contact >> + */ >> + private AutoCompleteContact(String value) >> + { >> + this.value = value; >> + } >> + >> + /** >> + * Gets the value of the auto completion contact >> + * >> + * @return the value of the auto completion contact >> + */ >> + public String getValue() >> + { >> + return value; >> + } >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteContactBuilder.java >> ---------------------------------------------------------------------- >> diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContactBuilder.java b/wicket-core/src/main/java/or >> g/apache/wicket/markup/html/form/AutoCompleteContactBuilder.java >> new file mode 100644 >> index 0000000..07324ff >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContactBuilder.java >> @@ -0,0 +1,38 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * The auto complete contact builder shrinks down the possibilities to >> the contact details >> + * >> + * @author Tobias Soloschenko >> + * >> + * @since 8.0.0 >> + * >> + */ >> +public interface AutoCompleteContactBuilder >> +{ >> + /** >> + * Applies the contact details information to the auto complete >> field >> + * >> + * @param contactDetail >> + * the contact detail >> + * @return the auto complete builder contact >> + */ >> + AutoCompleteContactBuilder forField(AutoCompleteContactDetails >> contactDetail); >> + >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteContactDetails.java >> ---------------------------------------------------------------------- >> diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContactDetails.java b/wicket-core/src/main/java/or >> g/apache/wicket/markup/html/form/AutoCompleteContactDetails.java >> new file mode 100644 >> index 0000000..e4d5e44 >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteContactDetails.java >> @@ -0,0 +1,102 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * Auto completion contact detail according to the whatwg specification. >> + * >> + * @author Tobias Soloschenko >> + * >> + * @see <a href= >> + * "https://html.spec.whatwg.org/multipage/forms.html">https:// >> html.spec.whatwg.org/multipage/forms.html</a> >> + * >> + */ >> +public enum AutoCompleteContactDetails { >> + >> + /** >> + * +1 617 253 5702 > > > Prefix it with "E.g." > > >> >> + */ >> + TEL("tel"), >> + >> + /** >> + * +1 >> + */ >> + TEL_COUNTRY_CODE("tel-country-code"), >> + >> + /** >> + * 617 253 5702 >> + */ >> + TEL_NATIONAL("tel-national"), >> + >> + /** >> + * 617 >> + */ >> + TEL_AREA_CODE("tel-area-code"), >> + >> + /** >> + * 2535702 >> + */ >> + TEL_LOCAL("tel-local"), >> + >> + /** >> + * 253 >> + */ >> + TEL_LOCAL_PREFIX("tel-local-prefix"), >> + >> + /** >> + * 5702 >> + */ >> + TEL_LOCAL_SUFFIX("tel-local-suffix"), >> + >> + /** >> + * 1000 >> + */ >> + TEL_EXTENSION("tel-extension"), >> + >> + /** >> + * [email protected] >> + */ >> + EMAIL("email"), >> + >> + /** >> + * irc://example.org/timbl,isuser >> + */ >> + IMPP("impp"); >> + >> + private String value; >> + >> + /** >> + * Creates an auto completion contact detail with the given value >> + * >> + * @param value >> + * the value of the contact detail >> + */ >> + private AutoCompleteContactDetails(String value) >> + { >> + this.value = value; >> + } >> + >> + /** >> + * Gets the value of the auto completion contact detail >> + * >> + * @return the value of the auto completion contact detail >> + */ >> + public String getValue() >> + { >> + return value; >> + } >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /AutoCompleteFields.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoCompleteFields.java >> b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteFields.java >> new file mode 100644 >> index 0000000..8f794c4 >> --- /dev/null >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/AutoCompleteFields.java >> @@ -0,0 +1,272 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.wicket.markup.html.form; >> + >> +/** >> + * Auto completion personal data according to the whatwg specification. >> + * >> + * @author Tobias Soloschenko >> + * >> + * @see <a href= >> + * "https://html.spec.whatwg.org/multipage/forms.html">https:// >> html.spec.whatwg.org/multipage/forms.html</a> >> + * >> + */ >> +public enum AutoCompleteFields { >> + >> + /** >> + * Simply turns on the auto completion >> + */ >> + ON("on"), >> + >> + /** >> + * Simply turns off the auto completion >> + */ >> + OFF("off"), >> + >> + /** >> + * Sir Timothy John Berners-Lee, OM, KBE, FRS, FREng, FRSA >> + */ >> + NAME("name"), >> + >> + /** >> + * Sir >> + */ >> + HONORIFIC_PREFIX("honorific-prefix"), >> + >> + /** >> + * Timothy >> + */ >> + GIVEN_NAME("given-name"), >> + >> + /** >> + * John >> + */ >> + ADDITIONAL_NAME("additional-name"), >> + >> + /** >> + * Berners-Lee >> + */ >> + FAMILY_NAME("family-name"), >> + >> + /** >> + * OM, KBE, FRS, FREng, FRSA >> + */ >> + HONORIFIC_SUFFIX("honorific-suffix"), >> + >> + /** >> + * Tim >> + */ >> + NICKNAME("nickname"), >> + >> + /** >> + * timbl >> + */ >> + USERNAME("username"), >> + >> + /** >> + * GUMFXbadyrS3 >> + */ >> + NEW_PASSWORD("new-password"), >> + >> + /** >> + * qwerty >> + */ >> + CURRENT_PASSWORD("current-password"), >> + >> + /** >> + * Professor >> + */ >> + ORGANIZATION_TITLE("organization-title"), >> + >> + /** >> + * World Wide Web Consortium >> + */ >> + ORGANIZATION("organization"), >> + >> + /** >> + * Multiple lines 32 Vassar Street MIT Room 32-G524 >> + */ >> + STREET_ADDRESS("street-address"), >> + >> + /** >> + * 32 Vassar Street >> + */ >> + ADDRESS_LINE1("address-line1"), >> + >> + /** >> + * MIT Room 32-G524 >> + */ >> + ADDRESS_LINE2("address-line2"), >> + >> + /** >> + * See {@link AutoComplete.ADRESS_LINE2} >> + */ >> + ADDRESS_LINE3("address-line3"), >> + >> + /** >> + * The most fine-grained administrative level, in addresses with >> four administrative levels >> + */ >> + ADDRESS_LEVEL4("address-level4"), >> + >> + /** >> + * The third administrative level, in addresses with three or >> more administrative levels >> + */ >> + ADDRESS_LEVEL3("address-level3"), >> + >> + /** >> + * Cambridge >> + */ >> + ADDRESS_LEVEL2("address-level2"), >> + >> + /** >> + * MA >> + */ >> + ADDRESS_LEVEL1("address-level1"), >> + >> + /** >> + * US >> + */ >> + COUNTRY("country"), >> + >> + /** >> + * US >> + */ >> + COUNTRY_NAME("country-name"), >> + >> + /** >> + * 02139 >> + */ >> + POSTAL_CODE("postal-code"), >> + >> + /** >> + * Tim Berners-Lee >> + */ >> + CC_NAME("cc-name"), >> + >> + /** >> + * Tim >> + */ >> + CC_GIVEN_NAME("cc-given-name"), >> + >> + /** >> + * - >> + */ >> + CC_ADDITIONAL_NAME("cc-additional-name"), >> + >> + /** >> + * Berners-Lee >> + */ >> + CC_FAMILY_NAME("cc-family-name"), >> + >> + /** >> + * 4114360123456785 >> + */ >> + CC_NUMBER("cc-number"), >> + >> + /** >> + * 2014-12 >> + */ >> + CC_EXP("cc-exp"), >> + >> + /** >> + * 12 >> + */ >> + CC_EXP_MONTH("cc-exp-month"), >> + >> + /** >> + * 2014 >> + */ >> + CC_EXP_YEAR("cc-exp-year"), >> + >> + /** >> + * 419 >> + */ >> + CC_CSC("cc-csc"), >> + >> + /** >> + * Visa >> + */ >> + CC_TYPE("cc-type"), >> + >> + /** >> + * GBP >> + */ >> + TRANSACTION_CURRENCY("transaction-currency"), >> + >> + /** >> + * 401.00 >> + */ >> + TRANSACTION_AMOUNT("transaction-amount"), >> + >> + /** >> + * en >> + */ >> + LANGUAGE("language"), >> + >> + /** >> + * 1955-06-08 >> + */ >> + BDAY("bday"), >> + >> + /** >> + * 8 >> + */ >> + BDAY_DAY("bday-day"), >> + >> + /** >> + * 6 >> + */ >> + BDAY_MONTH("bday-month"), >> + >> + /** >> + * 1955 >> + */ >> + BDAY_YEAR("bday-year"), >> + >> + /** >> + * Male >> + */ >> + SEX("sex"), >> + >> + /** >> + * https://www.w3.org/People/Berners-Lee/ >> + */ >> + URL("url"), >> + >> + /** >> + * https://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-ei >> ghth.jpg >> + */ >> + PHOTO("photo"); >> + >> + private String value; >> + >> + private AutoCompleteFields(String value) >> + { >> + this.value = value; >> + } >> + >> + /** >> + * Gets the value of the auto completion >> + * >> + * @return the value of the auto completion >> + */ >> + public String getValue() >> + { >> + return value; >> + } >> + >> +} >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java >> b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java >> index e8b61e7..1d3284a 100644 >> --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/Form.java >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/Form.java >> @@ -1352,6 +1352,14 @@ public class Form<T> extends WebMarkupContainer >> } >> >> /** >> + * Gets the value of the autocomplete attribute. The default >> behavior is that it is turned off >> + * @return AutoCompleteBuilder the builder to generate the >> autocomplete attribute information >> + */ >> + protected AutoCompleteBuilder getAutoCompleteBuilder(){ >> + return AutoCompleteBuilder.init().empty(); >> > > Since there is no way to set empty=false at the moment this definitely > doesn't work. > Some tests for the builders would be nice! > > >> + } >> + >> + /** >> * >> * @see org.apache.wicket.Component#getStatelessHint() >> */ >> @@ -1633,6 +1641,12 @@ public class Form<T> extends WebMarkupContainer >> setMultiPart(true); >> } >> } >> + >> + // Auto completion support >> + String autocompleteValue = >> getAutoCompleteBuilder().toString(); >> + if(!autocompleteValue.isEmpty()){ >> + tag.put("autocomplete", >> autocompleteValue); >> + } >> } >> else >> { >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/main/java/org/apache/wicket/markup/html/form >> /TextField.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/TextField.java >> b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/TextField.java >> index 81dc828..719560c 100644 >> --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/TextField.java >> +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/fo >> rm/TextField.java >> @@ -107,6 +107,12 @@ public class TextField<T> extends >> AbstractTextComponent<T> >> >> tag.put("value", getValue()); >> >> + // Auto completion support >> + String autocompleteValue = getAutoCompleteBuilder().toStr >> ing(); >> + if(!autocompleteValue.isEmpty()){ >> + tag.put("autocomplete", autocompleteValue); >> + } >> + >> // Default handling for component tag >> super.onComponentTag(tag); >> } >> @@ -121,4 +127,12 @@ public class TextField<T> extends >> AbstractTextComponent<T> >> { >> return null; >> } >> + >> + /** >> + * Gets the value of the autocomplete attribute. The default >> behavior is that it is turned off >> + * @return AutoCompleteBuilder the builder to generate the >> autocomplete attribute information >> + */ >> + protected AutoCompleteBuilder getAutoCompleteBuilder(){ >> + return AutoCompleteBuilder.init().empty(); >> + } >> } >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/test/java/org/apache/wicket/markup/html/form >> /FormTest.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/FormTest.java >> b/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/FormTest.java >> index 05344a5..2ee420a 100644 >> --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/FormTest.java >> +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/FormTest.java >> @@ -53,6 +53,39 @@ public class FormTest extends WicketTestCase >> }; >> } >> >> + /** >> + * Test auto complete functionality >> + */ >> + @Test >> + public void testAutoComplete(){ >> + class TestPage extends WebPage implements >> IMarkupResourceStreamProvider >> + { >> + boolean shouldFail, submit, error; >> + >> + public TestPage() >> + { >> + add(new Form<Void>("form") >> + { >> + @Override >> + protected AutoCompleteBuilder >> getAutoCompleteBuilder() >> + { >> + return >> AutoCompleteBuilder.init().forAddressType(AutoCompleteAddres >> sType.BILLING).forField(AutoCompleteFields.GIVEN_NAME); >> + } >> + }); >> + } >> + >> + @Override >> + public IResourceStream >> getMarkupResourceStream(final MarkupContainer container, >> + Class<?> containerClass) >> + { >> + return new StringResourceStream("<form >> wicket:id='form'></form>"); >> + } >> + } >> + >> + TestPage testPage = new TestPage(); >> + tester.startPage(testPage); >> + assertTrue(tester.getLastResp >> onseAsString().contains("autocomplete=\"billing given-name\"")); >> + } >> >> /** >> * @throws Exception >> @@ -115,6 +148,12 @@ public class FormTest extends WicketTestCase >> { >> error = true; >> } >> + >> + @Override >> + protected AutoCompleteBuilder >> getAutoCompleteBuilder() >> + { >> + return >> AutoCompleteBuilder.init().forAddressType(AutoCompleteAddres >> sType.BILLING).forField(AutoCompleteFields.GIVEN_NAME); >> + } >> }); >> } >> >> >> http://git-wip-us.apache.org/repos/asf/wicket/blob/bcd55813/ >> wicket-core/src/test/java/org/apache/wicket/markup/html/form >> /TextFieldTest.java >> ---------------------------------------------------------------------- >> diff --git >> a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/TextFieldTest.java >> b/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/TextFieldTest.java >> index 5af5917..2c215e5 100644 >> --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/TextFieldTest.java >> +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/fo >> rm/TextFieldTest.java >> @@ -36,7 +36,20 @@ import org.junit.Test; >> */ >> public class TextFieldTest extends WicketTestCase >> { >> - /** */ >> + >> + /** >> + * Test auto complete feature >> + */ >> + @Test >> + public void testAutoComplete(){ >> + TestPage testPage = new TestPage(); >> + tester.startPage(testPage); >> + assertTrue(tester.getLastResp >> onseAsString().contains("autocomplete=\"section-blue billing name\"")); >> + } >> + >> + /** >> + * Test that inputs are converted to null >> + * */ >> @Test >> public void emptyInputConvertedToNull() >> { >> @@ -111,7 +124,13 @@ public class TextFieldTest extends WicketTestCase >> public TestPage() >> { >> add(form = new Form<>("form")); >> - form.add(textField = new TextField<>("text", >> textModel)); >> + form.add(textField = new >> TextField<String>("text", textModel){ >> + @Override >> + protected AutoCompleteBuilder >> getAutoCompleteBuilder() >> + { >> + return >> AutoCompleteBuilder.init().withSection("blue").forAddressTyp >> e(AutoCompleteAddressType.BILLING).forField(AutoCompleteFields.NAME); >> + } >> + }); >> } >> >> @Override >> >> >
