org.jboss.logmanager.LogManager
diff --git a/src/main/java/net/bootsfaces/component/InputText.java b/src/main/java/net/bootsfaces/component/InputText.java
index e043f83c2..98fc8e361 100644
--- a/src/main/java/net/bootsfaces/component/InputText.java
+++ b/src/main/java/net/bootsfaces/component/InputText.java
@@ -1,22 +1,16 @@
/**
- * Copyright 2014 Riccardo Massera (TheCoder4.Eu)
- *
- * This file is part of BootsFaces.
- *
- * BootsFaces is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Copyright 2014 Riccardo Massera (TheCoder4.Eu)
*
- * BootsFaces is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * This file is part of BootsFaces.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with BootsFaces. If not, see .
+ * BootsFaces is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * BootsFaces is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with BootsFaces. If not, see .
*/
-
package net.bootsfaces.component;
import javax.faces.application.ResourceDependencies;
@@ -31,72 +25,78 @@
*
* @author thecoder4.eu
*/
-
@ResourceDependencies({
- @ResourceDependency(library="bsf", name="css/core.css", target="head"),
- @ResourceDependency(library="bsf", name="css/bsf.css", target="head")
+ @ResourceDependency(library = "bsf", name = "css/core.css", target = "head"),
+ @ResourceDependency(library = "bsf", name = "css/bsf.css", target = "head")
})
@FacesComponent(C.INPUTTEXT_COMPONENT_TYPE)
public class InputText extends HtmlInputText {
-
+
/**
- * The standard component type for this component.
+ *
+ * The standard component type for this component.
*/
- public static final String COMPONENT_TYPE =C.INPUTTEXT_COMPONENT_TYPE;
+ public static final String COMPONENT_TYPE = C.INPUTTEXT_COMPONENT_TYPE;
/**
- * The component family for this component.
+ *
+ * The component family for this component.
*/
public static final String COMPONENT_FAMILY = C.BSFCOMPONENT;
-
- public static final String ADDON="input-group-addon";
-
+
+ public static final String ADDON = "input-group-addon";
+
protected enum PropertyKeys {
- placeholder
- ,fieldSize
- ,type;
+ placeholder,
+ fieldSize,
+ type;
+
+ String toString;
- String toString;
+ PropertyKeys(String toString) {
+ this.toString = toString;
+ }
- PropertyKeys(String toString) {
- this.toString = toString;
- }
+ PropertyKeys() {
+ }
- PropertyKeys() {}
+ public String toString() {
+ return ((this.toString != null) ? this.toString : super.toString());
+ }
+ }
- public String toString() {
- return ((this.toString != null) ? this.toString : super.toString());
- }
- }
-
public InputText() {
- setRendererType("net.bootsfaces.component.InputTextRenderer");
- Tooltip.addResourceFile();
+ setRendererType("net.bootsfaces.component.InputTextRenderer");
+ Tooltip.addResourceFile();
}
-
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
}
-
- public java.lang.String getPlaceholder() {
- return (java.lang.String) getStateHelper().eval(PropertyKeys.placeholder, null);
- }
- public void setPlaceholder(java.lang.String _placeholder) {
- getStateHelper().put(PropertyKeys.placeholder, _placeholder);
- }
- public java.lang.String getFieldSize() {
- return (java.lang.String) getStateHelper().eval(PropertyKeys.fieldSize, null);
- }
- public void setFieldSize(java.lang.String _fieldSize) {
- getStateHelper().put(PropertyKeys.fieldSize, _fieldSize);
- }
- public java.lang.String getType() {
- return (java.lang.String) getStateHelper().eval(PropertyKeys.type, "text");
- }
- public void setType(java.lang.String _type) {
- getStateHelper().put(PropertyKeys.type, _type);
- }
-
+
+ public java.lang.String getPlaceholder() {
+ return (java.lang.String) getStateHelper().eval(PropertyKeys.placeholder, null);
+ }
+
+ public void setPlaceholder(java.lang.String _placeholder) {
+ getStateHelper().put(PropertyKeys.placeholder, _placeholder);
+ }
+
+ public java.lang.String getFieldSize() {
+ return (java.lang.String) getStateHelper().eval(PropertyKeys.fieldSize, null);
+ }
+
+ public void setFieldSize(java.lang.String _fieldSize) {
+ getStateHelper().put(PropertyKeys.fieldSize, _fieldSize);
+ }
+
+ public java.lang.String getType() {
+ return (java.lang.String) getStateHelper().eval(PropertyKeys.type, "text");
+ }
+
+ public void setType(java.lang.String _type) {
+ getStateHelper().put(PropertyKeys.type, _type);
+ }
}
diff --git a/src/main/java/net/bootsfaces/render/A.java b/src/main/java/net/bootsfaces/render/A.java
index c7a4f5f15..339d4bbf1 100644
--- a/src/main/java/net/bootsfaces/render/A.java
+++ b/src/main/java/net/bootsfaces/render/A.java
@@ -196,7 +196,7 @@ public static String asString(Map attrs, Object o) {
public static final String[] ALLBUTTON_ATTRS = A.concatAll( H.ALLBUTTON, E.DBLCLICK, E.FOCUS, E.MOUSE);
public static final String[] CHECKBOX_ATTRS = A.concatAll( H.CHECKBOX, E.CLICK, E.FOCUS, E.MOUSE, E.CHANGE_SELECT);
- public static final String[] INPUT_TEXT_ATTRS = A.concatAll( H.INPUT_TEXT, E.CLICK, E.FOCUS, E.MOUSE);
+ public static final String[] INPUT_TEXT_ATTRS = A.concatAll( H.INPUT_TEXT, E.CLICK, E.FOCUS, E.MOUSE, E.CHANGE_SELECT);
public static final String[] TAB_ATTRS = A.concatAll( H.TAB, E.DBLCLICK, E.FOCUS, E.MOUSE);
public static final String[] TAB_VIEW_ATTRS = A.concatAll( H.TAB_VIEW, E.CLICK, E.FOCUS, E.MOUSE);
public static final String[] SELECT_ONE_MENU_ATTRS = A.concatAll( H.SELECT_ONE_MENU, E.CLICK, E.FOCUS, E.MOUSE);
diff --git a/src/main/java/net/bootsfaces/component/InputTextRenderer.java b/src/main/java/net/bootsfaces/render/InputTextRenderer.java
similarity index 96%
rename from src/main/java/net/bootsfaces/component/InputTextRenderer.java
rename to src/main/java/net/bootsfaces/render/InputTextRenderer.java
index 7e8d96534..f38b5136b 100644
--- a/src/main/java/net/bootsfaces/component/InputTextRenderer.java
+++ b/src/main/java/net/bootsfaces/render/InputTextRenderer.java
@@ -1,4 +1,4 @@
-package net.bootsfaces.component;
+package net.bootsfaces.render;
import java.io.IOException;
import java.util.List;
@@ -6,7 +6,6 @@
import java.util.Set;
import javax.el.ValueExpression;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.component.behavior.ClientBehavior;
@@ -18,11 +17,8 @@
import javax.faces.render.FacesRenderer;
import net.bootsfaces.C;
-import net.bootsfaces.render.A;
-import net.bootsfaces.render.CoreRenderer;
-import net.bootsfaces.render.H;
-import net.bootsfaces.render.R;
-import net.bootsfaces.render.Tooltip;
+import net.bootsfaces.component.InputSecret;
+import net.bootsfaces.component.InputText;
@FacesRenderer(componentFamily = C.BSFCOMPONENT, rendererType = "net.bootsfaces.component.InputTextRenderer")
public class InputTextRenderer extends CoreRenderer {
diff --git a/src/test/java/net/bootsfaces/component/InputTextITCase.java b/src/test/java/net/bootsfaces/component/InputTextITCase.java
new file mode 100644
index 000000000..5c3a87a67
--- /dev/null
+++ b/src/test/java/net/bootsfaces/component/InputTextITCase.java
@@ -0,0 +1,142 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.bootsfaces.component;
+
+import java.io.IOException;
+import net.bootsfaces.component.validators.RequiredInputTextValidator;
+import net.bootsfaces.IntegrationTestsBase;
+import org.jboss.arquillian.container.test.api.Deployment;
+import static org.jboss.arquillian.graphene.Graphene.guardAjax;
+import org.jboss.arquillian.graphene.GrapheneElement;
+import org.jboss.arquillian.graphene.findby.FindByJQuery;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.support.FindBy;
+
+/**
+ * Simple test which validates the rendered information for b:selectbooleancheckbox tag.
+ * It opens the SelectBooleanCheckBox.xhtml file and assert that the rendered information is
+ * correct.
+ *
+ * @author yersan
+ */
+@RunWith(Arquillian.class)
+public class InputTextITCase extends IntegrationTestsBase {
+
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ WebArchive deployment = createBaseDeployment()
+ .addClass(InputTextSessionBean.class)
+ .addClass(RequiredInputTextValidator.class)
+ .addAsWebResource("inputText.xhtml");
+
+
+ System.out.println(deployment.toString(true));
+
+ return deployment;
+ }
+
+ @Before
+ public void setup() throws IOException {
+ browser.get(context + "/faces/inputText.xhtml");
+ }
+
+
+ @FindBy(id = "txt_1")
+ private GrapheneElement txt_1;
+
+ @FindBy(id = "txt_2")
+ private GrapheneElement txt_2;
+
+ @FindBy(id = "txt_3")
+ private GrapheneElement txt_3;
+
+ @FindBy(id = "cmd")
+ private GrapheneElement cmd;
+
+ @FindBy(id = "msg")
+ private GrapheneElement msg;
+
+ @FindByJQuery("#msg li")
+ private GrapheneElement facesMessage;
+
+ @FindBy(id = "txt_1_label")
+ private GrapheneElement txt_1_label;
+
+
+
+
+ @Test
+ @InSequence(1)
+ public void testInputTextRender() {
+ String pageTitle = browser.getTitle();
+
+ //assert page title
+ assertEquals("InputText IT", pageTitle);
+
+ assertTrue("txt_1 rendered failed", txt_1.getAttribute("onchange").equals("var dummy=0;"));
+ assertTrue("txt_1 rendered failed", txt_1.getAttribute("onselect").equals("var dummy=0;"));
+ }
+
+ @Test
+ @InSequence(10)
+ public void testInputTextValidator() {
+
+ //assert that there is no message
+ assertFalse(facesMessage.isPresent());
+
+
+ txt_2.clear();
+
+ //submit
+ guardAjax(cmd).click();
+
+ //assert that there is no message
+ assertTrue(facesMessage.getText().contains(RequiredInputTextValidator.VALUE_REQUIRED_MSG));
+
+
+ txt_2.sendKeys("DUMMY");
+
+ }
+
+ @Test
+ @InSequence(20)
+ public void testInputTextBinding() {
+ //binding value was set in backed bean, must be checked
+ assertTrue("txt_3 binding failed", txt_3.getAttribute("value").contains("VALUE BINDING"));
+ }
+
+
+ @Test
+ @InSequence(30)
+ public void testInputTextValuechangeListener() {
+
+ txt_1.clear();
+
+ //change listener count is 0 ?
+ assertTrue(txt_1_label.getText().contains("0"));
+
+ txt_1.sendKeys("CHANGED VALUE");
+
+ //submit
+ guardAjax(cmd).click();
+
+ //binding value was set in backed bean, must be checked
+ //change listener count is 0 ?
+ assertTrue(txt_1_label.getText().contains("1"));
+ }
+
+
+
+
+
+}
diff --git a/src/test/java/net/bootsfaces/component/InputTextSessionBean.java b/src/test/java/net/bootsfaces/component/InputTextSessionBean.java
new file mode 100644
index 000000000..5f949b793
--- /dev/null
+++ b/src/test/java/net/bootsfaces/component/InputTextSessionBean.java
@@ -0,0 +1,69 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.bootsfaces.component;
+
+import java.io.Serializable;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.event.ValueChangeEvent;
+import javax.inject.Named;
+
+/**
+ *
+ * @author yersan
+ */
+@Named
+@SessionScoped
+public class InputTextSessionBean implements Serializable {
+
+ private String txtValue1 = "";
+ private String txtValue2 = "DUMMY";
+ private int valueChangeCount = 0;
+ private InputText inputText;
+
+ public String getTxtValue1() {
+ return txtValue1;
+ }
+
+ public void setTxtValue1(String txtValue1) {
+ this.txtValue1 = txtValue1;
+ }
+
+ public String getTxtValue2() {
+ return txtValue2;
+ }
+
+ public void setTxtValue2(String txtValue2) {
+ this.txtValue2 = txtValue2;
+ }
+
+
+ public void ajaxAction(){
+ }
+
+ public void valueChangeMethod(ValueChangeEvent e){
+ valueChangeCount++;
+ }
+
+ public int getValueChangeCount() {
+ return valueChangeCount;
+ }
+
+ public void setValueChangeCount(int valueChangeCount) {
+ this.valueChangeCount = valueChangeCount;
+ }
+
+ public InputText getInputText() {
+ if ( inputText == null ) {
+ inputText = new InputText();
+ inputText.setValue("VALUE BINDING");
+ }
+ return inputText;
+ }
+
+ public void setInputText(InputText inputText) {
+ this.inputText = inputText;
+ }
+}
diff --git a/src/test/java/net/boostfaces/component/SelectBooleanCheckBoxITCase.java b/src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxITCase.java
similarity index 89%
rename from src/test/java/net/boostfaces/component/SelectBooleanCheckBoxITCase.java
rename to src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxITCase.java
index 5c673e5d2..2c9fb4de3 100644
--- a/src/test/java/net/boostfaces/component/SelectBooleanCheckBoxITCase.java
+++ b/src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxITCase.java
@@ -3,11 +3,10 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package net.boostfaces.component;
+package net.bootsfaces.component;
+import net.bootsfaces.component.validators.RequiredCheckBoxValidator;
import java.io.IOException;
-import javax.inject.Inject;
-import javax.persistence.SequenceGenerator;
import net.bootsfaces.IntegrationTestsBase;
import org.jboss.arquillian.container.test.api.Deployment;
import static org.jboss.arquillian.graphene.Graphene.guardAjax;
@@ -37,8 +36,8 @@ public class SelectBooleanCheckBoxITCase extends IntegrationTestsBase {
public static WebArchive createDeployment() {
WebArchive deployment = createBaseDeployment()
.addClass(SelectBooleanCheckBoxSessionBean.class)
- .addClass(RequiredCheckboxValidator.class)
- .addAsWebResource("SelectBooleanCheckBox.xhtml");
+ .addClass(RequiredCheckBoxValidator.class)
+ .addAsWebResource("selectBooleanCheckBox.xhtml");
System.out.println(deployment.toString(true));
@@ -48,9 +47,10 @@ public static WebArchive createDeployment() {
@Before
public void setup() throws IOException {
- browser.get(context + "/faces/SelectBooleanCheckBox.xhtml");
+ browser.get(context + "/faces/selectBooleanCheckBox.xhtml");
}
+
@FindBy(id = "chk_1")
private GrapheneElement chk_1;
@@ -101,7 +101,7 @@ public void testSelectBooleanCheckBoxValidator() {
guardAjax(cmd).click();
//assert that there is no message
- assertTrue(facesMessage.getText().contains("chk_2 CheckBox value required"));
+ assertTrue(facesMessage.getText().contains(RequiredCheckBoxValidator.VALUE_REQUIRED_MSG));
}
diff --git a/src/test/java/net/boostfaces/component/SelectBooleanCheckBoxSessionBean.java b/src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxSessionBean.java
similarity index 95%
rename from src/test/java/net/boostfaces/component/SelectBooleanCheckBoxSessionBean.java
rename to src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxSessionBean.java
index 86afda470..65c45df5b 100644
--- a/src/test/java/net/boostfaces/component/SelectBooleanCheckBoxSessionBean.java
+++ b/src/test/java/net/bootsfaces/component/SelectBooleanCheckBoxSessionBean.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package net.boostfaces.component;
+package net.bootsfaces.component;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
@@ -21,7 +21,7 @@ public class SelectBooleanCheckBoxSessionBean implements Serializable {
private boolean boolValue1;
private boolean boolValue2 = true;
- private int valueChangeCount;
+ private int valueChangeCount = 0;
private SelectBooleanCheckbox booleanCheckbox;
diff --git a/src/test/java/net/boostfaces/component/RequiredCheckboxValidator.java b/src/test/java/net/bootsfaces/component/validators/RequiredCheckBoxValidator.java
similarity index 71%
rename from src/test/java/net/boostfaces/component/RequiredCheckboxValidator.java
rename to src/test/java/net/bootsfaces/component/validators/RequiredCheckBoxValidator.java
index b7fd8ad8d..1255f74e4 100644
--- a/src/test/java/net/boostfaces/component/RequiredCheckboxValidator.java
+++ b/src/test/java/net/bootsfaces/component/validators/RequiredCheckBoxValidator.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package net.boostfaces.component;
+package net.bootsfaces.component.validators;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
@@ -16,14 +16,15 @@
*
* @author ysantana
*/
-@FacesValidator("net.bootsfaces.requiredCheckBoxValidator")
-public class RequiredCheckboxValidator implements Validator{
+@FacesValidator("net.bootsfaces.validators.requiredCheckBoxValidator")
+public class RequiredCheckBoxValidator implements Validator {
+ public final static String VALUE_REQUIRED_MSG = "CheckBox value required";
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
if (value.equals(Boolean.FALSE)) {
throw new ValidatorException(
- new FacesMessage(FacesMessage.SEVERITY_ERROR, component.getClientId(), "CheckBox value required"));
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, component.getClientId(), VALUE_REQUIRED_MSG));
}
}
}
diff --git a/src/test/java/net/bootsfaces/component/validators/RequiredInputTextValidator.java b/src/test/java/net/bootsfaces/component/validators/RequiredInputTextValidator.java
new file mode 100644
index 000000000..e9fe35a74
--- /dev/null
+++ b/src/test/java/net/bootsfaces/component/validators/RequiredInputTextValidator.java
@@ -0,0 +1,31 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.bootsfaces.component.validators;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+/**
+ *
+ * @author ysantana
+ */
+@FacesValidator(RequiredInputTextValidator.VALIDATOR)
+public class RequiredInputTextValidator implements Validator {
+ public final static String VALUE_REQUIRED_MSG = "InputText value required";
+ public final static String VALIDATOR = "net.bootsfaces.validators.requiredInputTextValidator";
+
+ @Override
+ public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
+ if (value == null || value.equals("")) {
+ throw new ValidatorException(
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, component.getClientId(), VALUE_REQUIRED_MSG));
+ }
+ }
+}
diff --git a/src/test/resources/webapp/inputText.xhtml b/src/test/resources/webapp/inputText.xhtml
new file mode 100644
index 000000000..e7d441af2
--- /dev/null
+++ b/src/test/resources/webapp/inputText.xhtml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ InputText IT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/webapp/SelectBooleanCheckBox.xhtml b/src/test/resources/webapp/selectBooleanCheckBox.xhtml
similarity index 90%
rename from src/test/resources/webapp/SelectBooleanCheckBox.xhtml
rename to src/test/resources/webapp/selectBooleanCheckBox.xhtml
index a5de893aa..f206792ba 100644
--- a/src/test/resources/webapp/SelectBooleanCheckBox.xhtml
+++ b/src/test/resources/webapp/selectBooleanCheckBox.xhtml
@@ -21,12 +21,12 @@
-
+
-
+