You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sl...@apache.org on 2009/02/05 00:55:29 UTC
svn commit: r740940 [8/9] - in /myfaces/core/branches/2_0_0:
api/src/main/java/javax/faces/webapp/pdl/facelets/
api/src/main/resources/META-INF/ impl/src/main/java/com/
impl/src/main/java/com/sun/ impl/src/main/java/com/sun/facelets/
impl/src/main/java...
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ChooseWhenHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ChooseWhenHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ChooseWhenHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ChooseWhenHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,55 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import javax.faces.component.UIComponent;
+
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: ChooseWhenHandler.java,v 1.3 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class ChooseWhenHandler extends TagHandler
+{
+
+ private final TagAttribute test;
+
+ public ChooseWhenHandler(TagConfig config)
+ {
+ super(config);
+ this.test = this.getRequiredAttribute("test");
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+
+ public boolean isTestTrue(FaceletContext ctx)
+ {
+ return this.test.getBoolean(ctx);
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ForEachHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ForEachHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ForEachHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/ForEachHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,333 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Jacob Hookom
+ * @author Andrew Robinson
+ * @version $Id: ForEachHandler.java,v 1.12 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class ForEachHandler extends TagHandler
+{
+
+ private static class ArrayIterator implements Iterator
+ {
+
+ protected final Object array;
+
+ protected int i;
+
+ protected final int len;
+
+ public ArrayIterator(Object src)
+ {
+ this.i = 0;
+ this.array = src;
+ this.len = Array.getLength(src);
+ }
+
+ public boolean hasNext()
+ {
+ return this.i < this.len;
+ }
+
+ public Object next()
+ {
+ return Array.get(this.array, this.i++);
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private final TagAttribute begin;
+
+ private final TagAttribute end;
+
+ private final TagAttribute items;
+
+ private final TagAttribute step;
+
+ private final TagAttribute tranzient;
+
+ private final TagAttribute var;
+
+ private final TagAttribute varStatus;
+
+ /**
+ * @param config
+ */
+ public ForEachHandler(TagConfig config)
+ {
+ super(config);
+ this.items = this.getAttribute("items");
+ this.var = this.getAttribute("var");
+ this.begin = this.getAttribute("begin");
+ this.end = this.getAttribute("end");
+ this.step = this.getAttribute("step");
+ this.varStatus = this.getAttribute("varStatus");
+ this.tranzient = this.getAttribute("transient");
+
+ if (this.items == null && this.begin != null && this.end == null)
+ {
+ throw new TagAttributeException(this.tag, this.begin,
+ "If the 'items' attribute is not specified, but the 'begin' attribute is, then the 'end' attribute is required");
+ }
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+
+ int s = this.getBegin(ctx);
+ int e = this.getEnd(ctx);
+ int m = this.getStep(ctx);
+ Integer sO = this.begin != null ? new Integer(s) : null;
+ Integer eO = this.end != null ? new Integer(e) : null;
+ Integer mO = this.step != null ? new Integer(m) : null;
+
+ boolean t = this.getTransient(ctx);
+ Object src = null;
+ ValueExpression srcVE = null;
+ if (this.items != null)
+ {
+ srcVE = this.items.getValueExpression(ctx, Object.class);
+ src = srcVE.getValue(ctx);
+ }
+ else
+ {
+ byte[] b = new byte[e + 1];
+ for (int i = 0; i < b.length; i++)
+ {
+ b[i] = (byte) i;
+ }
+ src = b;
+ }
+ if (src != null)
+ {
+ Iterator itr = this.toIterator(src);
+ if (itr != null)
+ {
+ int i = 0;
+
+ // move to start
+ while (i < s && itr.hasNext())
+ {
+ itr.next();
+ i++;
+ }
+
+ String v = this.getVarName(ctx);
+ String vs = this.getVarStatusName(ctx);
+ VariableMapper vars = ctx.getVariableMapper();
+ ValueExpression ve = null;
+ ValueExpression vO = this.capture(v, vars);
+ ValueExpression vsO = this.capture(vs, vars);
+ int mi = 0;
+ Object value = null;
+ try
+ {
+ boolean first = true;
+ while (i <= e && itr.hasNext())
+ {
+ value = itr.next();
+
+ // set the var
+ if (v != null)
+ {
+ if (t || srcVE == null)
+ {
+ ctx.setAttribute(v, value);
+ }
+ else
+ {
+ ve = this.getVarExpr(srcVE, src, value, i);
+ vars.setVariable(v, ve);
+ }
+ }
+
+ // set the varStatus
+ if (vs != null)
+ {
+ IterationStatus itrS = new IterationStatus(first, !itr.hasNext(), i, sO, eO, mO);
+ if (t || srcVE == null)
+ {
+ ctx.setAttribute(vs, itrS);
+ }
+ else
+ {
+ ve = new IterationStatusExpression(itrS);
+ vars.setVariable(vs, ve);
+ }
+ }
+
+ // execute body
+ this.nextHandler.apply(ctx, parent);
+
+ // increment steps
+ mi = 1;
+ while (mi < m && itr.hasNext())
+ {
+ itr.next();
+ mi++;
+ i++;
+ }
+ i++;
+
+ first = false;
+ }
+ }
+ finally
+ {
+ if (v != null)
+ {
+ vars.setVariable(v, vO);
+ }
+ if (vs != null)
+ {
+ vars.setVariable(vs, vsO);
+ }
+ }
+ }
+ }
+ }
+
+ private final ValueExpression capture(String name, VariableMapper vars)
+ {
+ if (name != null)
+ {
+ return vars.setVariable(name, null);
+ }
+ return null;
+ }
+
+ private final int getBegin(FaceletContext ctx)
+ {
+ if (this.begin != null)
+ {
+ return this.begin.getInt(ctx);
+ }
+ return 0;
+ }
+
+ private final int getEnd(FaceletContext ctx)
+ {
+ if (this.end != null)
+ {
+ return this.end.getInt(ctx);
+ }
+ return Integer.MAX_VALUE - 1; // hotspot bug in the JVM
+ }
+
+ private final int getStep(FaceletContext ctx)
+ {
+ if (this.step != null)
+ {
+ return this.step.getInt(ctx);
+ }
+ return 1;
+ }
+
+ private final boolean getTransient(FaceletContext ctx)
+ {
+ if (this.tranzient != null)
+ {
+ return this.tranzient.getBoolean(ctx);
+ }
+ return false;
+ }
+
+ private final ValueExpression getVarExpr(ValueExpression ve, Object src, Object value, int i)
+ {
+ if (src instanceof List || src.getClass().isArray())
+ {
+ return new IndexedValueExpression(ve, i);
+ }
+ else if (src instanceof Map && value instanceof Map.Entry)
+ {
+ return new MappedValueExpression(ve, (Map.Entry) value);
+ }
+ else if (src instanceof Collection)
+ {
+ return new IteratedValueExpression(ve, value);
+ }
+ throw new IllegalStateException("Cannot create VE for: " + src);
+ }
+
+ private final String getVarName(FaceletContext ctx)
+ {
+ if (this.var != null)
+ {
+ return this.var.getValue(ctx);
+ }
+ return null;
+ }
+
+ private final String getVarStatusName(FaceletContext ctx)
+ {
+ if (this.varStatus != null)
+ {
+ return this.varStatus.getValue(ctx);
+ }
+ return null;
+ }
+
+ private final Iterator toIterator(Object src)
+ {
+ if (src == null)
+ {
+ return null;
+ }
+ else if (src instanceof Collection)
+ {
+ return ((Collection) src).iterator();
+ }
+ else if (src instanceof Map)
+ {
+ return ((Map) src).entrySet().iterator();
+ }
+ else if (src.getClass().isArray())
+ {
+ return new ArrayIterator(src);
+ }
+ else
+ {
+ throw new TagAttributeException(this.tag, this.items, "Must evaluate to a Collection, Map, Array, or null.");
+ }
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IfHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IfHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IfHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IfHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,62 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: IfHandler.java,v 1.5 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class IfHandler extends TagHandler
+{
+
+ private final TagAttribute test;
+
+ private final TagAttribute var;
+
+ /**
+ * @param config
+ */
+ public IfHandler(TagConfig config)
+ {
+ super(config);
+ this.test = this.getRequiredAttribute("test");
+ this.var = this.getAttribute("var");
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException
+ {
+ boolean b = this.test.getBoolean(ctx);
+ if (this.var != null)
+ {
+ ctx.setAttribute(var.getValue(ctx), new Boolean(b));
+ }
+ if (b)
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IndexedValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IndexedValueExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IndexedValueExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IndexedValueExpression.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,158 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: IndexedValueExpression.java,v 1.4 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class IndexedValueExpression extends ValueExpression
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final Integer i;
+
+ private final ValueExpression orig;
+
+ /**
+ *
+ */
+ public IndexedValueExpression(ValueExpression orig, int i)
+ {
+ this.i = new Integer(i);
+ this.orig = orig;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ public Object getValue(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ return context.getELResolver().getValue(context, base, i);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object value)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ context.getELResolver().setValue(context, base, i, value);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ public boolean isReadOnly(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ return context.getELResolver().isReadOnly(context, base, i);
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ public Class getType(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ return context.getELResolver().getType(context, base, i);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ public Class getExpectedType()
+ {
+ return Object.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ public String getExpressionString()
+ {
+ return this.orig.getExpressionString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ return this.orig.equals(obj);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#hashCode()
+ */
+ public int hashCode()
+ {
+ return this.orig.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#isLiteralText()
+ */
+ public boolean isLiteralText()
+ {
+ return false;
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IteratedValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IteratedValueExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IteratedValueExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IteratedValueExpression.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,132 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import javax.el.ELContext;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+
+/**
+ * @version $Id: IteratedValueExpression.java,v 1.2 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class IteratedValueExpression extends ValueExpression
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private ValueExpression orig;
+
+ private Object value;
+
+ public IteratedValueExpression(ValueExpression orig, Object value)
+ {
+ this.orig = orig;
+ this.value = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ public Object getValue(ELContext context)
+ {
+ return value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object value)
+ {
+ context.setPropertyResolved(false);
+ throw new PropertyNotWritableException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ public boolean isReadOnly(ELContext context)
+ {
+ context.setPropertyResolved(false);
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ public Class getType(ELContext context)
+ {
+ context.setPropertyResolved(false);
+ return Object.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ public Class getExpectedType()
+ {
+ return Object.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ public String getExpressionString()
+ {
+ return this.orig.getExpressionString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ return this.orig.equals(obj);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#hashCode()
+ */
+ public int hashCode()
+ {
+ return this.orig.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#isLiteralText()
+ */
+ public boolean isLiteralText()
+ {
+ return false;
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatus.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatus.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatus.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatus.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,86 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import java.io.Serializable;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: IterationStatus.java,v 1.4 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class IterationStatus implements Serializable
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final int index;
+
+ private final boolean first;
+
+ private final boolean last;
+
+ private final Integer begin;
+
+ private final Integer end;
+
+ private final Integer step;
+
+ /**
+ *
+ */
+ public IterationStatus(boolean first, boolean last, int index, Integer begin, Integer end, Integer step)
+ {
+ this.index = index;
+ this.begin = begin;
+ this.end = end;
+ this.step = step;
+ this.first = first;
+ this.last = last;
+ }
+
+ public boolean isFirst()
+ {
+ return this.first;
+ }
+
+ public boolean isLast()
+ {
+ return this.last;
+ }
+
+ public Integer getBegin()
+ {
+ return begin;
+ }
+
+ public Integer getEnd()
+ {
+ return end;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public Integer getStep()
+ {
+ return step;
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatusExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatusExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatusExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/IterationStatusExpression.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,137 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: IterationStatusExpression.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class IterationStatusExpression extends ValueExpression
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final IterationStatus status;
+
+ /**
+ *
+ */
+ public IterationStatusExpression(IterationStatus status)
+ {
+ this.status = status;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ public Object getValue(ELContext context)
+ {
+ return this.status;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object value)
+ {
+ throw new UnsupportedOperationException("Cannot set IterationStatus");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ public boolean isReadOnly(ELContext context)
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ public Class getType(ELContext context)
+ {
+ return IterationStatus.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ public Class getExpectedType()
+ {
+ return IterationStatus.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ public String getExpressionString()
+ {
+ return this.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ return this.status.equals(obj);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#hashCode()
+ */
+ public int hashCode()
+ {
+ return this.status.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#isLiteralText()
+ */
+ public boolean isLiteralText()
+ {
+ return true;
+ }
+
+ public String toString()
+ {
+ return this.status.toString();
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/JstlCoreLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/JstlCoreLibrary.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/JstlCoreLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/JstlCoreLibrary.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,49 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import com.sun.facelets.tag.AbstractTagLibrary;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: JstlCoreLibrary.java,v 1.5 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class JstlCoreLibrary extends AbstractTagLibrary
+{
+
+ public final static String Namespace = "http://java.sun.com/jstl/core";
+
+ public final static JstlCoreLibrary Instance = new JstlCoreLibrary();
+
+ public JstlCoreLibrary()
+ {
+ super(Namespace);
+
+ this.addTagHandler("if", IfHandler.class);
+
+ this.addTagHandler("forEach", ForEachHandler.class);
+
+ this.addTagHandler("catch", CatchHandler.class);
+
+ this.addTagHandler("choose", ChooseHandler.class);
+
+ this.addTagHandler("when", ChooseWhenHandler.class);
+
+ this.addTagHandler("otherwise", ChooseOtherwiseHandler.class);
+
+ this.addTagHandler("set", SetHandler.class);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/MappedValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/MappedValueExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/MappedValueExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/MappedValueExpression.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,193 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: MappedValueExpression.java,v 1.6 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class MappedValueExpression extends ValueExpression
+{
+
+ private final static class Entry implements Map.Entry, Serializable
+ {
+
+ private final Map src;
+ private final Object key;
+
+ public Entry(Map src, Object key)
+ {
+ this.src = src;
+ this.key = key;
+ }
+
+ public Object getKey()
+ {
+ return key;
+ }
+
+ public Object getValue()
+ {
+ return src.get(key);
+ }
+
+ public Object setValue(Object value)
+ {
+ return src.put(key, value);
+ }
+
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final Object key;
+
+ private final ValueExpression orig;
+
+ /**
+ *
+ */
+ public MappedValueExpression(ValueExpression orig, Map.Entry entry)
+ {
+ this.orig = orig;
+ this.key = entry.getKey();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ public Object getValue(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(true);
+ return new Entry((Map) base, key);
+
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object value)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ context.getELResolver().setValue(context, base, key, value);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ public boolean isReadOnly(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ return context.getELResolver().isReadOnly(context, base, key);
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ public Class getType(ELContext context)
+ {
+ Object base = this.orig.getValue(context);
+ if (base != null)
+ {
+ context.setPropertyResolved(false);
+ return context.getELResolver().getType(context, base, key);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ public Class getExpectedType()
+ {
+ return Object.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ public String getExpressionString()
+ {
+ return this.orig.getExpressionString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ return this.orig.equals(obj);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#hashCode()
+ */
+ public int hashCode()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)eturn new Map.Entry<K, V>
+ *
+ * @see javax.el.Expression#isLiteralText()
+ */
+ public boolean isLiteralText()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/SetHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/SetHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/SetHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/SetHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,57 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * Simplified implementation of c:set
+ *
+ * @author Jacob Hookom
+ * @version $Id: SetHandler.java,v 1.2 2008/07/13 19:01:44 rlubke Exp $
+ */
+public class SetHandler extends TagHandler
+{
+
+ private final TagAttribute var;
+
+ private final TagAttribute value;
+
+ public SetHandler(TagConfig config)
+ {
+ super(config);
+ this.value = this.getRequiredAttribute("value");
+ this.var = this.getRequiredAttribute("var");
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ String varStr = this.var.getValue(ctx);
+ ValueExpression veObj = this.value.getValueExpression(ctx, Object.class);
+ ctx.getVariableMapper().setVariable(varStr, veObj);
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/core/package.html Wed Feb 4 23:55:25 2009
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:43 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Tag Library for <b>http://java.sun.com/jstl/core</b>.
+See JSTL Core Tag Javadocs for attributes/functionality.
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFnLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFnLibrary.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFnLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFnLibrary.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,100 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.fn;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+import com.sun.facelets.tag.TagLibrary;
+
+/**
+ * Library for JSTL Functions
+ *
+ * @author Jacob Hookom
+ * @version $Id: JstlFnLibrary.java,v 1.3 2008/07/13 19:01:51 rlubke Exp $
+ */
+public class JstlFnLibrary implements TagLibrary
+{
+
+ public final static String Namespace = "http://java.sun.com/jsp/jstl/functions";
+
+ private final Map fns = new HashMap();
+
+ public JstlFnLibrary()
+ {
+ super();
+ try
+ {
+ Method[] methods = JstlFunction.class.getMethods();
+ for (int i = 0; i < methods.length; i++)
+ {
+ if (Modifier.isStatic(methods[i].getModifiers()))
+ {
+ fns.put(methods[i].getName(), methods[i]);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean containsNamespace(String ns)
+ {
+ return Namespace.equals(ns);
+ }
+
+ public boolean containsTagHandler(String ns, String localName)
+ {
+ return false;
+ }
+
+ public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
+ {
+ return null;
+ }
+
+ public boolean containsFunction(String ns, String name)
+ {
+ if (Namespace.equals(ns))
+ {
+ return this.fns.containsKey(name);
+ }
+ return false;
+ }
+
+ public Method createFunction(String ns, String name)
+ {
+ if (Namespace.equals(ns))
+ {
+ return (Method) this.fns.get(name);
+ }
+ return null;
+ }
+
+ public static void main(String[] argv)
+ {
+ JstlFnLibrary lib = new JstlFnLibrary();
+ System.out.println(lib.containsFunction(JstlFnLibrary.Namespace, "toUpperCase"));
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFunction.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFunction.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFunction.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/JstlFunction.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,218 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.jstl.fn;
+
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Implementations of JSTL Functions
+ *
+ * @author Jacob Hookom
+ * @version $Id: JstlFunction.java,v 1.6 2009/01/16 20:51:11 rlubke Exp $
+ */
+public final class JstlFunction
+{
+
+ private JstlFunction()
+ {
+ }
+
+ public static boolean contains(String name, String searchString)
+ {
+ if (name == null || searchString == null)
+ {
+ return false;
+ }
+
+ return -1 != name.indexOf(searchString);
+ }
+
+ public static boolean containsIgnoreCase(String name, String searchString)
+ {
+ if (name == null || searchString == null)
+ {
+ return false;
+ }
+ return -1 != name.toUpperCase().indexOf(searchString.toUpperCase());
+ }
+
+ public static boolean endsWith(String name, String searchString)
+ {
+ if (name == null || searchString == null)
+ {
+ return false;
+ }
+ return name.endsWith(searchString);
+ }
+
+ public static String escapeXml(String value)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ return value.replaceAll("<", "<");
+ }
+
+ public static int indexOf(String name, String searchString)
+ {
+ if (name == null || searchString == null)
+ {
+ return -1;
+ }
+ return name.indexOf(searchString);
+ }
+
+ public static String join(String[] a, String delim)
+ {
+ if (a == null || delim == null)
+ {
+ return null;
+ }
+ if (a.length == 0)
+ {
+ return "";
+ }
+ StringBuffer sb = new StringBuffer(a.length * (a[0].length() + delim.length()));
+ for (int i = 0; i < a.length; i++)
+ {
+ sb.append(a[i]);
+ if (i < (a.length - 1))
+ {
+ sb.append(delim);
+ }
+ }
+ return sb.toString();
+ }
+
+ public static int length(Object obj)
+ {
+ if (obj == null)
+ {
+ return 0;
+ }
+ if (obj instanceof Collection)
+ {
+ return ((Collection) obj).size();
+ }
+ if (obj.getClass().isArray())
+ {
+ return Array.getLength(obj);
+ }
+ if (obj instanceof String)
+ {
+ return ((String) obj).length();
+ }
+ if (obj instanceof Map)
+ {
+ return ((Map) obj).size();
+ }
+ throw new IllegalArgumentException("Object type not supported: " + obj.getClass().getName());
+ }
+
+ public static String replace(String value, String a, String b)
+ {
+ if (value == null || a == null || b == null)
+ {
+ return null;
+ }
+ return value.replaceAll(a, b);
+ }
+
+ public static String[] split(String value, String d)
+ {
+ if (value == null || d == null)
+ {
+ return null;
+ }
+ return value.split(d);
+ }
+
+ public static boolean startsWith(String value, String p)
+ {
+ if (value == null || p == null)
+ {
+ return false;
+ }
+ return value.startsWith(p);
+ }
+
+ public static String substring(String v, int s, int e)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ return v.substring(s, e);
+ }
+
+ public static String substringAfter(String v, String p)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ int i = v.indexOf(p);
+ if (i >= 0)
+ {
+ return v.substring(i + p.length());
+ }
+ return null;
+ }
+
+ public static String substringBefore(String v, String s)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ int i = v.indexOf(s);
+ if (i > 0)
+ {
+ return v.substring(0, i);
+ }
+ return null;
+ }
+
+ public static String toLowerCase(String v)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ return v.toLowerCase();
+ }
+
+ public static String toUpperCase(String v)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ return v.toUpperCase();
+ }
+
+ public static String trim(String v)
+ {
+ if (v == null)
+ {
+ return null;
+ }
+ return v.trim();
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/jstl/fn/package.html Wed Feb 4 23:55:25 2009
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:51 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Tag Library for <b>http://java.sun.com/jstl/functions</b>.
+See JSTL Functions Tag Javadocs for attributes/functionality.
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/package.html Wed Feb 4 23:55:25 2009
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Tags and other objects that define Facelet implementations.
+Includes abstract classes to make the developer's job easier.
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRef.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRef.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRef.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRef.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import javax.faces.component.UIComponentBase;
+
+public final class ComponentRef extends UIComponentBase
+{
+
+ public final static String COMPONENT_TYPE = "facelets.ui.ComponentRef";
+ public final static String COMPONENT_FAMILY = "facelets";
+
+ public ComponentRef()
+ {
+ super();
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRefHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRefHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRefHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ComponentRefHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,30 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+public final class ComponentRefHandler extends ComponentHandler
+{
+
+ public final static String Name = "component";
+
+ public ComponentRefHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/CompositionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/CompositionHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/CompositionHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/CompositionHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,169 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.TemplateClient;
+import com.sun.facelets.el.VariableMapperWrapper;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: CompositionHandler.java,v 1.14 2008/07/13 19:01:42 rlubke Exp $
+ */
+public final class CompositionHandler extends TagHandler implements TemplateClient
+{
+
+ private static final Logger log = Logger.getLogger("facelets.tag.ui.composition");
+
+ public final static String Name = "composition";
+
+ protected final TagAttribute template;
+
+ protected final Map handlers;
+
+ protected final ParamHandler[] params;
+
+ /**
+ * @param config
+ */
+ public CompositionHandler(TagConfig config)
+ {
+ super(config);
+ this.template = this.getAttribute("template");
+ if (this.template != null)
+ {
+ this.handlers = new HashMap();
+ Iterator itr = this.findNextByType(DefineHandler.class);
+ DefineHandler d = null;
+ while (itr.hasNext())
+ {
+ d = (DefineHandler) itr.next();
+ this.handlers.put(d.getName(), d);
+ if (log.isLoggable(Level.FINE))
+ {
+ log.fine(tag + " found Define[" + d.getName() + "]");
+ }
+ }
+ List paramC = new ArrayList();
+ itr = this.findNextByType(ParamHandler.class);
+ while (itr.hasNext())
+ {
+ paramC.add(itr.next());
+ }
+ if (paramC.size() > 0)
+ {
+ this.params = new ParamHandler[paramC.size()];
+ for (int i = 0; i < this.params.length; i++)
+ {
+ this.params[i] = (ParamHandler) paramC.get(i);
+ }
+ }
+ else
+ {
+ this.params = null;
+ }
+ }
+ else
+ {
+ this.params = null;
+ this.handlers = null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ if (this.template != null)
+ {
+ VariableMapper orig = ctx.getVariableMapper();
+ if (this.params != null)
+ {
+ VariableMapper vm = new VariableMapperWrapper(orig);
+ ctx.setVariableMapper(vm);
+ for (int i = 0; i < this.params.length; i++)
+ {
+ this.params[i].apply(ctx, parent);
+ }
+ }
+
+ ctx.extendClient(this);
+ try
+ {
+ ctx.includeFacelet(parent, this.template.getValue(ctx));
+ }
+ finally
+ {
+ ctx.popClient(this);
+ ctx.setVariableMapper(orig);
+ }
+ }
+ else
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ }
+
+ public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException, FacesException,
+ FaceletException, ELException
+ {
+ if (name != null)
+ {
+ if (this.handlers == null)
+ {
+ return false;
+ }
+ DefineHandler handler = (DefineHandler) this.handlers.get(name);
+ if (handler != null)
+ {
+ handler.applyDefinition(ctx, parent);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ this.nextHandler.apply(ctx, parent);
+ return true;
+ }
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DecorateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DecorateHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DecorateHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DecorateHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,148 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.TemplateClient;
+import com.sun.facelets.el.VariableMapperWrapper;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: DecorateHandler.java,v 1.16 2008/07/13 19:01:41 rlubke Exp $
+ */
+public final class DecorateHandler extends TagHandler implements TemplateClient
+{
+
+ private static final Logger log = Logger.getLogger("facelets.tag.ui.decorate");
+
+ private final TagAttribute template;
+
+ private final Map handlers;
+
+ private final ParamHandler[] params;
+
+ /**
+ * @param config
+ */
+ public DecorateHandler(TagConfig config)
+ {
+ super(config);
+ this.template = this.getRequiredAttribute("template");
+ this.handlers = new HashMap();
+
+ Iterator itr = this.findNextByType(DefineHandler.class);
+ DefineHandler d = null;
+ while (itr.hasNext())
+ {
+ d = (DefineHandler) itr.next();
+ this.handlers.put(d.getName(), d);
+ if (log.isLoggable(Level.FINE))
+ {
+ log.fine(tag + " found Define[" + d.getName() + "]");
+ }
+ }
+ List paramC = new ArrayList();
+ itr = this.findNextByType(ParamHandler.class);
+ while (itr.hasNext())
+ {
+ paramC.add(itr.next());
+ }
+ if (paramC.size() > 0)
+ {
+ this.params = new ParamHandler[paramC.size()];
+ for (int i = 0; i < this.params.length; i++)
+ {
+ this.params[i] = (ParamHandler) paramC.get(i);
+ }
+ }
+ else
+ {
+ this.params = null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ VariableMapper orig = ctx.getVariableMapper();
+ if (this.params != null)
+ {
+ VariableMapper vm = new VariableMapperWrapper(orig);
+ ctx.setVariableMapper(vm);
+ for (int i = 0; i < this.params.length; i++)
+ {
+ this.params[i].apply(ctx, parent);
+ }
+ }
+
+ ctx.pushClient(this);
+ try
+ {
+ ctx.includeFacelet(parent, this.template.getValue(ctx));
+ }
+ finally
+ {
+ ctx.setVariableMapper(orig);
+ ctx.popClient(this);
+ }
+ }
+
+ public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException, FacesException,
+ FaceletException, ELException
+ {
+ if (name != null)
+ {
+ DefineHandler handler = (DefineHandler) this.handlers.get(name);
+ if (handler != null)
+ {
+ handler.applyDefinition(ctx, parent);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ this.nextHandler.apply(ctx, parent);
+ return true;
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DefineHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DefineHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DefineHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/DefineHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,75 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: DefineHandler.java,v 1.5 2008/07/13 19:01:41 rlubke Exp $
+ */
+public final class DefineHandler extends TagHandler
+{
+
+ private final String name;
+
+ /**
+ * @param config
+ */
+ public DefineHandler(TagConfig config)
+ {
+ super(config);
+ TagAttribute attr = this.getRequiredAttribute("name");
+ if (!attr.isLiteral())
+ {
+ throw new TagAttributeException(this.tag, attr, "Must be Literal");
+ }
+ this.name = attr.getValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ // no-op
+ // this.nextHandler.apply(ctx, parent);
+ }
+
+ public void applyDefinition(FaceletContext ctx, UIComponent parent) throws IOException, FacesException,
+ FaceletException, ELException
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/IncludeHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/IncludeHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/IncludeHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/IncludeHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,74 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.el.VariableMapperWrapper;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: IncludeHandler.java,v 1.5 2008/07/13 19:01:41 rlubke Exp $
+ */
+public final class IncludeHandler extends TagHandler
+{
+
+ private final TagAttribute src;
+
+ /**
+ * @param config
+ */
+ public IncludeHandler(TagConfig config)
+ {
+ super(config);
+ this.src = this.getRequiredAttribute("src");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ String path = this.src.getValue(ctx);
+ if (path == null || path.length() == 0)
+ {
+ return;
+ }
+ VariableMapper orig = ctx.getVariableMapper();
+ ctx.setVariableMapper(new VariableMapperWrapper(orig));
+ try
+ {
+ this.nextHandler.apply(ctx, null);
+ ctx.includeFacelet(parent, path);
+ }
+ finally
+ {
+ ctx.setVariableMapper(orig);
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/InsertHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/InsertHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/InsertHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/InsertHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,97 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.TemplateClient;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: InsertHandler.java,v 1.7 2008/07/13 19:01:42 rlubke Exp $
+ */
+public final class InsertHandler extends TagHandler implements TemplateClient
+{
+
+ private final String name;
+
+ /**
+ * @param config
+ */
+ public InsertHandler(TagConfig config)
+ {
+ super(config);
+ TagAttribute attr = this.getAttribute("name");
+ if (attr != null)
+ {
+ if (!attr.isLiteral())
+ {
+ throw new TagAttributeException(this.tag, attr, "Must be Literal");
+ }
+ this.name = attr.getValue();
+ }
+ else
+ {
+ this.name = null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+
+ ctx.extendClient(this);
+ boolean found = false;
+ try
+ {
+ found = ctx.includeDefinition(parent, this.name);
+ }
+ finally
+ {
+ ctx.popClient(this);
+ }
+ if (!found)
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ }
+
+ public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException, FacesException,
+ FaceletException, ELException
+ {
+ if (this.name == name || this.name != null && this.name.equals(name))
+ {
+ this.nextHandler.apply(ctx, parent);
+ return true;
+ }
+ return false;
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ParamHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ParamHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ParamHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/ParamHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,64 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: ParamHandler.java,v 1.6 2008/07/13 19:01:42 rlubke Exp $
+ */
+public class ParamHandler extends TagHandler
+{
+
+ private final TagAttribute name;
+
+ private final TagAttribute value;
+
+ /**
+ * @param config
+ */
+ public ParamHandler(TagConfig config)
+ {
+ super(config);
+ this.name = this.getRequiredAttribute("name");
+ this.value = this.getRequiredAttribute("value");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.pdl.facelets.FaceletHandler#apply(javax.faces.webapp.pdl.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ String nameStr = this.name.getValue(ctx);
+ ValueExpression valueVE = this.value.getValueExpression(ctx, Object.class);
+ ctx.getVariableMapper().setVariable(nameStr, valueVE);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/RepeatHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/RepeatHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/RepeatHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/ui/RepeatHandler.java Wed Feb 4 23:55:25 2009
@@ -0,0 +1,107 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.facelets.tag.ui;
+
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+public class RepeatHandler extends ComponentHandler
+{
+
+ public RepeatHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset meta = super.createMetaRuleset(type);
+
+ if (!UILibrary.Namespace.equals(this.tag.getNamespace()))
+ {
+ meta.add(new TagMetaData(type));
+ }
+
+ meta.alias("class", "styleClass");
+
+ return meta;
+ }
+
+ private class TagMetaData extends Metadata
+ {
+
+ private final String[] attrs;
+
+ public TagMetaData(Class type)
+ {
+ Set s = new HashSet();
+ TagAttribute[] ta = tag.getAttributes().getAll();
+ for (int i = 0; i < ta.length; i++)
+ {
+ if ("class".equals(ta[i].getLocalName()))
+ {
+ s.add("styleClass");
+ }
+ else
+ {
+ s.add(ta[i].getLocalName());
+ }
+ }
+ try
+ {
+ PropertyDescriptor[] pd = Introspector.getBeanInfo(type).getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++)
+ {
+ if (pd[i].getWriteMethod() != null)
+ {
+ s.remove(pd[i].getName());
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // do nothing
+ }
+ this.attrs = (String[]) s.toArray(new String[s.size()]);
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIComponent c = (UIComponent) instance;
+ Map attrs = c.getAttributes();
+ attrs.put("alias.element", tag.getQName());
+ if (this.attrs.length > 0)
+ {
+ attrs.put("alias.attributes", this.attrs);
+ }
+ }
+
+ }
+
+}