Author: jjamrich
Date: 2011-04-21 06:26:42 -0400 (Thu, 21 Apr 2011)
New Revision: 22434
Added:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichMessagesBean.properties
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessageBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessagesBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MultipleValidationRulesBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/csv.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsfValidator.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsr303.xhtml
Log:
Add support to verify globalOnly attribute
There is related JIRA:
https://issues.jboss.org/browse/RF-7351.
Problem with 'globalOnly' parameter is that it is incompatible with
'for', so there are 2 instances of rich:messsages components.
Add new button for generate FacesMessage without bind to any component
(global message)
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessageBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessageBean.java 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessageBean.java 2011-04-21
10:26:42 UTC (rev 22434)
@@ -21,6 +21,8 @@
*******************************************************************************/
package org.richfaces.tests.metamer.bean;
+import java.io.Serializable;
+
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@@ -38,8 +40,10 @@
*/
@ManagedBean(name = "richMessageBean")
@ViewScoped
-public class RichMessageBean {
+public class RichMessageBean implements Serializable {
+ /** Generated UID */
+ private static final long serialVersionUID = -5058242586244822846L;
private static Logger logger;
private Attributes attributes;
private String simpleInput1;
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessagesBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessagesBean.java 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichMessagesBean.java 2011-04-21
10:26:42 UTC (rev 22434)
@@ -21,9 +21,14 @@
*******************************************************************************/
package org.richfaces.tests.metamer.bean;
+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.context.FacesContext;
+import javax.faces.event.ActionEvent;
import org.richfaces.component.UIRichMessages;
import org.richfaces.tests.metamer.Attributes;
@@ -38,8 +43,10 @@
*/
@ManagedBean(name = "richMessagesBean")
@ViewScoped
-public class RichMessagesBean {
+public class RichMessagesBean implements Serializable {
+ /** Generated UID */
+ private static final long serialVersionUID = 4893769498631480379L;
private static Logger logger;
private Attributes attributes;
@@ -52,11 +59,25 @@
logger.info("initializing bean " + getClass().getName());
attributes =
Attributes.getComponentAttributesFromFacesConfig(UIRichMessages.class, getClass());
+ simpleInput1 = "10";
+ simpleInput2 = "10";
+
attributes.setAttribute("ajaxRendered", true);
attributes.setAttribute("rendered", true);
attributes.setAttribute("for", "simpleInput1");
attributes.setAttribute("showSummary", true);
}
+
+ public void generateFacesError(ActionEvent event) {
+
+ logger.info(" ### Just called generateFacesError()");
+
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, "Generated error
message", "Generated error message"));
+
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_WARN, "Generated warning
message", "Generated warning message"));
+ }
public Attributes getAttributes() {
return attributes;
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MultipleValidationRulesBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MultipleValidationRulesBean.java 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MultipleValidationRulesBean.java 2011-04-21
10:26:42 UTC (rev 22434)
@@ -27,7 +27,9 @@
import javax.validation.constraints.Min;
/**
- * Simple bean with property with more than one validation
+ * Simple bean with property with more than one validation.
+ * This is not very logic validation, but its useful for testing
+ * rich:messages component - where need more validation messages per input
*
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
* @version $Revision$
@@ -54,7 +56,7 @@
@Override
public String getDescription() {
- return "Integer between 5 and 150, but at less than 3 digits";
+ return "Integer between 5 and 150, but less than 3 digits";
}
@Override
Added:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichMessagesBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichMessagesBean.properties
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichMessagesBean.properties 2011-04-21
10:26:42 UTC (rev 22434)
@@ -0,0 +1,3 @@
+attr.for.simpleInput1=simpleInput1
+attr.for.simpleInput2=simpleInput2
+attr.for.null=
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/csv.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/csv.xhtml 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/csv.xhtml 2011-04-21
10:26:42 UTC (rev 22434)
@@ -61,8 +61,26 @@
<input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
<input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
- <rich:messages id="msgs"
+ <fieldset title="Msgs1 - with for attribute" >
+ <legend>Messages1 - with 'for' attribute</legend>
+ <rich:messages id="msgs1"
for="#{richMessagesBean.attributes['for'].value}"
+
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
+
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
+
rendered="#{richMessagesBean.attributes['rendered'].value}"
+
showDetail="#{richMessagesBean.attributes['showDetail'].value}"
+
showSummary="#{richMessagesBean.attributes['showSummary'].value}"
+
style="#{richMessagesBean.attributes['style'].value}"
+
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
+
title="#{richMessagesBean.attributes['title'].value}"
+ />
+ </fieldset>
+
+ <br/>
+
+ <fieldset title="Msgs2 - with globalOnly attribute">
+ <legend>Messages2 - without 'for' but 'globalOnly'
attribute instead</legend>
+ <rich:messages id="msgs2"
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
globalOnly="#{richMessagesBean.attributes['globalOnly'].value}"
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
@@ -72,7 +90,9 @@
style="#{richMessagesBean.attributes['style'].value}"
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
title="#{richMessagesBean.attributes['title'].value}"
- />
+ />
+ </fieldset>
+
<h:panelGrid columns="3">
<h:outputLabel for="simpleInput1"
value="#{multipleValidationRulesBean.description}" />
<h:inputText id="simpleInput1"
value="#{multipleValidationRulesBean.value}" label="Input 1"
@@ -93,9 +113,11 @@
<h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
<a4j:commandButton id="a4jButton"
value="a4j:commandButton"/>
+ <a4j:commandButton id="generateMsgsBtn" value="Generate
Msgs"
+ actionListener="#{richMessagesBean.generateFacesError}"
/>
<br/>
- <rich:messages id="msgs2" />
+ <rich:messages id="msgs" />
</ui:define>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsfValidator.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsfValidator.xhtml 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsfValidator.xhtml 2011-04-21
10:26:42 UTC (rev 22434)
@@ -56,8 +56,26 @@
<input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
<input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
- <rich:messages id="msgs"
+ <fieldset title="Msgs1 - with for attribute" >
+ <legend>Messages1 - with 'for' attribute</legend>
+ <rich:messages id="msgs1"
for="#{richMessagesBean.attributes['for'].value}"
+
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
+
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
+
rendered="#{richMessagesBean.attributes['rendered'].value}"
+
showDetail="#{richMessagesBean.attributes['showDetail'].value}"
+
showSummary="#{richMessagesBean.attributes['showSummary'].value}"
+
style="#{richMessagesBean.attributes['style'].value}"
+
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
+
title="#{richMessagesBean.attributes['title'].value}"
+ />
+ </fieldset>
+
+ <br/>
+
+ <fieldset title="Msgs2 - with globalOnly attribute">
+ <legend>Messages2 - without 'for' but 'globalOnly'
attribute instead</legend>
+ <rich:messages id="msgs2"
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
globalOnly="#{richMessagesBean.attributes['globalOnly'].value}"
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
@@ -67,7 +85,9 @@
style="#{richMessagesBean.attributes['style'].value}"
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
title="#{richMessagesBean.attributes['title'].value}"
- />
+ />
+ </fieldset>
+
<h:panelGrid columns="3">
<h:outputLabel for="simpleInput1"
value="#{multipleValidationRulesBean.description}" />
<h:inputText id="simpleInput1"
value="#{richMessagesBean.simpleInput1}" label="Input 1" >
@@ -88,9 +108,11 @@
<h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
<a4j:commandButton id="a4jButton"
value="a4j:commandButton"/>
+ <a4j:commandButton id="generateMsgsBtn" value="Generate
Msgs"
+ actionListener="#{richMessagesBean.generateFacesError}"
/>
<br/>
- <rich:messages id="msgs2" />
+ <rich:messages id="msgs" />
</ui:define>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsr303.xhtml 2011-04-20
13:29:05 UTC (rev 22433)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richMessages/jsr303.xhtml 2011-04-21
10:26:42 UTC (rev 22434)
@@ -60,9 +60,29 @@
<input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
<input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
+
+ <br/>
- <rich:messages id="msgs"
+ <fieldset title="Msgs1 - with for attribute" >
+ <legend>Messages1 - with 'for' attribute</legend>
+ <rich:messages id="msgs1"
for="#{richMessagesBean.attributes['for'].value}"
+
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
+
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
+
rendered="#{richMessagesBean.attributes['rendered'].value}"
+
showDetail="#{richMessagesBean.attributes['showDetail'].value}"
+
showSummary="#{richMessagesBean.attributes['showSummary'].value}"
+
style="#{richMessagesBean.attributes['style'].value}"
+
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
+
title="#{richMessagesBean.attributes['title'].value}"
+ />
+ </fieldset>
+
+ <br/>
+
+ <fieldset title="Msgs2 - with globalOnly attribute">
+ <legend>Messages2 - without 'for' but 'globalOnly'
attribute instead</legend>
+ <rich:messages id="msgs2"
ajaxRendered="#{richMessagesBean.attributes['ajaxRendered'].value}"
globalOnly="#{richMessagesBean.attributes['globalOnly'].value}"
keepTransient="#{richMessagesBean.attributes['keepTransient'].value}"
@@ -72,7 +92,9 @@
style="#{richMessagesBean.attributes['style'].value}"
styleClass="#{richMessagesBean.attributes['styleClass'].value}"
title="#{richMessagesBean.attributes['title'].value}"
- />
+ />
+ </fieldset>
+
<h:panelGrid columns="3">
<h:outputLabel for="simpleInput1"
value="#{multipleValidationRulesBean.description}" />
<h:inputText id="simpleInput1"
value="#{multipleValidationRulesBean.value}" label="Input 1"
@@ -89,9 +111,11 @@
<h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
<a4j:commandButton id="a4jButton"
value="a4j:commandButton"/>
+ <a4j:commandButton id="generateMsgsBtn" value="Generate
Msgs"
+ actionListener="#{richMessagesBean.generateFacesError}"
/>
<br/>
- <rich:messages id="msgs2" />
+ <rich:messages id="msgs" />
</ui:define>