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/04/04 20:45:04 UTC
svn commit: r761982 [8/10] - in /myfaces/core/branches/2_0_0/impl/src:
main/java/com/ main/java/org/apache/myfaces/application/
main/java/org/apache/myfaces/config/
main/java/org/apache/myfaces/config/impl/digester/
main/java/org/apache/myfaces/config/...
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/FacetHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/FacetHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/FacetHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/FacetHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * Register a named facet on the UIComponent associated with the closest parent UIComponent custom action. <p/> See <a
+ * target="_new" href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/facet.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: FacetHandler.java,v 1.8 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class FacetHandler extends TagHandler
+{
+
+ public static final String KEY = "facelets.FACET_NAME";
+
+ protected final TagAttribute name;
+
+ public FacetHandler(TagConfig config)
+ {
+ super(config);
+ this.name = this.getRequiredAttribute("name");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ if (parent == null)
+ {
+ throw new TagException(this.tag, "Parent UIComponent was null");
+ }
+ parent.getAttributes().put(KEY, this.name.getValue(ctx));
+ try
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ finally
+ {
+ parent.getAttributes().remove(KEY);
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/LoadBundleHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/LoadBundleHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/LoadBundleHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/LoadBundleHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+
+/**
+ * Load a resource bundle localized for the Locale of the current view, and expose it (as a Map) in the request
+ * attributes of the current request. <p/> See <a target="_new"
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/loadBundle.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: LoadBundleHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class LoadBundleHandler extends TagHandler
+{
+
+ private final static class ResourceBundleMap implements Map<String, String>
+ {
+ private final static class ResourceEntry implements Map.Entry<String, String>
+ {
+
+ protected final String key;
+
+ protected final String value;
+
+ public ResourceEntry(String key, String value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey()
+ {
+ return this.key;
+ }
+
+ public String getValue()
+ {
+ return this.value;
+ }
+
+ public String setValue(String value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int hashCode()
+ {
+ return this.key.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ return (obj instanceof ResourceEntry && this.hashCode() == obj.hashCode());
+ }
+ }
+
+ protected final ResourceBundle bundle;
+
+ public ResourceBundleMap(ResourceBundle bundle)
+ {
+ this.bundle = bundle;
+ }
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ try
+ {
+ bundle.getString(key.toString());
+ return true;
+ }
+ catch (MissingResourceException e)
+ {
+ return false;
+ }
+ }
+
+ public boolean containsValue(Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set<Map.Entry<String, String>> entrySet()
+ {
+ Enumeration<String> e = this.bundle.getKeys();
+ Set<Map.Entry<String, String>> s = new HashSet<Map.Entry<String, String>>();
+ String k;
+ while (e.hasMoreElements())
+ {
+ k = e.nextElement();
+ s.add(new ResourceEntry(k, this.bundle.getString(k)));
+ }
+ return s;
+ }
+
+ public String get(Object key)
+ {
+ try
+ {
+ return this.bundle.getString((String) key);
+ }
+ catch (java.util.MissingResourceException mre)
+ {
+ return "???" + key + "???";
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public Set<String> keySet()
+ {
+ Enumeration<String> e = this.bundle.getKeys();
+ Set<String> s = new HashSet<String>();
+ while (e.hasMoreElements())
+ {
+ s.add(e.nextElement());
+ }
+ return s;
+ }
+
+ public String put(String key, String value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putAll(Map<? extends String, ? extends String> t)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String remove(Object key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size()
+ {
+ return this.keySet().size();
+ }
+
+ public Collection<String> values()
+ {
+ Enumeration<String> e = this.bundle.getKeys();
+ Set<String> s = new HashSet<String>();
+ while (e.hasMoreElements())
+ {
+ s.add(this.bundle.getString(e.nextElement()));
+ }
+ return s;
+ }
+ }
+
+ private final TagAttribute basename;
+
+ private final TagAttribute var;
+
+ /**
+ * @param config
+ */
+ public LoadBundleHandler(TagConfig config)
+ {
+ super(config);
+ this.basename = this.getRequiredAttribute("basename");
+ this.var = this.getRequiredAttribute("var");
+ }
+
+ /**
+ * See taglib documentation.
+ *
+ * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
+ ResourceBundle bundle = null;
+ try
+ {
+ String name = this.basename.getValue(ctx);
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (root != null && root.getLocale() != null)
+ {
+ bundle = ResourceBundle.getBundle(name, root.getLocale(), cl);
+ }
+ else
+ {
+ bundle = ResourceBundle.getBundle(name, Locale.getDefault(), cl);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(this.tag, this.basename, e);
+ }
+ ResourceBundleMap map = new ResourceBundleMap(bundle);
+ FacesContext faces = ctx.getFacesContext();
+ faces.getExternalContext().getRequestMap().put(this.var.getValue(ctx), map);
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/PhaseListenerHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/PhaseListenerHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/PhaseListenerHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/PhaseListenerHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+import org.apache.myfaces.view.facelets.util.ReflectionUtil;
+
+public class PhaseListenerHandler extends TagHandler
+{
+
+ private final static class LazyPhaseListener implements PhaseListener, Serializable
+ {
+
+ private static final long serialVersionUID = -6496143057319213401L;
+
+ private final String type;
+
+ private final ValueExpression binding;
+
+ public LazyPhaseListener(String type, ValueExpression binding)
+ {
+ this.type = type;
+ this.binding = binding;
+ }
+
+ private PhaseListener getInstance()
+ {
+ PhaseListener instance = null;
+ FacesContext faces = FacesContext.getCurrentInstance();
+ if (faces == null)
+ {
+ return null;
+ }
+ if (this.binding != null)
+ {
+ instance = (PhaseListener) binding.getValue(faces.getELContext());
+ }
+ if (instance == null && type != null)
+ {
+ try
+ {
+ instance = (PhaseListener) ReflectionUtil.forName(this.type).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new AbortProcessingException("Couldn't Lazily instantiate PhaseListener", e);
+ }
+ if (this.binding != null)
+ {
+ binding.setValue(faces.getELContext(), instance);
+ }
+ }
+ return instance;
+ }
+
+ public void afterPhase(PhaseEvent event)
+ {
+ PhaseListener pl = this.getInstance();
+ if (pl != null)
+ {
+ pl.afterPhase(event);
+ }
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ PhaseListener pl = this.getInstance();
+ if (pl != null)
+ {
+ pl.beforePhase(event);
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ PhaseListener pl = this.getInstance();
+ return (pl != null) ? pl.getPhaseId() : PhaseId.ANY_PHASE;
+ }
+
+ }
+
+ private final TagAttribute binding;
+
+ private final String listenerType;
+
+ public PhaseListenerHandler(TagConfig config)
+ {
+ super(config);
+ TagAttribute type = this.getAttribute("type");
+ this.binding = this.getAttribute("binding");
+ if (type != null)
+ {
+ if (!type.isLiteral())
+ {
+ throw new TagAttributeException(type, "Must be a literal class name of type PhaseListener");
+ }
+ else
+ {
+ // test it out
+ try
+ {
+ ReflectionUtil.forName(type.getValue());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new TagAttributeException(type, "Couldn't qualify PhaseListener", e);
+ }
+ }
+ this.listenerType = type.getValue();
+ }
+ else
+ {
+ this.listenerType = null;
+ }
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ if (ComponentSupport.isNew(parent))
+ {
+ UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
+ if (root == null)
+ {
+ throw new TagException(this.tag, "UIViewRoot not available");
+ }
+ ValueExpression b = null;
+ if (this.binding != null)
+ {
+ b = this.binding.getValueExpression(ctx, PhaseListener.class);
+ }
+
+ PhaseListener pl = new LazyPhaseListener(this.listenerType, b);
+
+ root.addPhaseListener(pl);
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/SetPropertyActionListenerHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/SetPropertyActionListenerHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/SetPropertyActionListenerHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/SetPropertyActionListenerHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+
+public class SetPropertyActionListenerHandler extends TagHandler
+{
+ private final TagAttribute _target;
+ private final TagAttribute _value;
+
+ public SetPropertyActionListenerHandler(TagConfig config)
+ {
+ super(config);
+ this._value = this.getRequiredAttribute("value");
+ this._target = this.getRequiredAttribute("target");
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ if (parent instanceof ActionSource)
+ {
+ ActionSource src = (ActionSource) parent;
+ if (ComponentSupport.isNew(parent))
+ {
+ ValueExpression valueExpr = _value.getValueExpression(ctx, Object.class);
+ ValueExpression targetExpr = _target.getValueExpression(ctx, Object.class);
+
+ src.addActionListener(new SetPropertyListener(valueExpr, targetExpr));
+ }
+ }
+ else
+ {
+ throw new TagException(this.tag, "Parent is not of type ActionSource, type is: " + parent);
+ }
+ }
+
+ private static class SetPropertyListener implements ActionListener, Serializable
+ {
+ private ValueExpression _target;
+ private ValueExpression _value;
+
+ public SetPropertyListener()
+ {
+ };
+
+ public SetPropertyListener(ValueExpression value, ValueExpression target)
+ {
+ _value = value;
+ _target = target;
+ }
+
+ public void processAction(ActionEvent evt) throws AbortProcessingException
+ {
+ FacesContext faces = FacesContext.getCurrentInstance();
+
+ ELContext el = faces.getELContext();
+
+ Object valueObj = _value.getValue(el);
+
+ _target.setValue(el, valueObj);
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import javax.faces.validator.Validator;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.ValidatorConfig;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ValidateHandler;
+
+/**
+ * Register a named Validator instance on the UIComponent associated with the closest parent UIComponent custom
+ * action.<p/> See <a target="_new"
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/validator.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: ValidateDelegateHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class ValidateDelegateHandler extends ValidateHandler
+{
+
+ private final TagAttribute validatorId;
+
+ public ValidateDelegateHandler(ValidatorConfig config)
+ {
+ super(config);
+ this.validatorId = this.getRequiredAttribute("validatorId");
+ }
+
+ /**
+ * Uses the specified "validatorId" to get a new Validator instance from the Application.
+ *
+ * @see javax.faces.application.Application#createValidator(java.lang.String)
+ * @see org.apache.myfaces.view.facelets.tag.jsf.ValidateHandler#createValidator(javax.faces.view.facelets.FaceletContext)
+ */
+ protected Validator createValidator(FaceletContext ctx)
+ {
+ return ctx.getFacesContext().getApplication().createValidator(this.validatorId.getValue(ctx));
+ }
+
+ protected MetaRuleset createMetaRuleset(Class<?> type)
+ {
+ return super.createMetaRuleset(type).ignoreAll();
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValueChangeListenerHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValueChangeListenerHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValueChangeListenerHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValueChangeListenerHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+import org.apache.myfaces.view.facelets.util.ReflectionUtil;
+
+/**
+ * Register an ValueChangeListener instance on the UIComponent associated with the closest parent UIComponent custom
+ * action.<p/> See <a target="_new"
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/valueChangeListener.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: ValueChangeListenerHandler.java,v 1.2 2005/08/24 04:38:50 jhook Exp $
+ */
+public final class ValueChangeListenerHandler extends TagHandler
+{
+
+ private static class LazyValueChangeListener implements ValueChangeListener, Serializable
+ {
+
+ private static final long serialVersionUID = 7613811124326963180L;
+
+ private final String type;
+
+ private final ValueExpression binding;
+
+ public LazyValueChangeListener(String type, ValueExpression binding)
+ {
+ this.type = type;
+ this.binding = binding;
+ }
+
+ public void processValueChange(ValueChangeEvent event) throws AbortProcessingException
+ {
+ ValueChangeListener instance = null;
+ FacesContext faces = FacesContext.getCurrentInstance();
+ if (faces == null)
+ {
+ return;
+ }
+ if (this.binding != null)
+ {
+ instance = (ValueChangeListener) binding.getValue(faces.getELContext());
+ }
+ if (instance == null && this.type != null)
+ {
+ try
+ {
+ instance = (ValueChangeListener) ReflectionUtil.forName(this.type).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new AbortProcessingException("Couldn't Lazily instantiate ValueChangeListener", e);
+ }
+ if (this.binding != null)
+ {
+ binding.setValue(faces.getELContext(), instance);
+ }
+ }
+ if (instance != null)
+ {
+ instance.processValueChange(event);
+ }
+ }
+ }
+
+ private final TagAttribute binding;
+
+ private final String listenerType;
+
+ public ValueChangeListenerHandler(TagConfig config)
+ {
+ super(config);
+ this.binding = this.getAttribute("binding");
+ TagAttribute type = this.getAttribute("type");
+ if (type != null)
+ {
+ if (!type.isLiteral())
+ {
+ throw new TagAttributeException(type, "Must be a literal class name of type ValueChangeListener");
+ }
+ else
+ {
+ // test it out
+ try
+ {
+ ReflectionUtil.forName(type.getValue());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new TagAttributeException(type, "Couldn't qualify ValueChangeListener", e);
+ }
+ }
+ this.listenerType = type.getValue();
+ }
+ else
+ {
+ this.listenerType = null;
+ }
+ }
+
+ /**
+ * See taglib documentation.
+ *
+ * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ if (parent instanceof EditableValueHolder)
+ {
+ if (ComponentSupport.isNew(parent))
+ {
+ EditableValueHolder evh = (EditableValueHolder) parent;
+ ValueExpression b = null;
+ if (this.binding != null)
+ {
+ b = this.binding.getValueExpression(ctx, ValueChangeListener.class);
+ }
+ ValueChangeListener listener = new LazyValueChangeListener(this.listenerType, b);
+ evh.addValueChangeListener(listener);
+ }
+ }
+ else
+ {
+ throw new TagException(this.tag, "Parent is not of type EditableValueHolder, type is: " + parent);
+ }
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/VerbatimHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/VerbatimHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/VerbatimHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/VerbatimHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TextHandler;
+
+import org.apache.myfaces.view.facelets.tag.TagHandlerUtils;
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * Handler for f:verbatim
+ *
+ * @author Adam Winer
+ * @version $Id: VerbatimHandler.java,v 1.3 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class VerbatimHandler extends ComponentHandler
+{
+ public VerbatimHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+ protected void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
+ {
+ StringBuffer content = new StringBuffer();
+ for (TextHandler handler : TagHandlerUtils.findNextByType(nextHandler, TextHandler.class))
+ {
+ content.append(handler.getText(ctx));
+ }
+
+ c.getAttributes().put("value", content.toString());
+ c.getAttributes().put("escape", Boolean.FALSE);
+ c.setTransient(true);
+ }
+
+ protected void applyNextHandler(FaceletContext ctx, UIComponent c)
+ {
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.event.PhaseEvent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+
+/**
+ * Container for all JavaServer Faces core and custom component actions used on a page. <p/> See <a target="_new"
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/view.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: ViewHandler.java,v 1.5 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class ViewHandler extends TagHandler
+{
+
+ private final static Class<?>[] LISTENER_SIG = new Class<?>[] { PhaseEvent.class };
+
+ private final TagAttribute locale;
+
+ private final TagAttribute renderKitId;
+
+ private final TagAttribute contentType;
+
+ private final TagAttribute encoding;
+
+ private final TagAttribute beforePhaseListener;
+
+ private final TagAttribute afterPhaseListener;
+
+ /**
+ * @param config
+ */
+ public ViewHandler(TagConfig config)
+ {
+ super(config);
+ this.locale = this.getAttribute("locale");
+ this.renderKitId = this.getAttribute("renderKitId");
+ this.contentType = this.getAttribute("contentType");
+ this.encoding = this.getAttribute("encoding");
+ this.beforePhaseListener = this.getAttribute("beforePhaseListener");
+ this.afterPhaseListener = this.getAttribute("afterPhaseListener");
+ }
+
+ /**
+ * See taglib documentation.
+ *
+ * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
+ if (root != null)
+ {
+ if (this.locale != null)
+ {
+ root.setLocale(ComponentSupport.getLocale(ctx, this.locale));
+ }
+ if (this.renderKitId != null)
+ {
+ String v = this.renderKitId.getValue(ctx);
+ root.setRenderKitId(v);
+ }
+ if (this.contentType != null)
+ {
+ String v = this.contentType.getValue(ctx);
+ ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType", v);
+ }
+ if (this.encoding != null)
+ {
+ String v = this.encoding.getValue(ctx);
+ ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", v);
+ }
+ if (this.beforePhaseListener != null)
+ {
+ MethodExpression m = this.beforePhaseListener.getMethodExpression(ctx, null, LISTENER_SIG);
+ root.setBeforePhaseListener(m);
+ }
+ if (this.afterPhaseListener != null)
+ {
+ MethodExpression m = this.afterPhaseListener.getMethodExpression(ctx, null, LISTENER_SIG);
+ root.setAfterPhaseListener(m);
+ }
+ }
+ this.nextHandler.apply(ctx, parent);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/package.html?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/package.html Sat Apr 4 18:44:59 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:44 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Tag Library for <b><a target="_new" href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/tld-summary.html">http://java.sun.com/jsf/core</a></b>.
+See JSF 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/org/apache/myfaces/view/facelets/tag/jsf/html/AbstractHtmlLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/AbstractHtmlLibrary.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/AbstractHtmlLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/AbstractHtmlLibrary.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.html;
+
+import org.apache.myfaces.view.facelets.tag.AbstractTagLibrary;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: AbstractHtmlLibrary.java,v 1.3 2008/07/13 19:01:50 rlubke Exp $
+ */
+public abstract class AbstractHtmlLibrary extends AbstractTagLibrary
+{
+
+ /**
+ * @param namespace
+ */
+ public AbstractHtmlLibrary(String namespace)
+ {
+ super(namespace);
+ }
+
+ public void addHtmlComponent(String name, String componentType, String rendererType)
+ {
+ super.addComponent(name, componentType, rendererType, HtmlComponentHandler.class);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlComponentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlComponentHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlComponentHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlComponentHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.html;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.MetaRuleset;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: HtmlComponentHandler.java,v 1.3 2008/07/13 19:01:50 rlubke Exp $
+ */
+public class HtmlComponentHandler extends ComponentHandler
+{
+
+ /**
+ * @param config
+ */
+ public HtmlComponentHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class<?> type)
+ {
+ return super.createMetaRuleset(type).alias("class", "styleClass");
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlDecorator.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlDecorator.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlDecorator.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.html;
+
+import javax.faces.view.facelets.Tag;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributes;
+
+import org.apache.myfaces.view.facelets.tag.TagAttributesImpl;
+import org.apache.myfaces.view.facelets.tag.TagDecorator;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: HtmlDecorator.java,v 1.4 2008/07/13 19:01:50 rlubke Exp $
+ */
+public final class HtmlDecorator implements TagDecorator
+{
+
+ public final static String XhtmlNamespace = "http://www.w3.org/1999/xhtml";
+
+ public final static HtmlDecorator Instance = new HtmlDecorator();
+
+ /**
+ *
+ */
+ public HtmlDecorator()
+ {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.myfaces.view.facelets.tag.TagDecorator#decorate(org.apache.myfaces.view.facelets.tag.Tag)
+ */
+ public Tag decorate(Tag tag)
+ {
+ if (XhtmlNamespace.equals(tag.getNamespace()))
+ {
+ String n = tag.getLocalName();
+ if ("a".equals(n))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "commandLink", tag.getQName(), tag
+ .getAttributes());
+ }
+ if ("form".equals(n))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "form", tag.getQName(), tag.getAttributes());
+ }
+ if ("input".equals(n))
+ {
+ TagAttribute attr = tag.getAttributes().get("type");
+ if (attr != null)
+ {
+ String t = attr.getValue();
+ TagAttributes na = removeType(tag.getAttributes());
+ if ("text".equals(t))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "inputText", tag.getQName(), na);
+ }
+ if ("password".equals(t))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "inputSecret", tag.getQName(), na);
+ }
+ if ("hidden".equals(t))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "inputHidden", tag.getQName(), na);
+ }
+ if ("submit".equals(t))
+ {
+ return new Tag(tag.getLocation(), HtmlLibrary.Namespace, "commandButton", tag.getQName(), na);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private static TagAttributes removeType(TagAttributes attrs)
+ {
+ TagAttribute[] o = attrs.getAll();
+ TagAttribute[] a = new TagAttribute[o.length - 1];
+ int p = 0;
+ for (int i = 0; i < o.length; i++)
+ {
+ if (!"type".equals(o[i].getLocalName()))
+ {
+ a[p++] = o[i];
+ }
+ }
+ return new TagAttributesImpl(a);
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlLibrary.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlLibrary.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jsf.html;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: HtmlLibrary.java,v 1.3 2008/07/13 19:01:50 rlubke Exp $
+ */
+public final class HtmlLibrary extends AbstractHtmlLibrary
+{
+
+ public final static String Namespace = "http://java.sun.com/jsf/html";
+
+ public final static HtmlLibrary Instance = new HtmlLibrary();
+
+ public HtmlLibrary()
+ {
+ super(Namespace);
+
+ this.addHtmlComponent("column", "javax.faces.Column", null);
+
+ this.addHtmlComponent("commandButton", "javax.faces.HtmlCommandButton", "javax.faces.Button");
+
+ this.addHtmlComponent("commandLink", "javax.faces.HtmlCommandLink", "javax.faces.Link");
+
+ this.addHtmlComponent("dataTable", "javax.faces.HtmlDataTable", "javax.faces.Table");
+
+ this.addHtmlComponent("form", "javax.faces.HtmlForm", "javax.faces.Form");
+
+ this.addHtmlComponent("graphicImage", "javax.faces.HtmlGraphicImage", "javax.faces.Image");
+
+ this.addHtmlComponent("inputHidden", "javax.faces.HtmlInputHidden", "javax.faces.Hidden");
+
+ this.addHtmlComponent("inputSecret", "javax.faces.HtmlInputSecret", "javax.faces.Secret");
+
+ this.addHtmlComponent("inputText", "javax.faces.HtmlInputText", "javax.faces.Text");
+
+ this.addHtmlComponent("inputTextarea", "javax.faces.HtmlInputTextarea", "javax.faces.Textarea");
+
+ this.addHtmlComponent("message", "javax.faces.HtmlMessage", "javax.faces.Message");
+
+ this.addHtmlComponent("messages", "javax.faces.HtmlMessages", "javax.faces.Messages");
+
+ this.addHtmlComponent("outputFormat", "javax.faces.HtmlOutputFormat", "javax.faces.Format");
+
+ this.addHtmlComponent("outputLabel", "javax.faces.HtmlOutputLabel", "javax.faces.Label");
+
+ this.addHtmlComponent("outputLink", "javax.faces.HtmlOutputLink", "javax.faces.Link");
+
+ this.addHtmlComponent("outputText", "javax.faces.HtmlOutputText", "javax.faces.Text");
+
+ this.addHtmlComponent("panelGrid", "javax.faces.HtmlPanelGrid", "javax.faces.Grid");
+
+ this.addHtmlComponent("panelGroup", "javax.faces.HtmlPanelGroup", "javax.faces.Group");
+
+ this.addHtmlComponent("selectBooleanCheckbox", "javax.faces.HtmlSelectBooleanCheckbox", "javax.faces.Checkbox");
+
+ this.addHtmlComponent("selectManyCheckbox", "javax.faces.HtmlSelectManyCheckbox", "javax.faces.Checkbox");
+
+ this.addHtmlComponent("selectManyListbox", "javax.faces.HtmlSelectManyListbox", "javax.faces.Listbox");
+
+ this.addHtmlComponent("selectManyMenu", "javax.faces.HtmlSelectManyMenu", "javax.faces.Menu");
+
+ this.addHtmlComponent("selectOneListbox", "javax.faces.HtmlSelectOneListbox", "javax.faces.Listbox");
+
+ this.addHtmlComponent("selectOneMenu", "javax.faces.HtmlSelectOneMenu", "javax.faces.Menu");
+
+ this.addHtmlComponent("selectOneRadio", "javax.faces.HtmlSelectOneRadio", "javax.faces.Radio");
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/package.html?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/package.html Sat Apr 4 18:44:59 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:50 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Tag Library for <b><a target="_new" href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/h/tld-summary.html">http://java.sun.com/jsf/html</a></b>.
+See JSF HTML Tag Javadocs for attributes/functionality.
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/CatchHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/CatchHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/CatchHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/CatchHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: CatchHandler.java,v 1.5 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class CatchHandler extends TagHandler
+{
+
+ private final TagAttribute var;
+
+ /**
+ * @param config
+ */
+ public CatchHandler(TagConfig config)
+ {
+ super(config);
+ this.var = this.getAttribute("var");
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ try
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ catch (Exception e)
+ {
+ if (this.var != null)
+ {
+ ctx.setAttribute(this.var.getValue(ctx), e);
+ }
+ }
+ }
+
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.tag.TagHandlerUtils;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: ChooseHandler.java,v 1.3 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class ChooseHandler extends TagHandler
+{
+
+ private final ChooseOtherwiseHandler otherwise;
+ private final ChooseWhenHandler[] when;
+
+ public ChooseHandler(TagConfig config)
+ {
+ super(config);
+
+ List<ChooseWhenHandler> whenList = new ArrayList<ChooseWhenHandler>();
+ for (ChooseWhenHandler handler : TagHandlerUtils.findNextByType(nextHandler, ChooseWhenHandler.class))
+ {
+ whenList.add(handler);
+ }
+ if (whenList.isEmpty())
+ {
+ throw new TagException(this.tag, "Choose Tag must have one or more When Tags");
+ }
+
+ this.when = (ChooseWhenHandler[]) whenList.toArray(new ChooseWhenHandler[whenList.size()]);
+
+ Iterator<ChooseOtherwiseHandler> itrOtherwise =
+ TagHandlerUtils.findNextByType(nextHandler, ChooseOtherwiseHandler.class).iterator();
+ if (itrOtherwise.hasNext())
+ {
+ this.otherwise = itrOtherwise.next();
+ }
+ else
+ {
+ this.otherwise = null;
+ }
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ for (int i = 0; i < this.when.length; i++)
+ {
+ if (this.when[i].isTestTrue(ctx))
+ {
+ this.when[i].apply(ctx, parent);
+ return;
+ }
+ }
+ if (this.otherwise != null)
+ {
+ this.otherwise.apply(ctx, parent);
+ }
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseOtherwiseHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseOtherwiseHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseOtherwiseHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseOtherwiseHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * @author Jacob Hookom
+ * @version $Id: ChooseOtherwiseHandler.java,v 1.3 2008/07/13 19:01:44 rlubke Exp $
+ */
+public final class ChooseOtherwiseHandler extends TagHandler
+{
+
+ public ChooseOtherwiseHandler(TagConfig config)
+ {
+ super(config);
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+ ELException
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseWhenHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseWhenHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseWhenHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseWhenHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.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/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,336 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+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;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * @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<Object>
+ {
+
+ 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/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.facelets.tag.jstl.core;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.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/org/apache/myfaces/view/facelets/tag/jstl/core/IndexedValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IndexedValueExpression.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IndexedValueExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IndexedValueExpression.java Sat Apr 4 18:44:59 2009
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.myfaces.view.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;
+ }
+
+}