JBoss Rich Faces SVN: r22579 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richEditor and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-08-01 15:35:05 -0400 (Mon, 01 Aug 2011)
New Revision: 22579
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
Log:
Add validator attribute testing into rich:editor
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 18:42:52 UTC (rev 22578)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 19:35:05 UTC (rev 22579)
@@ -24,8 +24,12 @@
import java.io.Serializable;
import javax.annotation.PostConstruct;
+import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
import org.richfaces.component.UIEditor;
import org.richfaces.tests.metamer.Attributes;
@@ -59,6 +63,21 @@
attributes.remove("validator");
attributes.remove("validatorMessage");
}
+
+ /**
+ * Test method for verify validator attribute
+ * @param context
+ * @param component
+ * @param value
+ */
+ public void validateEditorValue(FacesContext context, UIComponent component, Object value) {
+ String testValue = value.toString();
+ if (testValue != null && testValue.contains("#")) {
+ throw new ValidatorException(
+ new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Editor must not contains '#' value!", "Editor must not contains '#' value!"));
+ }
+ }
public Attributes getAttributes() {
return attributes;
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 18:42:52 UTC (rev 22578)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 19:35:05 UTC (rev 22579)
@@ -54,6 +54,7 @@
styleClass="#{richEditorBean.attributes['styleClass'].value}"
title="#{richEditorBean.attributes['title'].value}"
toolbar="#{richEditorBean.attributes['toolbar'].value}"
+ validator="#{richEditorBean.validateEditorValue}"
value="#{richEditorBean.attributes['value'].value}"
valueChangeListener="#{richBean.valueChangeListenerImproved}"
width="#{richEditorBean.attributes['width'].value}" />
13 years, 5 months
JBoss Rich Faces SVN: r22578 - in modules/tests/metamer/trunk/application/src: main/webapp/components/richEditor and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-08-01 14:42:52 -0400 (Mon, 01 Aug 2011)
New Revision: 22578
Added:
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
Log:
Fix valueChangeListener attr in rich:editor
rich:editor is supposed to edit text longer than few chars.
Created handling method for tracking valueChange event with logging only
less than 20 chars per value.
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-08-01 16:29:56 UTC (rev 22577)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-08-01 18:42:52 UTC (rev 22578)
@@ -430,6 +430,26 @@
public void changeEventListener(ValueChangeEvent event) {
logToPage("*2 value changed: " + event.getOldValue() + " -> " + event.getNewValue());
}
+
+
+ /** A value change listener that logs to the page old and new value.
+ * But if event value was longer that 20 chars, only first 20 chars will
+ * be logged
+ *
+ * @param event
+ * an event representing the activation of a user interface component
+ */
+ public void valueChangeListenerImproved(ValueChangeEvent event) {
+
+ String oldVal = event.getOldValue() != null ? event.getOldValue().toString() : null;
+ String newVal = event.getNewValue() != null ? event.getNewValue().toString() : null;
+
+ logToPage("*3 value changed: "
+ + (oldVal != null && oldVal.length() > 21 ? oldVal.substring(0, 20) : oldVal != null ? oldVal : "null")
+ + " -> "
+ + (newVal != null && newVal.length() > 21 ? newVal.substring(0, 20) : newVal != null ? newVal : "null")
+ );
+ }
public boolean getExecuteChecker() {
return true;
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 16:29:56 UTC (rev 22577)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 18:42:52 UTC (rev 22578)
@@ -55,7 +55,7 @@
title="#{richEditorBean.attributes['title'].value}"
toolbar="#{richEditorBean.attributes['toolbar'].value}"
value="#{richEditorBean.attributes['value'].value}"
- valueChangeListener="#{richEditorBean.attributes['valueChangeListener'].value}"
+ valueChangeListener="#{richBean.valueChangeListenerImproved}"
width="#{richEditorBean.attributes['width'].value}" />
<br/>
Added: modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java
===================================================================
--- modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java 2011-08-01 18:42:52 UTC (rev 22578)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer;
+
+import javax.faces.event.ValueChangeEvent;
+
+import org.junit.Test;
+import org.richfaces.tests.metamer.bean.RichBean;
+
+/**
+ * Tests for RichBean testing methods
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class RichBeanTestCase {
+
+ /**
+ * Test method for {@link org.richfaces.tests.metamer.bean.RichBean#valueChangeListenerImproved(javax.faces.event.ValueChangeEvent)}.
+ */
+ @Test
+ public void testValueChangeListenerImproved() {
+
+ RichBean rb = new RichBean();
+ String oldValue = "";
+ String newValue = "";
+
+ ValueChangeEvent changeEvent = new ValueChangeEvent(null, oldValue, newValue);
+
+ rb.valueChangeListenerImproved(changeEvent);
+
+ }
+
+}
13 years, 5 months
JBoss Rich Faces SVN: r22577 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richEditor and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-08-01 12:29:56 -0400 (Mon, 01 Aug 2011)
New Revision: 22577
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
Log:
Removed validator and validatorMessage attribute.
Use validator attribute with binding by EL causes consider it as
validator id and possibly break lifecycle.
In addition, validatorMessage cause blank error message on "validation
exception" - caused by inproper configuration.
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 16:29:35 UTC (rev 22576)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 16:29:56 UTC (rev 22577)
@@ -56,6 +56,8 @@
attributes.remove("converter");
attributes.remove("converterMessage");
+ attributes.remove("validator");
+ attributes.remove("validatorMessage");
}
public Attributes getAttributes() {
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 16:29:35 UTC (rev 22576)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 16:29:56 UTC (rev 22577)
@@ -38,6 +38,8 @@
<ui:define name="component">
+ <rich:messages globalOnly="true" />
+ <rich:messages for="editor" />
<rich:editor id="editor"
height="#{richEditorBean.attributes['height'].value}"
immediate="#{richEditorBean.attributes['immediate'].value}"
@@ -52,8 +54,6 @@
styleClass="#{richEditorBean.attributes['styleClass'].value}"
title="#{richEditorBean.attributes['title'].value}"
toolbar="#{richEditorBean.attributes['toolbar'].value}"
- validator="#{richEditorBean.attributes['validator'].value}"
- validatorMessage="#{richEditorBean.attributes['validatorMessage'].value}"
value="#{richEditorBean.attributes['value'].value}"
valueChangeListener="#{richEditorBean.attributes['valueChangeListener'].value}"
width="#{richEditorBean.attributes['width'].value}" />
13 years, 5 months
JBoss Rich Faces SVN: r22576 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-08-01 12:29:35 -0400 (Mon, 01 Aug 2011)
New Revision: 22576
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
Log:
Make RichEditorBean view scoped and cache attributes
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 15:03:20 UTC (rev 22575)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 16:29:35 UTC (rev 22576)
@@ -25,6 +25,7 @@
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
import org.richfaces.component.UIEditor;
import org.richfaces.tests.metamer.Attributes;
@@ -38,16 +39,19 @@
* @version $Revision$
*/
@ManagedBean(name = "richEditorBean")
+@ViewScoped
public class RichEditorBean implements Serializable {
public static final Logger LOG = LoggerFactory.getLogger(RichEditorBean.class);
/** Genrated serial UID */
private static final long serialVersionUID = -6029256813894981250L;
- private Attributes attributes = Attributes.getComponentAttributesFromFacesConfig(UIEditor.class, getClass());
+ private Attributes attributes;
@PostConstruct
public void init(){
+ attributes = Attributes.getComponentAttributesFromFacesConfig(UIEditor.class, getClass());
+
attributes.setAttribute("rendered", Boolean.TRUE);
attributes.remove("converter");
13 years, 5 months
JBoss Rich Faces SVN: r22575 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richEditor and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-08-01 11:03:20 -0400 (Mon, 01 Aug 2011)
New Revision: 22575
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
Log:
Fix problem with value not sett to model
Problem was with unnecessary attribute converterMessage, which caused
hidden error and then break component lifecycle when value was submitted
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-07-29 12:50:47 UTC (rev 22574)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichEditorBean.java 2011-08-01 15:03:20 UTC (rev 22575)
@@ -51,6 +51,7 @@
attributes.setAttribute("rendered", Boolean.TRUE);
attributes.remove("converter");
+ attributes.remove("converterMessage");
}
public Attributes getAttributes() {
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-07-29 12:50:47 UTC (rev 22574)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01 15:03:20 UTC (rev 22575)
@@ -39,7 +39,6 @@
<ui:define name="component">
<rich:editor id="editor"
- converterMessage="#{richEditorBean.attributes['converterMessage'].value}"
height="#{richEditorBean.attributes['height'].value}"
immediate="#{richEditorBean.attributes['immediate'].value}"
onblur="#{richEditorBean.attributes['onblur'].value}"
@@ -60,7 +59,8 @@
width="#{richEditorBean.attributes['width'].value}" />
<br/>
- <h:commandButton id="hButton" value="Submit" />
+ <h:commandButton id="hButton" value="[h] Submit" />
+ <a4j:commandButton id="a4jButton" value="[a4j] Submit" render="output" />
<br/><br/>
Your text: <h:outputText id="output" value="#{richEditorBean.attributes['value'].value}"/>
13 years, 5 months