Author: alexsmirnov
Date: 2011-02-04 18:59:32 -0500 (Fri, 04 Feb 2011)
New Revision: 21476
Added:
trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessage.java
trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessages.java
trunk/ui/validator/ui/src/main/java/org/richfaces/component/ClientSideMessage.java
Removed:
trunk/ui/validator/ui/src/main/config/messages.xml
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/dataTableEdit-sample.xhtml
trunk/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
Log:
CODING IN PROGRESS - issue RF-10293: richfaces-showcase: message: not updated via ajax but
h:message + outputPanel does.
https://issues.jboss.org/browse/RF-10293
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/dataTableEdit-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/dataTableEdit-sample.xhtml 2011-02-04
23:03:36 UTC (rev 21475)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/dataTableEdit-sample.xhtml 2011-02-04
23:59:32 UTC (rev 21476)
@@ -92,18 +92,18 @@
<h:inputText value="#{carsBean.editedCar.price}"
required="true"
requiredMessage="Price is required" id="price"
validatorMessage="Should be a valid price" label="Price field"
/>
- <rich:message for="price" />
+ <rich:message for="price" ajaxRendered="true"/>
<h:outputText value="Mileage" />
<h:inputText value="#{carsBean.editedCar.mileage}" id="mage"
validatorMessage="Should be a valid mileage" label="Mileage
field" />
- <rich:message for="mage" />
+ <rich:message for="mage" ajaxRendered="true"/>
<h:outputText value="VIN" />
<h:inputText value="#{carsBean.editedCar.vin}" id="vin"
required="true" validatorMessage="Not a valid 17-digit VIN"
requiredMessage="VIN is required">
<f:validateLength minimum="17" maximum="17" />
</h:inputText>
- <rich:message for="vin" />
+ <rich:message for="vin" ajaxRendered="true"/>
</h:panelGrid>
<a4j:commandButton value="Store" action="#{carsBean.store}"
render="table" execute="@form"
Deleted: trunk/ui/validator/ui/src/main/config/messages.xml
===================================================================
--- trunk/ui/validator/ui/src/main/config/messages.xml 2011-02-04 23:03:36 UTC (rev
21475)
+++ trunk/ui/validator/ui/src/main/config/messages.xml 2011-02-04 23:59:32 UTC (rev
21476)
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
-<faces-config version="2.0" metadata-complete="false"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
-
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <component>
- <component-type>org.richfaces.Message</component-type>
- <component-class>org.richfaces.component.html.HtmlMessage</component-class>
- <component-extension>
- <cdk:generate>true</cdk:generate>
- <cdk:base-class>javax.faces.component.UIMessage</cdk:base-class>
- <cdk:component-family>javax.faces.Message</cdk:component-family>
-
<cdk:renderer-type>org.richfaces.MessageRenderer</cdk:renderer-type>
- <cdk:tag>
- <cdk:tag-name>message</cdk:tag-name>
- <cdk:tag-type>Facelets</cdk:tag-type>
- </cdk:tag>
- </component-extension>
- </component>
- <component>
- <component-type>org.richfaces.Messages</component-type>
-
<component-class>org.richfaces.component.html.HtmlMessages</component-class>
- <component-extension>
- <cdk:generate>true</cdk:generate>
-
<cdk:base-class>javax.faces.component.UIMessages</cdk:base-class>
-
<cdk:component-family>javax.faces.Messages</cdk:component-family>
-
<cdk:renderer-type>org.richfaces.MessagesRenderer</cdk:renderer-type>
- <cdk:tag>
- <cdk:tag-name>messages</cdk:tag-name>
- <cdk:tag-type>Facelets</cdk:tag-type>
- </cdk:tag>
- </component-extension>
- </component>
-</faces-config>
Added: trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessage.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessage.java
(rev 0)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessage.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.component;
+
+import javax.faces.component.UIMessage;
+
+import org.ajax4jsf.component.AjaxOutput;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.RendererSpecificComponent;
+import org.richfaces.cdk.annotations.Tag;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@JsfComponent(
+ generate="org.richfaces.component.UIRichMessage",
+ type="org.richfaces.Message",
+ components=@RendererSpecificComponent(
+ tag=@Tag(name="message"),
+ generate="org.richfaces.component.html.HtmlMessage",
+
attributes={"core-props.xml","events-props.xml","i18n-props.xml"},
+ renderer=(a)JsfRenderer(template="/message.template.xml")
+ )
+ )
+public abstract class AbstractMessage extends UIMessage implements AjaxOutput {
+
+ @Attribute
+ public abstract boolean isAjaxRendered();
+
+ @Attribute
+ public abstract boolean isKeepTransient();
+
+
+
+}
Property changes on:
trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessages.java
(from rev 21459,
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java)
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessages.java
(rev 0)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/AbstractMessages.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.component;
+
+import javax.faces.component.UIMessages;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.AjaxOutput;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.RendererSpecificComponent;
+import org.richfaces.cdk.annotations.Tag;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@JsfComponent(
+ generate="org.richfaces.component.UIRichMessages",
+ type="org.richfaces.Messages",
+ components=@RendererSpecificComponent(
+ tag=@Tag(name="messages"),
+ generate="org.richfaces.component.html.HtmlMessages",
+
attributes={"core-props.xml","events-props.xml","i18n-props.xml"},
+ renderer=(a)JsfRenderer(template="/messages.template.xml")
+ )
+ )
+public abstract class AbstractMessages extends UIMessages implements AjaxOutput,
ClientSideMessage {
+
+ @Attribute
+ public abstract boolean isAjaxRendered();
+
+ @Attribute
+ public abstract boolean isKeepTransient();
+
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.component.ClientSideMessage#updateMessages(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public void updateMessages(FacesContext context, String clientId) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/ui/validator/ui/src/main/java/org/richfaces/component/ClientSideMessage.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/component/ClientSideMessage.java
(rev 0)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/ClientSideMessage.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -0,0 +1,11 @@
+package org.richfaces.component;
+
+import javax.faces.context.FacesContext;
+
+public interface ClientSideMessage {
+
+ void updateMessages(FacesContext context, String clientId);
+
+ String getFor();
+
+}
\ No newline at end of file
Property changes on:
trunk/ui/validator/ui/src/main/java/org/richfaces/component/ClientSideMessage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
===================================================================
---
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2011-02-04
23:03:36 UTC (rev 21475)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -1,204 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-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;
-import javax.faces.event.PhaseId;
-
-import org.richfaces.event.ValidatorEvent;
-
-/**
- * JSF component class
- *
- */
-public abstract class UIAjaxValidator extends UIComponentBase implements AjaxContainer {
-
- public static final String COMPONENT_TYPE = "org.richfaces.AjaxValidator";
-
- public static final String COMPONENT_FAMILY =
"org.richfaces.AjaxValidator";
-
- public static final String BEAN_VALIDATOR_FACET =
"org.richfaces.validator.";
-
- @Override
- public void setParent(UIComponent parent) {
- super.setParent(parent);
-
- if (null != parent && parent instanceof EditableValueHolder) {
- setParentProperties(parent);
- }
- }
-
- public abstract String getOnsubmit();
-
- /**
- * @param parent
- * @throws FacesException
- */
- public void setParentProperties(UIComponent parent) throws FacesException {
- if (!(parent instanceof EditableValueHolder)) {
- throw new FacesException("Parent component must be an
EditableValueHolder");
- }
-
- // if (null != getEvent()) {
- // ValueExpression binding = new EventValueExpression(this);
- // parent.setValueExpression(getEvent(), binding);
- // }
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
- if (event.getComponent() == this) {
- FacesContext context = getFacesContext();
- if (event instanceof ValidatorEvent) {
- // ByPass UpdateModelValue
- context.renderResponse();
- }
- }
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- if (event instanceof ValidatorEvent && event.getComponent() == this) {
- UIComponent parent = getParent();
- if (parent instanceof UIInput) {
- UIInput input = (UIInput) parent;
- if (input.isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else {
- event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- }
- }
- }
- super.queueEvent(event);
- }
-
- public String getEventString() {
- StringBuffer buildOnEvent = new StringBuffer();
- String onsubmit = getOnsubmit();
- // Insert script to call before submit ajax request.
- if (null != onsubmit) {
- buildOnEvent.append(onsubmit).append(";");
- }
- // buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
- // getFacesContext(), getEvent(), true));
- String script = buildOnEvent.toString();
- return script;
- }
-
- public UIComponent getSingleComponent() {
- return getParent();
- }
-
- public void encodeAjax(FacesContext context) throws IOException {
-// AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
-// Set<String> renderedAreas = ajaxContext.getAjaxRenderedAreas();
-// for (UIComponent message : getMessages(context, this)) {
-// if (message.isRendered()) {
-// message.encodeAll(context);
-// renderedAreas.add(message.getClientId(context));
-// }
-// }
- // Write information about encoded areas after submission.
- // AjaxRendererUtils.encodeAreas(context, this);
- }
-
- public Set<UIComponent> getMessages(FacesContext context, UIComponent
component) {
- Set<UIComponent> messages = new HashSet<UIComponent>();
- findMessages(component.getParent(), component, messages, false);
- findRichMessages(context, context.getViewRoot(), messages);
- return messages;
- }
-
- /**
- * Find all instances of the {@link UIRichMessages} and update list of the rendered
messages.
- *
- * @param context
- * @param component
- * @param messages
- */
- protected void findRichMessages(FacesContext context, UIComponent component,
Set<UIComponent> messages) {
- Iterator<UIComponent> facetsAndChildren =
component.getFacetsAndChildren();
- while (facetsAndChildren.hasNext()) {
- UIComponent child = (UIComponent) facetsAndChildren.next();
- if (child instanceof UIRichMessages) {
- UIRichMessages richMessage = (UIRichMessages) child;
- if (null == richMessage.getFor()) {
- richMessage.updateMessages(context,
this.getParent().getClientId(context));
- messages.add(richMessage);
- }
- } else {
- findRichMessages(context, child, messages);
- }
- }
- }
-
- /**
- * Recursive search messages for the parent component.
- *
- * @param parent
- * @param component
- * @param messages
- * @return
- */
- protected boolean findMessages(UIComponent parent, UIComponent component,
Set<UIComponent> messages, boolean found) {
- Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren();
- while (facetsAndChildren.hasNext()) {
- UIComponent child = (UIComponent) facetsAndChildren.next();
- if (child != component) {
- if (child instanceof UIMessage || child instanceof UIMessages) {
- UIComponent message = (UIComponent) child;
- Object targetId = message.getAttributes().get("for");
- if (null != targetId && targetId.equals(getParent().getId()))
{
- messages.add(message);
- found = true;
- }
- } else {
- found |= findMessages(child, null, messages, found);
- }
- }
- }
- if (!(found && parent instanceof NamingContainer) && component !=
null) {
- UIComponent newParent = parent.getParent();
- if (null != newParent) {
- found = findMessages(newParent, parent, messages, found);
- }
- }
- return found;
- }
-
-}
Deleted: trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
---
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java 2011-02-04
23:03:36 UTC (rev 21475)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -1,43 +0,0 @@
-/*
- * $Id$
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.component;
-
-import javax.faces.component.UIMessages;
-import javax.faces.context.FacesContext;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class UIRichMessages extends UIMessages {
-
- public void updateMessages(FacesContext context, String clientId) {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified:
trunk/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
---
trunk/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2011-02-04
23:03:36 UTC (rev 21475)
+++
trunk/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2011-02-04
23:59:32 UTC (rev 21476)
@@ -23,6 +23,7 @@
package org.richfaces.component.behavior;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -52,7 +53,7 @@
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
-import org.richfaces.component.UIRichMessages;
+import org.richfaces.component.ClientSideMessage;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.renderkit.html.ClientValidatorRenderer;
@@ -77,6 +78,10 @@
public class ClientValidatorImpl extends AjaxBehavior implements ClientValidatorBehavior
{
+ private static final Set<String> NONE =
Collections.singleton("@none");
+
+ private static final Set<String> THIS =
Collections.singleton("@this");
+
private static final Class<?>[] EMPTY_GROUPS = new Class<?>[0];
private static final String VALUE = "value";
@@ -141,11 +146,11 @@
Iterator<UIComponent> facetsAndChildren =
component.getFacetsAndChildren();
while (facetsAndChildren.hasNext()) {
UIComponent child = (UIComponent) facetsAndChildren.next();
- if (child instanceof UIRichMessages) {
- UIRichMessages richMessage = (UIRichMessages) child;
+ if (child instanceof ClientSideMessage) {
+ ClientSideMessage richMessage = (ClientSideMessage) child;
if (null == richMessage.getFor()) {
richMessage.updateMessages(context, id);
- messages.add(richMessage);
+ messages.add(child);
}
} else {
findRichMessages(context, child, id, messages);
@@ -374,4 +379,24 @@
return false;
}
+ // Disable processing for any component except validated input.
+ @Override
+ public boolean isLimitRender() {
+ return true;
+ }
+
+ @Override
+ public boolean isBypassUpdates() {
+ return true;
+ }
+
+ @Override
+ public Collection<String> getExecute() {
+ return THIS;
+ }
+
+ @Override
+ public Collection<String> getRender() {
+ return NONE;
+ }
}