Author: amarkhel
Date: 2008-09-12 05:55:45 -0400 (Fri, 12 Sep 2008)
New Revision: 10418
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
Log:
Fix RF-4451 bug
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java 2008-09-11
18:01:12 UTC (rev 10417)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java 2008-09-12
09:55:45 UTC (rev 10418)
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -18,6 +19,7 @@
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
import javax.faces.component.UIMessage;
+import javax.faces.component.UIMessages;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -45,6 +47,7 @@
public static final String COMPONENT_FAMILY =
"org.richfaces.BeanValidator";
public static final String BEAN_VALIDATOR_FACET =
"org.richfaces.validator.";
+
@Override
public void setParent(UIComponent parent) {
@@ -122,8 +125,8 @@
public void encodeAjax(FacesContext context) throws IOException {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
Set<String> renderedAreas = ajaxContext.getAjaxRenderedAreas();
- List<UIMessage> messages = getMessages(context);
- for (UIMessage message : messages) {
+ List<UIComponent> allMessages = getMessages(context);
+ for (UIComponent message : allMessages) {
if (message.isRendered()) {
message.encodeAll(context);
renderedAreas.add(message.getClientId(context));
@@ -133,8 +136,8 @@
AjaxRendererUtils.encodeAreas(context, this);
}
- public List<UIMessage> getMessages(FacesContext context) {
- ArrayList<UIMessage> messages = new ArrayList<UIMessage>();
+ public List<UIComponent> getMessages(FacesContext context) {
+ ArrayList<UIComponent> messages = new ArrayList<UIComponent>();
UIComponent form = AjaxRendererUtils.getNestingForm(this);
if (null == form) {
form = context.getViewRoot();
@@ -149,19 +152,22 @@
* @param component
* @param messages
*/
- protected void findMessages(UIComponent component, ArrayList<UIMessage>
messages) {
+ protected void findMessages(UIComponent component, ArrayList<UIComponent>
messages) {
// TODO create more intellectual search, symmenric for an UIMessage
// algoritm.
Iterator<UIComponent> facetsAndChildren =
component.getFacetsAndChildren();
while (facetsAndChildren.hasNext()) {
UIComponent child = (UIComponent) facetsAndChildren.next();
- if (child instanceof UIMessage) {
- UIMessage message = (UIMessage) child;
- String messageFor = message.getFor();
+ if (child instanceof UIMessage || child instanceof UIMessages) {
+ UIComponent message = (UIComponent) child;
+ Object messag = message.getAttributes().get("for");
+ String messageFor = messag != null ? messag.toString() : null ;
+
if (null != messageFor && messageFor.equals(getParent().getId()))
{
messages.add(message);
}
- } else {
+ }
+ else {
findMessages(child, messages);
}
}
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2008-09-11
18:01:12 UTC (rev 10417)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2008-09-12
09:55:45 UTC (rev 10418)
@@ -83,8 +83,10 @@
// send all validation messages.
for (String msg : messages) {
// TODO - create Summary message ?
+ String summaryString = getSummary()!=null?getSummary():msg;
+
context.addMessage(component.getClientId(context), new FacesMessage(
- FacesMessage.SEVERITY_ERROR, getSummary(), msg));
+ FacesMessage.SEVERITY_ERROR, summaryString , msg));
}
}
}
Show replies by date