[richfaces-svn-commits] JBoss Rich Faces SVN: r13988 - in trunk: samples/layout-sample/src/main/webapp/pages and 4 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri May 1 20:14:19 EDT 2009


Author: alexsmirnov
Date: 2009-05-01 20:14:19 -0400 (Fri, 01 May 2009)
New Revision: 13988

Added:
   trunk/ui/layout/src/main/java/org/richfaces/taglib/
   trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java
Modified:
   trunk/samples/layout-sample/src/main/java/org/richfaces/samples/Bean.java
   trunk/samples/layout-sample/src/main/webapp/pages/index.xhtml
   trunk/ui/layout/src/main/config/component/page.xml
   trunk/ui/layout/src/main/templates/org/richfaces/htmlPage.jspx
Log:
https://jira.jboss.org/jira/browse/RF-6629

Modified: trunk/samples/layout-sample/src/main/java/org/richfaces/samples/Bean.java
===================================================================
--- trunk/samples/layout-sample/src/main/java/org/richfaces/samples/Bean.java	2009-05-01 23:10:30 UTC (rev 13987)
+++ trunk/samples/layout-sample/src/main/java/org/richfaces/samples/Bean.java	2009-05-02 00:14:19 UTC (rev 13988)
@@ -22,6 +22,10 @@
 	
 	private String theme = "simple";
 	
+	private String contentType = "text/html";
+	
+	private String encoding = "UTF-8";
+	
 	private int width=960;
 	
 	private int sidebarWidth=260;
@@ -107,4 +111,32 @@
 	public List<LayoutBean> getLayoutValues(){
 		return layoutValues;
 	}
+
+	/**
+	 * @return the contentType
+	 */
+	public String getContentType() {
+		return contentType;
+	}
+
+	/**
+	 * @param contentType the contentType to set
+	 */
+	public void setContentType(String contentType) {
+		this.contentType = contentType;
+	}
+
+	/**
+	 * @return the encoding
+	 */
+	public String getEncoding() {
+		return encoding;
+	}
+
+	/**
+	 * @param encoding the encoding to set
+	 */
+	public void setEncoding(String encoding) {
+		this.encoding = encoding;
+	}
 }

Modified: trunk/samples/layout-sample/src/main/webapp/pages/index.xhtml
===================================================================
(Binary files differ)

Modified: trunk/ui/layout/src/main/config/component/page.xml
===================================================================
--- trunk/ui/layout/src/main/config/component/page.xml	2009-05-01 23:10:30 UTC (rev 13987)
+++ trunk/ui/layout/src/main/config/component/page.xml	2009-05-02 00:14:19 UTC (rev 13988)
@@ -38,11 +38,9 @@
 				org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
 			</superclass>
 		</tag>
-		<!--
 		<taghandler>
-			<classname>org.ajax4jsf.tag.TestHandler</classname>
+			<classname>org.richfaces.taglib.PageTagHandler</classname>
 		</taghandler>
-		-->
 		&ui_component_attributes;
 		&html_universal_attributes;
 		<property>

Added: trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java
===================================================================
--- trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java	                        (rev 0)
+++ trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java	2009-05-02 00:14:19 UTC (rev 13988)
@@ -0,0 +1,56 @@
+/**
+ * 
+ */
+package org.richfaces.taglib;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ComponentSupport;
+import com.sun.facelets.tag.jsf.core.ViewHandler;
+
+/**
+ * This handler does same work as Facelet's {@link ViewHandler} does to setup page encoding and content type.
+ * 
+ * @author asmirnov
+ *
+ */
+public class PageTagHandler extends ComponentHandler {
+
+	private TagAttribute locale;
+	private TagAttribute contentType;
+	private TagAttribute encoding;
+
+	public PageTagHandler(ComponentConfig config) {
+		super(config);
+        this.locale = this.getAttribute("locale");
+        this.contentType = this.getAttribute("contentType");
+        this.encoding = this.getAttribute("encoding");
+	}
+	
+	@Override
+	protected void onComponentPopulated(FaceletContext ctx, UIComponent c,
+			UIComponent parent) {
+		super.onComponentPopulated(ctx, c, parent);
+        UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
+        if (root != null) {
+            if (this.locale != null) {
+                root.setLocale(ComponentSupport.getLocale(ctx,
+                        this.locale));
+            }
+            if (this.contentType != null) {
+                String v = this.contentType.getValue(ctx);
+                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType", v);
+            }
+            if (this.encoding != null) {
+                String v = this.encoding.getValue(ctx);
+                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", v);
+            }
+        }
+	}
+
+}


Property changes on: trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/ui/layout/src/main/templates/org/richfaces/htmlPage.jspx
===================================================================
--- trunk/ui/layout/src/main/templates/org/richfaces/htmlPage.jspx	2009-05-01 23:10:30 UTC (rev 13987)
+++ trunk/ui/layout/src/main/templates/org/richfaces/htmlPage.jspx	2009-05-02 00:14:19 UTC (rev 13988)
@@ -40,7 +40,7 @@
 		   </c:if>
 		   	<div id="#{clientId}:cnt" class="rich-page-content #{component.attributes['contentClass']}">
 		       <c:if test="#{this:hasFacet(component,'sidebar')}">
-	              <div class="rich-page-sidebar #{component.attributes['styleClass']}">
+	              <div class="rich-page-sidebar #{component.attributes['sidebarClass']}">
 		            <u:insertFacet name="sidebar"/>
 	              </div>
 	           </c:if>




More information about the richfaces-svn-commits mailing list