Author: abelevich
Date: 2007-07-18 11:39:20 -0400 (Wed, 18 Jul 2007)
New Revision: 1679
Modified:
trunk/sandbox/samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/rich-message-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/rich-message-demo/src/main/webapp/pages/message-demo.xhtml
trunk/sandbox/ui/message/src/main/config/component/message.xml
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java
trunk/sandbox/ui/message/src/main/templates/org/richfaces/message.jspx
Log:
start implementing encodeEnd methods
Modified: trunk/sandbox/samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml 2007-07-18
15:35:33 UTC (rev 1678)
+++ trunk/sandbox/samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml 2007-07-18
15:39:20 UTC (rev 1679)
@@ -7,6 +7,10 @@
<param-value>#{skinBean.skin}</param-value>
</context-param>
<context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
Modified:
trunk/sandbox/samples/rich-message-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/sandbox/samples/rich-message-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-07-18
15:35:33 UTC (rev 1678)
+++
trunk/sandbox/samples/rich-message-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-07-18
15:39:20 UTC (rev 1679)
@@ -2,5 +2,14 @@
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
+ <managed-bean>
+ <managed-bean-name>jiraUserConverter</managed-bean-name>
+
<managed-bean-class>org.richfaces.demo.converters.JiraUserConverter</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>channel</property-name>
+ <value>#{jiraService.channel}</value>
+ </managed-property>
+ </managed-bean>
</faces-config>
Modified:
trunk/sandbox/samples/rich-message-demo/src/main/webapp/pages/message-demo.xhtml
===================================================================
---
trunk/sandbox/samples/rich-message-demo/src/main/webapp/pages/message-demo.xhtml 2007-07-18
15:35:33 UTC (rev 1678)
+++
trunk/sandbox/samples/rich-message-demo/src/main/webapp/pages/message-demo.xhtml 2007-07-18
15:39:20 UTC (rev 1679)
@@ -3,8 +3,16 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:msg="http://labs.jboss.com/jbossrichfaces/ui/ui/message"
+
xmlns:r="http://labs.jboss.com/jbossrichfaces/ui/ui/message"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
+
+ <h:form>
+ <h:inputText id="input" value="hello!!">
+ <f:validateLongRange minimum="1" maximum="500"/>
+ </h:inputText>
+ <h:commandButton value="submit"></h:commandButton>
+
+ <r:message for="input"></r:message>
+ </h:form>
- <h:outputText value="hello!!"></h:outputText>
</html>
\ No newline at end of file
Modified: trunk/sandbox/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-18 15:35:33 UTC
(rev 1678)
+++ trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-18 15:39:20 UTC
(rev 1679)
@@ -36,7 +36,7 @@
</tag>
- <property>
+ <property attachedstate="true">
<name>passedLabel</name>
<classname>java.lang.String</classname>
<description>
@@ -44,7 +44,7 @@
</description>
</property>
- <property>
+ <property attachedstate="true">
<name>markerLocation</name>
<classname>java.lang.String</classname>
<description>
@@ -59,6 +59,7 @@
<description>
Client identifier of the component for which to display messages
</description>
+
</property>
<property>
@@ -167,6 +168,12 @@
<name>LabelClass</name>
<classname>java.lang.String</classname>
</property>
+
+ <property attachedstate="true" hidden="true">
+ <name>binding</name>
+ <classname>javax.faces.component.UIComponent</classname>
+ </property>
+
&ui_component_attributes;
</component>
Modified:
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java 2007-07-18
15:35:33 UTC (rev 1678)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java 2007-07-18
15:39:20 UTC (rev 1679)
@@ -2,10 +2,31 @@
import javax.faces.component.UIMessage;
+import org.ajax4jsf.component.AjaxOutput;
+
/**
* @author Anton Belevich
*
*/
-public abstract class UIRichMessage extends UIMessage{
+public abstract class UIRichMessage extends UIMessage implements AjaxOutput{
+
+ public final String MARKER_LOCATION_LEFT = "left";
+
+ public final String MARKER_LOCATION_RIGHT = "right";
+
+ private String passedLabel = null;
+
+ private String markerLocation = "left";
+
+
+
+ public abstract String getPassedLabel();
+
+ public abstract void setPassedLabel(String passedLabel);
+
+ public abstract String getMarkerLocation();
+
+ public abstract void setMarkerLocation(String markerLocation);
+
}
\ No newline at end of file
Modified:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-18
15:35:33 UTC (rev 1678)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-18
15:39:20 UTC (rev 1679)
@@ -1,12 +1,172 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.renderkit.RendererBase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.component.UIRichMessage;
/**
* @author Anton Belevich
*
*/
-public abstract class RichMessageBaseRenderer extends RendererBase{
+public class RichMessageBaseRenderer extends RendererBase{
+
+ private static final Log log = LogFactory.getLog(RichMessageBaseRenderer.class);
+
+ public static final String NULL_PARAMETER_ERROR_MESSAGE = "null parameter
ERROR";
+
+ public static final String COMPONENT_NOT_FOUND_IN_VIEW = "component not found in
view";
+
+
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+
+ Iterator msgIter = null;
+
+ if(component == null && context == null){
+ throw new NullPointerException(NULL_PARAMETER_ERROR_MESSAGE);
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("begin encoding component " + component.getId());
+ }
+
+ if (!component.isRendered()) {
+ if (log.isTraceEnabled()) {
+ log.trace("stop encoding component: "
+ + component.getId() + " rendered attribute is set to
false");
+ }
+ return;
+ }
+
+ UIRichMessage msgComponent = (UIRichMessage)component;
+ String clientId = msgComponent.getClientId(context);
+ String forClientId = msgComponent.getFor();
+
+ if(forClientId == null){
+ if(log.isInfoEnabled()){
+ log.info(NULL_PARAMETER_ERROR_MESSAGE);
+ }
+ }
+
+ msgIter = getMessageIterator(context, forClientId, msgComponent);
+
+ if(!msgIter.hasNext()){
+ return;
+ }
+
+ FacesMessage message = (FacesMessage)msgIter.next();
+
+ //TODO rendering here
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ Set ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
+
+ if(null != ajaxRenderedAreas) {
+ ajaxRenderedAreas.add(clientId);
+ }
+ }
+
+ protected Iterator getMessageIterator(FacesContext context, String forClientId,
UIComponent component){
+
+ Iterator msgIter = null;
+
+ if(forClientId != null){
+
+ if(forClientId.length() == 0){
+ msgIter = context.getMessages(null);
+ }else{
+ UIComponent result = findForComponent(context, forClientId,component);
+
+ if (result == null) {
+ msgIter = Collections.EMPTY_LIST.iterator();
+ } else {
+ msgIter = context.getMessages(result.getClientId(context));
+ }
+ }
+ }else{
+ msgIter = context.getMessages();
+ }
+
+ return msgIter;
+ }
+
+ protected UIComponent findForComponent(FacesContext context, String forClientId,
UIComponent component) {
+
+ if(null == forClientId || forClientId.length() == 0) {
+ return null;
+ }
+
+ UIComponent result = null;
+ UIComponent parent = component;
+
+ try {
+ while(parent != null) {
+ result = parent.findComponent(forClientId);
+
+ if(result != null){
+ break;
+ }
+ parent = parent.getParent();
+ }
+
+ if(result == null) {
+ result = findComponentBelow(context.getViewRoot(), forClientId);
+ }
+
+ } catch(Throwable t) {
+ throw new RuntimeException(COMPONENT_NOT_FOUND_IN_VIEW + ":"+
forClientId);
+ }
+
+ if(result == null) {
+ if(log.isWarnEnabled()) {
+ log.warn(COMPONENT_NOT_FOUND_IN_VIEW + ":"+ forClientId);
+ }
+ }
+
+ return result;
+ }
+
+ protected UIComponent findComponentBelow(UIComponent startComponent, String
forClientId){
+
+ UIComponent retComp = null;
+ List children = startComponent.getChildren();
+
+ for(int i = 0, size = children.size(); i < size; i++){
+ UIComponent comp = (UIComponent) children.get(i);
+
+ if(comp instanceof NamingContainer){
+ retComp = comp.findComponent(forClientId);
+ }
+
+ if(retComp == null){
+ if(comp.getChildCount() > 0){
+ retComp = findComponentBelow(comp, forClientId);
+ }
+ }
+
+ if(retComp != null)
+ break;
+ }
+
+ return retComp;
+ };
+
+ protected Class getComponentClass() {
+ return getClass();
+ }
}
\ No newline at end of file
Modified: trunk/sandbox/ui/message/src/main/templates/org/richfaces/message.jspx
===================================================================
--- trunk/sandbox/ui/message/src/main/templates/org/richfaces/message.jspx 2007-07-18
15:35:33 UTC (rev 1678)
+++ trunk/sandbox/ui/message/src/main/templates/org/richfaces/message.jspx 2007-07-18
15:39:20 UTC (rev 1679)
@@ -11,5 +11,12 @@
baseclass="org.richfaces.renderkit.html.RichMessageBaseRenderer"
component="org.richfaces.component.UIRichMessage"
+ <f:clientId var="clientId" />
+
+ <div id="#{clientId}:m">
+ <span>
+ <vcp:body/>
+ </span>
+ </div>
</f:root>
\ No newline at end of file