You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/04/24 08:54:09 UTC
svn commit: r531791 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/
...
Author: bommel
Date: Mon Apr 23 23:54:07 2007
New Revision: 531791
URL: http://svn.apache.org/viewvc?view=rev&rev=531791
Log:
(TOBAGO-362) Allow display of the detail message in tc:messages and tc:message
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTag.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTagDeclaration.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTag.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/MessageRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Mon Apr 23 23:54:07 2007
@@ -135,6 +135,8 @@
public static final String ATTR_SHOW_ROOT = "showRoot";
public static final String ATTR_SHOW_ROOT_JUNCTION = "showRootJunction";
public static final String ATTR_SHOW_ROW_RANGE = "showRowRange";
+ public static final String ATTR_SHOW_SUMMARY = "showSummary";
+ public static final String ATTR_SHOW_DETAIL = "showDetail";
public static final String ATTR_SPAN_X = "spanX";
public static final String ATTR_SPAN_Y = "spanY";
public static final String ATTR_SRC = "src";
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTag.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTag.java Mon Apr 23 23:54:07 2007
@@ -18,6 +18,8 @@
*/
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOR;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
import org.apache.myfaces.tobago.component.ComponentUtil;
import javax.faces.component.UIComponent;
@@ -28,6 +30,8 @@
implements MessageTagDeclaration {
private String forComponent;
+ private String showSummary;
+ private String showDetail;
public String getComponentType() {
return UIMessage.COMPONENT_TYPE;
@@ -36,11 +40,15 @@
protected void setProperties(UIComponent component) {
super.setProperties(component);
ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent);
+ ComponentUtil.setBooleanProperty(component, ATTR_SHOW_SUMMARY, showSummary);
+ ComponentUtil.setBooleanProperty(component, ATTR_SHOW_DETAIL, showDetail);
}
public void release() {
super.release();
forComponent = null;
+ showSummary = null;
+ showDetail = null;
}
public String getFor() {
@@ -49,5 +57,13 @@
public void setFor(String forComponent) {
this.forComponent = forComponent;
+ }
+
+ public void setShowSummary(String showSummary) {
+ this.showSummary = showSummary;
+ }
+
+ public void setShowDetail(String showDetail) {
+ this.showDetail = showDetail;
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTagDeclaration.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessageTagDeclaration.java Mon Apr 23 23:54:07 2007
@@ -20,12 +20,12 @@
import org.apache.myfaces.tobago.apt.annotation.BodyContent;
import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.taglib.decl.HasFor;
import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
/*
- * Created by IntelliJ IDEA.
- * User: bommel
* Date: 02.04.2006
* Time: 15:55:21
*/
@@ -38,4 +38,20 @@
uiComponent = "javax.faces.component.UIMessage",
rendererType = "Message", isComponentAlreadyDefined = true)
public interface MessageTagDeclaration extends TobagoTagDeclaration, HasIdBindingAndRendered, HasFor {
+
+ /**
+ * Flag indicating whether the detail should be included
+ * The default is "false".
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "false")
+ void setShowDetail(String showDetail);
+
+ /**
+ * Flag indicating whether the summary should be included
+ * The default is "true".
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "true")
+ void setShowSummary(String showSummary);
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTag.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTag.java Mon Apr 23 23:54:07 2007
@@ -19,6 +19,8 @@
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOR;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_GLOBAL_ONLY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
import org.apache.myfaces.tobago.component.ComponentUtil;
import javax.faces.component.UIComponent;
@@ -29,6 +31,8 @@
implements MessagesTagDeclaration {
private String forComponent;
+ private String showSummary;
+ private String showDetail;
private String globalOnly;
@@ -40,11 +44,15 @@
super.setProperties(component);
ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent);
ComponentUtil.setBooleanProperty(component, ATTR_GLOBAL_ONLY, globalOnly);
+ ComponentUtil.setBooleanProperty(component, ATTR_SHOW_SUMMARY, showSummary);
+ ComponentUtil.setBooleanProperty(component, ATTR_SHOW_DETAIL, showDetail);
}
public void release() {
super.release();
forComponent = null;
+ showSummary = null;
+ showDetail = null;
}
public String getFor() {
@@ -57,5 +65,13 @@
public void setGlobalOnly(String globalOnly) {
this.globalOnly = globalOnly;
+ }
+
+ public void setShowSummary(String showSummary) {
+ this.showSummary = showSummary;
+ }
+
+ public void setShowDetail(String showDetail) {
+ this.showDetail = showDetail;
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java Mon Apr 23 23:54:07 2007
@@ -26,8 +26,6 @@
import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
/*
- * Created by IntelliJ IDEA.
- * User: bommel
* Date: 02.04.2006
* Time: 15:53:45
*/
@@ -50,4 +48,20 @@
@TagAttribute
@UIComponentTagAttribute()
void setGlobalOnly(String globalOnly);
+
+ /**
+ * Flag indicating whether the detail should be included
+ * The default is "false".
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "false")
+ void setShowDetail(String showDetail);
+
+ /**
+ * Flag indicating whether the summary should be included
+ * The default is "true".
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "true")
+ void setShowSummary(String showSummary);
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/MessageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/MessageRenderer.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/MessageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/tag/MessageRenderer.java Mon Apr 23 23:54:07 2007
@@ -25,6 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.renderkit.MessageRendererBase;
@@ -69,7 +71,6 @@
public void encodeEnd(FacesContext facesContext,
UIComponent uiComponent) throws IOException {
-
UIMessage component = (UIMessage) uiComponent;
String clientId = ComponentUtil.findClientIdFor(component, facesContext);
@@ -78,6 +79,8 @@
TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
+ boolean showSummary = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_SUMMARY);
+ boolean showDetail = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_DETAIL);
if (iterator.hasNext()) {
@@ -88,9 +91,28 @@
while (iterator.hasNext()) {
FacesMessage message = (FacesMessage) iterator.next();
// MessageFormat detail = new MessageFormat(formatString, tobagoContext.getLocale());
+
+ String summary = message.getSummary();
+ String detail = message.getDetail();
+
writer.startElement(HtmlConstants.LABEL, null);
writer.writeAttribute(HtmlAttributes.FOR, clientId, null);
- writer.writeAttribute(HtmlAttributes.TITLE, message.getDetail(), null);
+ writer.writeAttribute(HtmlAttributes.TITLE, detail, null);
+ boolean writeEmptyText = true;
+ if (summary != null && showSummary) {
+ writer.writeText(summary, null);
+ writeEmptyText = false;
+ if (detail != null && showDetail) {
+ writer.writeText(" ", null);
+ }
+ }
+ if (detail != null && showDetail) {
+ writer.writeText(detail, null);
+ writeEmptyText = false;
+ }
+ if (writeEmptyText) {
+ writer.writeText("", null);
+ }
writer.writeText(message.getSummary(), null);
writer.endElement(HtmlConstants.LABEL);
@@ -101,8 +123,7 @@
} else {
writer.startElement(HtmlConstants.IMG, null);
- String image = ResourceManagerUtil.getImageWithPath(
- facesContext, "image/1x1.gif");
+ String image = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
writer.writeAttribute(HtmlAttributes.SRC, image, null);
writer.writeAttribute(HtmlAttributes.ALT, "", null);
writer.writeAttribute(HtmlAttributes.STYLE, "border: 0px; height: 1px; width: 1px;", null);
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java Mon Apr 23 23:54:07 2007
@@ -25,6 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.renderkit.MessageRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -74,6 +76,9 @@
TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
+ boolean showSummary = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_SUMMARY);
+ boolean showDetail = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_DETAIL);
+
writer.startElement(HtmlConstants.SPAN, component);
writer.writeClassAttribute("tobago-validation-message");
writer.writeAttribute(HtmlAttributes.STYLE, null, ATTR_STYLE);
@@ -81,13 +86,26 @@
while (iterator.hasNext()) {
FacesMessage message = (FacesMessage) iterator.next();
// MessageFormat detail = new MessageFormat(formatString, tobagoContext.getLocale());
+
+ String summary = message.getSummary();
+ String detail = message.getDetail();
+
writer.startElement(HtmlConstants.LABEL, null);
writer.writeAttribute(HtmlAttributes.FOR, clientId, null);
- writer.writeAttribute(HtmlAttributes.TITLE, message.getDetail(), null);
- String summary = message.getSummary();
- if (summary != null) {
+ writer.writeAttribute(HtmlAttributes.TITLE, detail, null);
+ boolean writeEmptyText = true;
+ if (summary != null && showSummary) {
writer.writeText(summary, null);
- } else {
+ writeEmptyText = false;
+ if (detail != null && showDetail) {
+ writer.writeText(" ", null);
+ }
+ }
+ if (detail != null && showDetail) {
+ writer.writeText(detail, null);
+ writeEmptyText = false;
+ }
+ if (writeEmptyText) {
writer.writeText("", null);
}
writer.endElement(HtmlConstants.LABEL);
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java?view=diff&rev=531791&r1=531790&r2=531791
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java Mon Apr 23 23:54:07 2007
@@ -23,6 +23,8 @@
*/
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_GLOBAL_ONLY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.renderkit.MessageRendererBase;
@@ -82,12 +84,14 @@
} else {
clientIds = facesContext.getClientIdsWithMessages();
}
+ boolean showSummary = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_SUMMARY);
+ boolean showDetail = ComponentUtil.getBooleanAttribute(component, ATTR_SHOW_DETAIL);
while(clientIds.hasNext()) {
String clientId = (String) clientIds.next();
- encodeMessagesForId(facesContext, writer, clientId);
+ encodeMessagesForId(facesContext, writer, clientId, showSummary, showDetail);
if (focusId == null) {
focusId = clientId;
- }
+ }
}
if (focusId != null) {
ComponentUtil.findPage(component).setFocusId(focusId);
@@ -98,29 +102,41 @@
}
private void encodeMessagesForId(FacesContext facesContext,
- ResponseWriter writer, String clientId) throws IOException {
+ ResponseWriter writer, String clientId, boolean showSummary, boolean showDetail) throws IOException {
Iterator iterator = facesContext.getMessages(clientId);
while (iterator.hasNext()) {
FacesMessage message = (FacesMessage) iterator.next();
if (LOG.isDebugEnabled()) {
LOG.debug("message = " + message.getSummary());
}
- encodeMessage(writer, message, clientId);
+ encodeMessage(writer, message, clientId, showSummary, showDetail);
}
}
private void encodeMessage(ResponseWriter writer, FacesMessage message,
- String clientId)
+ String clientId, boolean showSummary, boolean showDetail)
throws IOException {
+
+ String summary = message.getSummary();
+ String detail = message.getDetail();
writer.startElement(HtmlConstants.LABEL, null);
if (clientId != null) {
writer.writeAttribute(HtmlAttributes.FOR, clientId, null);
}
- writer.writeAttribute(HtmlAttributes.TITLE, message.getDetail(), null);
- String summary = message.getSummary();
- if (summary != null) {
+ writer.writeAttribute(HtmlAttributes.TITLE, detail, null);
+ boolean writeEmptyText = true;
+ if (summary != null && showSummary) {
writer.writeText(summary, null);
- } else {
+ writeEmptyText = false;
+ if (detail != null && showDetail) {
+ writer.writeText(" ", null);
+ }
+ }
+ if (detail != null && showDetail) {
+ writeEmptyText = false;
+ writer.writeText(detail, null);
+ }
+ if (writeEmptyText) {
writer.writeText("", null);
}
writer.endElement(HtmlConstants.LABEL);