Author: amarkhel
Date: 2008-08-11 11:16:59 -0400 (Mon, 11 Aug 2008)
New Revision: 10027
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/hibernateValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/templates/include/components-navigation.xhtml
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
trunk/ui/message/src/main/config/component/message.xml
trunk/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
trunk/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
Log:
Fix bugs RF-4111, RF-4122, Rf-4041, RF-4042, RF-3946
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/hibernateValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/hibernateValidation.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/hibernateValidation.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -5,12 +5,12 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form>
+ <h:form id="validationForm">
<rich:panel>
<f:facet name="header">
<h:outputText value="User Info:" />
</f:facet>
- <h:panelGrid columns="3">
+ <h:panelGrid columns="3">
<h:outputText value="Name:" />
<h:inputText value="#{validationBean.name}" id="name"
required="true">
<rich:ajaxValidator event="onblur" />
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -5,7 +5,7 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form>
+ <h:form id="validationForm">
<rich:panel>
<f:facet name="header">
<h:outputText value="User Info:" />
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -5,7 +5,7 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form>
+ <h:form id="validationForm">
<rich:panel>
<f:facet name="header">
<h:outputText value="#{validationBean.progressString}"
id="progress"/>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -14,7 +14,7 @@
color: green;
}
</style>
- <h:form>
+ <h:form id="validationForm">
<a4j:region renderRegionOnly="true">
<rich:graphValidator value="#{dayStatistics}">
<table>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -5,7 +5,7 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form>
+ <h:form id="validationForm">
<a4j:region renderRegionOnly="true">
<rich:panel id="panel">
<f:facet name="header">
Modified:
trunk/samples/richfaces-demo/src/main/webapp/templates/include/components-navigation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/templates/include/components-navigation.xhtml 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/samples/richfaces-demo/src/main/webapp/templates/include/components-navigation.xhtml 2008-08-11
15:16:59 UTC (rev 10027)
@@ -7,7 +7,7 @@
<ui:composition>
<rich:panel styleClass="panel_menu"
bodyClass="rich-laguna-panel-no-header">
-<rich:panelBar style="width: auto;"
selectedPanel="#{componentNavigator.currentComponent.group}"
height="605px" contentStyle="background:none;">
+<rich:panelBar style="width: auto;"
selectedPanel="#{componentNavigator.currentComponent.group}"
height="625px" contentStyle="background:none;">
<rich:panelBarItem id="ajaxSupport" label="Ajax Support">
<ui:include src="/templates/include/components-group.xhtml" >
<ui:param name="components"
value="#{componentNavigator.ajaxSupport}" />
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java 2008-08-11
15:16:59 UTC (rev 10027)
@@ -63,8 +63,22 @@
* @param newvalue
*/
public abstract void setValue(Object newvalue);
+
+ /**
+ * Get object for validation
+ *
+ * @return
+ */
+ public abstract String getSummary();
/**
+ * Set object for validation
+ *
+ * @param newvalue
+ */
+ public abstract void setSummary(String newvalue);
+
+ /**
* Get set of profiles for validation
*
* @return
@@ -91,7 +105,7 @@
for (String msg : messages) {
// TODO - create Summary message ?
context.addMessage(null, new FacesMessage(
- FacesMessage.SEVERITY_ERROR, msg, msg));
+ FacesMessage.SEVERITY_ERROR, getSummary() + msg, msg));
}
}
@@ -101,7 +115,8 @@
@Override
public void encodeBegin(FacesContext context) throws IOException {
super.encodeBegin(context);
- Validator validator =
context.getApplication().createValidator(FacesBeanValidator.BEAN_VALIDATOR_TYPE);
+ FacesBeanValidator validator =
(FacesBeanValidator)context.getApplication().createValidator(FacesBeanValidator.BEAN_VALIDATOR_TYPE);
+ validator.setSummary(getSummary());
setupValidators(this,validator);
}
Modified:
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
===================================================================
---
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-08-11
15:16:59 UTC (rev 10027)
@@ -113,15 +113,26 @@
private void ensureParentPresent(UIComponent component) {
UIComponent parent = component.getParent();
+ UIContextMenu menu = (UIContextMenu) component;
+ String attachTo = menu.getAttachTo();
+ boolean isAttached = false;
+ if(null != attachTo && !attachTo.equals("")){
+ isAttached = true;
+ }
+
if (parent != null) {
if (HtmlUtil.shouldWriteId(parent)) {
return;
- } else {
+ } else
+ {
+ if(!isAttached){
+
throw new FacesException(
"Context menu cannot be attached to the component with id = "
+ parent.getId()
+ ", because a client identifier of the component won't be rendered onto
the page. Please, set the identifier.");
}
+ }
} else {
throw new FacesException(
"Parent component is null for ContextMenu "
Modified: trunk/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/ui/message/src/main/config/component/message.xml 2008-08-11 15:06:04 UTC (rev
10026)
+++ trunk/ui/message/src/main/config/component/message.xml 2008-08-11 15:16:59 UTC (rev
10027)
@@ -312,8 +312,15 @@
<defaultvalue>"ALL"</defaultvalue>
</property>
-
<property>
+ <name>for</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Client identifier of the component for which to display messages
+ </description>
+
+ </property>
+ <property>
<name>layout</name>
<classname>java.lang.String</classname>
<defaultvalue>"list"</defaultvalue>
@@ -344,11 +351,9 @@
<name>showSummary</name>
<classname>boolean</classname>
<defaultvalue>false</defaultvalue>
- <description>
- Flag indicating whether the summary portion of displayed messages should be included.
Default value is "false"
- </description>
- </property>
-
+ <description> Flag indicating whether the summary portion of displayed
+ messages should be included. Default value is "false" </description>
+ </property>
<property>
<name>title</name>
<classname>java.lang.String</classname>
Modified: trunk/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
--- trunk/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2008-08-11
15:06:04 UTC (rev 10026)
+++ trunk/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2008-08-11
15:16:59 UTC (rev 10027)
@@ -3,6 +3,9 @@
*/
package org.richfaces.component;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
import javax.faces.component.UIMessages;
import javax.faces.context.FacesContext;
@@ -14,9 +17,46 @@
*/
public abstract class UIRichMessages extends UIMessages implements AjaxOutput{
-
+ private String forVal = null;
private boolean isPassed = true;
+ /**
+ * <p>Return the client identifier of the component for which
+ * this component represents associated message(s) (if any).</p>
+ */
+ public String getFor() {
+
+ if (this.forVal != null) {
+ return (this.forVal);
+ }
+ ValueExpression ve = getValueExpression("for");
+ if (ve != null) {
+ try {
+ return ((String) ve.getValue(getFacesContext().getELContext()));
+ }
+ catch (ELException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the client identifier of the component for which this
+ * component represents associated message(s) (if any). This
+ * property must be set before the message is displayed.</p>
+ *
+ * @param newFor The new client id
+ */
+ public void setFor(String newFor) {
+
+ forVal = newFor;
+
+ }
+
public boolean isPassed(){
return isPassed;
}
@@ -40,4 +80,25 @@
public abstract void setLevel(String level);
+ private Object[] values;
+
+ public Object saveState(FacesContext context) {
+
+ if (values == null) {
+ values = new Object[2];
+ }
+
+ values[0] = super.saveState(context);
+ values[1] = this.forVal;
+ return (values);
+
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+
+ values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ forVal = (String) values[1];
+ }
+
}
Modified:
trunk/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
===================================================================
---
trunk/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java 2008-08-11
15:06:04 UTC (rev 10026)
+++
trunk/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java 2008-08-11
15:16:59 UTC (rev 10027)
@@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.List;
+import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIMessages;
@@ -23,17 +24,22 @@
*/
public class HtmlRichMessagesRenderer extends RichMessageBaseRenderer {
-
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
UIRichMessages uiMessages = (UIRichMessages)component;
String layout = null;
String forIds = null;
-
+ String forClientId = uiMessages.getFor();
+ if(null != forClientId){
+ forIds = forClientId;
+ }
if(uiMessages.isGlobalOnly()){
- forIds = "";
+ if(null == forClientId){
+ forIds = "";
+ }else{
+ throw new FacesException("The rich:messages component must specify only one of
'for' or 'globalOnly' atribbute");
+ }
}
-
Iterator<FacesMessage> messagesIter = getMessageIterator(context, forIds,
component);
boolean isDisplayNone = !messagesIter.hasNext();
String [] levels = uiMessages.getLevel().split(",");