[jboss-cvs] jboss-seam/src/ui/org/jboss/seam/ui ...
Gavin King
gavin.king at jboss.com
Sat Mar 17 13:32:34 EDT 2007
User: gavin
Date: 07/03/17 13:32:34
Modified: src/ui/org/jboss/seam/ui HtmlDiv.java
HtmlLayoutForm.java HtmlSpan.java
UIStyleDecoration.java
Log:
various improvements to s:layoutForm
Revision Changes Path
1.2 +12 -2 jboss-seam/src/ui/org/jboss/seam/ui/HtmlDiv.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HtmlDiv.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlDiv.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HtmlDiv.java 2 Oct 2006 18:20:36 -0000 1.1
+++ HtmlDiv.java 17 Mar 2007 17:32:34 -0000 1.2
@@ -1,14 +1,24 @@
package org.jboss.seam.ui;
+import java.io.IOException;
+
+import javax.faces.context.ResponseWriter;
+
public class HtmlDiv extends UIStyleDecoration
{
public static final String COMPONENT_TYPE = "org.jboss.seam.ui.HtmlDiv";
@Override
- public String getElement()
+ public void endElement(ResponseWriter writer) throws IOException
+ {
+ writer.endElement("div");
+ }
+
+ @Override
+ public void startElement(ResponseWriter writer) throws IOException
{
- return "div";
+ writer.startElement("div", this);
}
}
1.4 +47 -75 jboss-seam/src/ui/org/jboss/seam/ui/HtmlLayoutForm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HtmlLayoutForm.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlLayoutForm.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- HtmlLayoutForm.java 17 Mar 2007 05:04:01 -0000 1.3
+++ HtmlLayoutForm.java 17 Mar 2007 17:32:34 -0000 1.4
@@ -11,26 +11,36 @@
{
public static final String COMPONENT_TYPE = "org.jboss.seam.ui.HtmlLayoutForm";
+ public static final String COMPONENT_FAMILY = "org.jboss.seam.ui.LayoutForm";
@Override
- public String getElement()
+ public String getFamily()
{
- return HTML.DIV_ELEM;
+ return COMPONENT_FAMILY;
}
@Override
- public void encodeChildren(FacesContext context) throws IOException
+ public void endElement(ResponseWriter writer) throws IOException
+ {
+ writer.endElement("div");
+ }
+
+ @Override
+ public void startElement(ResponseWriter writer) throws IOException
{
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute(HTML.STYLE_ATTR, "display: table;", null);
+ writer.startElement("div", this);
+ writer.writeAttribute("style", "display: table;", null);
+ }
+ @Override
+ public void encodeChildren(FacesContext context) throws IOException
+ {
for (Object child : this.getChildren())
{
if (child instanceof UIComponent)
{
- writeRow(context, (UIComponent) child);
+ renderChild( context, (UIComponent) child );
}
-
}
}
@@ -40,86 +50,41 @@
return true;
}
- private void writeRow(FacesContext facesContext, UIComponent child) throws IOException
+ private void renderChild(FacesContext facesContext, UIComponent child) throws IOException
{
- UIComponent belowField = child.getFacet("belowField");
- UIComponent belowLabel = child.getFacet("belowLabel");
-
- renderChild( facesContext, child, belowField, belowLabel, facesContext.getResponseWriter() );
- }
+ ResponseWriter writer = facesContext.getResponseWriter();
- private void renderChild(FacesContext facesContext, UIComponent child, UIComponent belowField, UIComponent belowLabel, ResponseWriter writer) throws IOException
- {
- writer.startElement(HTML.DIV_ELEM, this);
- writer.writeAttribute(HTML.STYLE_ATTR, "display: table-row;", null);
+ writer.startElement("div", this);
+ writer.writeAttribute("style", "display: table-row;", null);
- writer.startElement(HTML.DIV_ELEM, child);
- writer.writeAttribute(HTML.STYLE_ATTR, "display: table-cell; vertical-align: top", null);
- writeLabel(facesContext, child);
+ writer.startElement("div", child);
+ writer.writeAttribute("style", "display: table-cell; vertical-align: top", null);
+ renderLabel(facesContext, child);
+ UIComponent belowLabel = child.getFacet("belowLabel");
if (belowLabel != null)
{
- writer.startElement(HTML.DIV_ELEM, this);
+ writer.startElement("div", this);
JSF.renderChild(facesContext, belowLabel);
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement("div");
}
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement("div");
- writer.startElement(HTML.DIV_ELEM, this);
- writer.writeAttribute(HTML.STYLE_ATTR, "display: table-cell;", null);
+ writer.startElement("div", this);
+ writer.writeAttribute("style", "display: table-cell;", null);
JSF.renderChild(facesContext, child);
+ UIComponent belowField = child.getFacet("belowField");
if (belowField != null)
{
- writer.startElement(HTML.DIV_ELEM, this);
+ writer.startElement("div", this);
JSF.renderChild(facesContext, belowField);
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement("div");
}
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement("div");
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement("div");
}
- /*private void renderChild(FacesContext facesContext, UIComponent child, UIComponent belowField, UIComponent belowLabel, ResponseWriter writer) throws IOException
- {
- writer.startElement(HTML.TR_ELEM, child);
- writer.startElement(HTML.TD_ELEM, child);
-
- writeLabel(facesContext, (UIDecorate) child);
-
- writer.endElement(HTML.TD_ELEM);
- writer.startElement(HTML.TD_ELEM, child);
- JSF.renderChild(facesContext, child);
- writer.endElement(HTML.TD_ELEM);
- writer.endElement(HTML.TR_ELEM);
- if (belowLabel != null || belowField != null)
- {
- writer.startElement(HTML.TR_ELEM, this);
- if (belowLabel != null)
- {
- writer.startElement(HTML.TD_ELEM, belowLabel);
- JSF.renderChild(facesContext, belowLabel);
- writer.endElement(HTML.TD_ELEM);
- }
- else
- {
- writer.startElement(HTML.TD_ELEM, this);
- writer.endElement(HTML.TD_ELEM);
- }
- if (belowField != null)
- {
- writer.startElement(HTML.TD_ELEM, belowField);
- JSF.renderChild(facesContext, belowField);
- writer.endElement(HTML.TD_ELEM);
- }
- else
- {
- writer.startElement(HTML.TD_ELEM, this);
- writer.endElement(HTML.TD_ELEM);
- }
- writer.endElement(HTML.TR_ELEM);
- }
- }*/
-
- private void writeLabel(FacesContext facesContext, UIComponent child) throws IOException
+ private void renderLabel(FacesContext facesContext, UIComponent child) throws IOException
{
ResponseWriter writer = facesContext.getResponseWriter();
// Write out a label element
@@ -167,10 +132,17 @@
JSF.renderChild(facesContext, beforeRequiredLabelDecoration);
}
- writer.startElement(HTML.LABEL_ELEM, label);
- writer.writeAttribute(HTML.FOR_ATTR, UIDecorate.getInputClientId(child, facesContext), HTML.FOR_ATTR);
+ String inputClientId = UIDecorate.getInputClientId(child, facesContext);
+ if (inputClientId!=null)
+ {
+ writer.startElement("label", label);
+ writer.writeAttribute("for", inputClientId, "for");
+ }
JSF.renderChild(facesContext, label);
- writer.endElement(HTML.LABEL_ELEM);
+ if (inputClientId!=null)
+ {
+ writer.endElement("label");
+ }
UIComponent afterLabelDecoration = UIDecorate.getDecoration("afterLabel", child);
UIComponent afterInvalidLabelDecoration = UIDecorate.getDecoration("afterInvalidLabel", child);
1.2 +12 -2 jboss-seam/src/ui/org/jboss/seam/ui/HtmlSpan.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HtmlSpan.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlSpan.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HtmlSpan.java 2 Oct 2006 18:20:36 -0000 1.1
+++ HtmlSpan.java 17 Mar 2007 17:32:34 -0000 1.2
@@ -1,14 +1,24 @@
package org.jboss.seam.ui;
+import java.io.IOException;
+
+import javax.faces.context.ResponseWriter;
+
public class HtmlSpan extends UIStyleDecoration
{
public static final String COMPONENT_TYPE = "org.jboss.seam.ui.HtmlSpan";
@Override
- public String getElement()
+ public void endElement(ResponseWriter writer) throws IOException
+ {
+ writer.endElement("span");
+ }
+
+ @Override
+ public void startElement(ResponseWriter writer) throws IOException
{
- return "span";
+ writer.startElement("span", this);
}
}
1.6 +4 -3 jboss-seam/src/ui/org/jboss/seam/ui/UIStyleDecoration.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIStyleDecoration.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/UIStyleDecoration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- UIStyleDecoration.java 16 Jan 2007 20:52:45 -0000 1.5
+++ UIStyleDecoration.java 17 Mar 2007 17:32:34 -0000 1.6
@@ -54,7 +54,7 @@
super.encodeBegin(context);
ResponseWriter response = context.getResponseWriter();
- response.startElement( getElement(), this );
+ startElement(response);
response.writeAttribute("id", getClientId(context), "id");
@@ -81,12 +81,13 @@
if ( !isRendered() ) return;
ResponseWriter response = context.getResponseWriter();
- response.endElement( getElement() );
+ endElement(response);
response.flush();
super.encodeEnd(context);
}
- public abstract String getElement();
+ public abstract void startElement(ResponseWriter writer) throws IOException;
+ public abstract void endElement(ResponseWriter writer) throws IOException;
public String getStyle()
{
More information about the jboss-cvs-commits
mailing list