Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -21,6 +21,7 @@
*/

import org.gwtbootstrap3.client.ui.base.HasFormValue;
import org.gwtbootstrap3.client.ui.base.HasRequired;
import org.gwtbootstrap3.client.ui.constants.Styles;
import org.gwtbootstrap3.client.ui.gwt.ButtonBase;
import org.gwtbootstrap3.client.ui.gwt.FormPanel;
Expand Down Expand Up @@ -68,7 +69,7 @@
* </p>
*/
public class CheckBox extends ButtonBase implements HasName, HasValue<Boolean>, HasWordWrap, HasDirectionalSafeHtml,
HasDirectionEstimator, IsEditor<LeafValueEditor<Boolean>>, HasFormValue, HasChangeHandlers {
HasDirectionEstimator, IsEditor<LeafValueEditor<Boolean>>, HasFormValue, HasChangeHandlers, HasRequired {

protected final SpanElement labelElem = Document.get().createSpanElement();
protected final InputElement inputElem;
Expand Down Expand Up @@ -502,4 +503,17 @@ protected void onUnload() {
setValue(getValue());
}

@Override
public void setRequired(boolean required) {
if (required) {
inputElem.setAttribute(HasRequired.REQUIRED, HasRequired.REQUIRED);
} else {
inputElem.removeAttribute(HasRequired.REQUIRED);
}
}

@Override
public boolean getRequired() {
return inputElem.hasAttribute(HasRequired.REQUIRED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.gwtbootstrap3.client.ui.base;

/*
* #%L
* GwtBootstrap3
* %%
* Copyright (C) 2013 GwtBootstrap3
* %%
* Licensed 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.
* #L%
*/

/**
* @author Pontus Enmark
*/
public interface HasRequired {
String REQUIRED = "required";

void setRequired(boolean required);

boolean getRequired();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import com.google.web.bindery.event.shared.HandlerRegistration;

public class ValueBoxBase<T> extends com.google.gwt.user.client.ui.ValueBoxBase<T> implements HasId, HasReadOnly,
HasResponsiveness, HasPlaceholder, HasAutoComplete, HasSize<InputSize>, HasEditorErrors<T>,
HasResponsiveness, HasPlaceholder, HasAutoComplete, HasRequired, HasSize<InputSize>, HasEditorErrors<T>,
HasErrorHandler, HasValidators<T>, HasBlankValidator<T> {

private static final String MAX_LENGTH = "maxlength";
Expand Down Expand Up @@ -214,4 +214,17 @@ public HandlerRegistration addValidationChangedHandler(ValidationChangedHandler
return validatorMixin.addValidationChangedHandler(handler);
}

@Override
public void setRequired(boolean required) {
if (required) {
getElement().setAttribute(HasRequired.REQUIRED, HasRequired.REQUIRED);
} else {
getElement().removeAttribute(HasRequired.REQUIRED);
}
}

@Override
public boolean getRequired() {
return getElement().hasAttribute(HasRequired.REQUIRED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ interface IFrameTemplate extends SafeHtmlTemplates {
private Element synthesizedFrame;

public AbstractForm() {
this(true);
this(false);
}

public AbstractForm(boolean createIFrame) {
Expand Down