Author: alexsmirnov
Date: 2009-03-09 19:19:03 -0400 (Mon, 09 Mar 2009)
New Revision: 12899
Added:
trunk/sandbox/samples/layout-sample/src/main/webapp/pages/layout.xhtml
trunk/sandbox/ui/layout/src/main/config/component/layout.xml
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/LayoutPosition.java
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayout.java
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
Modified:
trunk/sandbox/ui/layout/src/main/config/component/layoutPanel.xml
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java
trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx
Log:
layout component created.
Added: trunk/sandbox/samples/layout-sample/src/main/webapp/pages/layout.xhtml
===================================================================
--- trunk/sandbox/samples/layout-sample/src/main/webapp/pages/layout.xhtml
(rev 0)
+++ trunk/sandbox/samples/layout-sample/src/main/webapp/pages/layout.xhtml 2009-03-09
23:19:03 UTC (rev 12899)
@@ -0,0 +1,65 @@
+<layout:page
xmlns="http://www.w3.org/1999/xhtml"
+
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:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:layout="http://richfaces.org/layout"
+
xmlns:c="http://java.sun.com/jsp/jstl/core"
+ markupposition="xhtml"
+ contentposition="text/html"
+ theme="#{bean.theme}"
+ width="#{bean.width}"
+ sidebarWidth="#{bean.sidebarWidth}"
+ sidebarPosition="#{bean.position}"
+ headerClass="p_header"
+ footerClass="p_footer"
+ bodyClass="p_body"
+ sidebarClass="p_sidebar"
+ pageTitle="Simple Page Layout"
+ >
+ <f:facet name="pageHeader">
+ <style>
+ .yui-u {text-align: center;}
+ </style>
+ </f:facet>
+ <f:facet name="header">
+ <h:outputText value="Header"/>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="Copyright (c) 2009 RichFaces. All rights
reserved."/>
+ </f:facet>
+ <f:facet name="sidebar">
+ <h:form>
+ <h2>Page Attributes</h2>
+ <h:panelGrid columns="2">
+ <h:outputLabel for="theme" value="Page Theme"/>
+ <h:inputText id="theme" value="#{bean.theme}"/>
+ <h:outputLabel for="width" value="Page Width"/>
+ <h:inputText id="width" value="#{bean.width}"/>
+ <h:outputLabel for="sidebarwidth" value="Sidebar
Width"/>
+ <h:inputText id="sidebarwidth"
value="#{bean.sidebarWidth}"/>
+ <h:outputLabel for="position" value="Side bar
position"/>
+ <h:selectOneMenu value="#{bean.position}">
+ <f:selectItem itemValue="left"/>
+ <f:selectItem itemValue="right"/>
+ </h:selectOneMenu>
+ <h:outputLabel for="skin" value="Current skin"/>
+ <h:selectOneMenu binding="#{skinBean.component}">
+ </h:selectOneMenu>
+ <h:commandButton value="Change"
action="#{skinBean.change}"></h:commandButton>
+ </h:panelGrid>
+ </h:form>
+ </f:facet>
+
+ <!-- body of the page -->
+
+ <layout:layout>
+ <layout:layoutPanel position="center">Center
panel</layout:layoutPanel>
+ <layout:layoutPanel position="left">Left</layout:layoutPanel>
+ <layout:layoutPanel
position="right">Right</layout:layoutPanel>
+ <layout:layoutPanel position="top">Top</layout:layoutPanel>
+ <layout:layoutPanel
position="bottom">Bottom</layout:layoutPanel>
+
+ </layout:layout>
+
+</layout:page>
\ No newline at end of file
Property changes on:
trunk/sandbox/samples/layout-sample/src/main/webapp/pages/layout.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/ui/layout/src/main/config/component/layout.xml
===================================================================
--- trunk/sandbox/ui/layout/src/main/config/component/layout.xml
(rev 0)
+++ trunk/sandbox/ui/layout/src/main/config/component/layout.xml 2009-03-09 23:19:03 UTC
(rev 12899)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd">
+
+<components>
+ <component>
+ <name>org.richfaces.Layout</name>
+ <family>org.richfaces.Layout</family>
+ <classname>org.richfaces.component.html.HtmlLayout</classname>
+ <superclass>org.richfaces.component.UILayout</superclass>
+ <description>
+ <![CDATA[
+ ]]>
+ </description>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.LayoutRenderer</name>
+ <template>org/richfaces/htmlLayout.jspx</template>
+ </renderer>
+ <tag>
+ <name>layout</name>
+ <classname>org.richfaces.taglib.LayoutTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
+ <!--
+ <taghandler>
+ <classname>org.ajax4jsf.tag.TestHandler</classname>
+ </taghandler>
+ -->
+ &ui_component_attributes;
+ <!--
+ <property>
+ <name>param</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ <defaultvalue>"default"</defaultvalue>
+ </property>
+ -->
+ </component>
+</components>
Property changes on: trunk/sandbox/ui/layout/src/main/config/component/layout.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sandbox/ui/layout/src/main/config/component/layoutPanel.xml
===================================================================
--- trunk/sandbox/ui/layout/src/main/config/component/layoutPanel.xml 2009-03-09 19:03:51
UTC (rev 12898)
+++ trunk/sandbox/ui/layout/src/main/config/component/layoutPanel.xml 2009-03-09 23:19:03
UTC (rev 12899)
@@ -29,12 +29,11 @@
-->
&ui_component_attributes;
- <property>
- <name>type</name>
- <classname>java.lang.String</classname>
+ <property required="true">
+ <name>position</name>
+ <classname>org.richfaces.component.LayoutPosition</classname>
<description>
</description>
- <defaultvalue>""</defaultvalue>
</property>
</component>
Added: trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/LayoutPosition.java
===================================================================
--- trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/LayoutPosition.java
(rev 0)
+++
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/LayoutPosition.java 2009-03-09
23:19:03 UTC (rev 12899)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+/**
+ * @author asmirnov
+ *
+ */
+public enum LayoutPosition {
+ center,
+ left,
+ right,
+ top,
+ bottom;
+}
Property changes on:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/LayoutPosition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayout.java
===================================================================
--- trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayout.java
(rev 0)
+++ trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayout.java 2009-03-09
23:19:03 UTC (rev 12899)
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIPanel;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UILayout extends UIPanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Layout";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Layout";
+
+}
Property changes on:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayout.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java
===================================================================
---
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java 2009-03-09
19:03:51 UTC (rev 12898)
+++
trunk/sandbox/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java 2009-03-09
23:19:03 UTC (rev 12899)
@@ -16,4 +16,17 @@
public static final String COMPONENT_FAMILY = "org.richfaces.LayoutPanel";
+ /**
+ * Get placement position type name
+ * @return
+ */
+ public abstract LayoutPosition getPosition();
+
+ /**
+ * Set placement position type name
+ * @param newvalue
+ */
+ public abstract void setPosition(LayoutPosition newvalue);
+
+
}
Added:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
===================================================================
---
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
(rev 0)
+++
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java 2009-03-09
23:19:03 UTC (rev 12899)
@@ -0,0 +1,114 @@
+/**
+ *
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.LayoutPosition;
+import org.richfaces.component.UILayout;
+import org.richfaces.component.UILayoutPanel;
+
+/**
+ * @author asmirnov
+ *
+ */
+public abstract class AbstractLayoutRenderer extends
+ HeaderResourcesRendererBase {
+
+ public void renderLayout(FacesContext context, UILayout layout) throws IOException {
+ // Detect layout content;
+ UILayoutPanel top = null;
+ UILayoutPanel bottom = null;
+ UILayoutPanel left = null;
+ UILayoutPanel right = null;
+ UILayoutPanel center = null;
+ int columns = 0;
+ for (UIComponent child : layout.getChildren()) {
+ if (child instanceof UILayoutPanel) {
+ UILayoutPanel layoutPanel = (UILayoutPanel) child;
+ LayoutPosition position = layoutPanel.getPosition();
+ if( LayoutPosition.top.equals(position)){
+ if(null != top){
+ throw new FacesException("Duplicate layoutPanel's with same
position"+position);
+ }
+ top = layoutPanel;
+ } else if( LayoutPosition.bottom.equals(position)){
+ if(null != bottom){
+ throw new FacesException("Duplicate layoutPanel's with same
position"+position);
+ }
+ bottom = layoutPanel;
+ } else if( LayoutPosition.left.equals(position)){
+ if(null != left){
+ throw new FacesException("Duplicate layoutPanel's with same
position"+position);
+ }
+ left = layoutPanel;
+ columns++;
+ } else if( LayoutPosition.right.equals(position)){
+ if(null != right){
+ throw new FacesException("Duplicate layoutPanel's with same
position"+position);
+ }
+ right = layoutPanel;
+ columns++;
+ } else if( null == position || LayoutPosition.center.equals(position)){
+ if(null != center){
+ throw new FacesException("Duplicate layoutPanel's with same
position"+position);
+ }
+ center = layoutPanel;
+ columns++;
+ } else {
+
+ }
+ }
+ }
+ if(columns>0 && null == center){
+ throw new FacesException("Center layout panel for multi-column layout is not
defined");
+ }
+ ResponseWriter writer = context.getResponseWriter();
+ if(null != top){
+ renderChild(context, top);
+ }
+ if(columns>1){
+ // Render Y! CSS Grid
+ writer.startElement(HTML.DIV_ELEM, layout);
+ // calculate class.
+ String yahooClass = "yui-g";
+ if(columns >2){
+ yahooClass = "yui-gb";
+ } else {
+ Object width = center.getAttributes().get("width");
+ if("75%".equals(width)){
+ yahooClass = "yui-gc";
+ } else if("66%".equals(width)){
+ yahooClass = "yui-gd";
+ }
+ }
+ writer.writeAttribute(HTML.class_ATTRIBUTE, yahooClass, null);
+ if(null != left){
+ left.getAttributes().put("first", "first");
+ center.getAttributes().remove("first");
+ renderChild(context, left);
+ } else {
+ center.getAttributes().put("first", "first");
+ }
+ renderChild(context, center);
+ if(null != right){
+ right.getAttributes().remove("first");
+ renderChild(context, right);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+ } else if (columns == 1) {
+ renderChild(context, center);
+ }
+ if(null != bottom){
+ renderChild(context, bottom);
+ }
+ }
+}
Property changes on:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
===================================================================
--- trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
(rev 0)
+++ trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx 2009-03-09
23:19:03 UTC (rev 12899)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:root
+
xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:c="
http://java.sun.com/jsf/core"
+ xmlns:ui="
http://ajax4jsf.org/cdk/ui"
+ xmlns:u="
http://ajax4jsf.org/cdk/u"
+ xmlns:x="
http://ajax4jsf.org/cdk/x"
+
xmlns:h="http://jsf.exadel.com/header"
+
xmlns:vcp="http://ajax4jsf.org/cdk/vcp"
+ class="org.richfaces.renderkit.html.LayoutRenderer"
+ baseclass="org.richfaces.renderkit.AbstractLayoutRenderer"
+ component="org.richfaces.component.UILayout"
+ >
+ <h:styles>css/grids.css</h:styles>
+ <f:clientid var="clientId"/>
+ <div id="#{clientId}"
+ x:passThruWithExclusions="value,name,type,id"
+ >
+ <vcp:body>
+ <f:call name="renderLayout" />
+ </vcp:body>
+
+ </div>
+</f:root>
\ No newline at end of file
Property changes on:
trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx
===================================================================
---
trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2009-03-09
19:03:51 UTC (rev 12898)
+++
trunk/sandbox/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2009-03-09
23:19:03 UTC (rev 12899)
@@ -12,10 +12,8 @@
component="org.richfaces.component.UILayoutPanel"
<f:clientid var="clientId"/>
- <h:styles>css/grids.css</h:styles>
<c:set var="styleClass"
value="#{component.attributes['styleClass']}"/>
- <c:set var="yuiClass"
value="#{component.attributes['type']}"/>
- <div id="#{clientId}" class="#{styleClass} yui-#{yuiClass}"
+ <div id="#{clientId}" class="yui-u
#{component.attributes['first']} #{styleClass}"
x:passThruWithExclusions="type,id, styleClass"
<vcp:body>