org.ajax4jsf.tag.AjaxReRendrRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ajax4jsf Show documentation
Show all versions of ajax4jsf Show documentation
Ajax4jsf is an open source extension to the JavaServer Faces standard that adds AJAX capability to JSF applications without requiring the writing of any JavaScript.
The newest version!
/**
* Licensed under the Common Development and Distribution License,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.sun.com/cddl/
*
* 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.ajax4jsf.tag;
import java.util.Set;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.tag.MetaRule;
import com.sun.facelets.tag.Metadata;
import com.sun.facelets.tag.MetadataTarget;
import com.sun.facelets.tag.TagAttribute;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.3 $ $Date: 2006/07/19 13:59:22 $
*
*/
public class AjaxReRendrRule extends MetaRule {
public static final AjaxReRendrRule instance = new AjaxReRendrRule();
/**
*
*/
public AjaxReRendrRule() {
super();
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String, com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
*/
public Metadata applyRule(String name, TagAttribute attribute,
MetadataTarget meta) {
if (meta.isTargetInstanceOf(AjaxComponent.class)) {
if ("reRender".equals(name)) {
if (attribute.isLiteral()) {
return new ReRendersSetMataData(attribute.getValue());
} else {
// Process as usual expression
return null;
}
}
}
return null;
}
static class ReRendersSetMataData extends Metadata{
private Set _reRender;
/**
* @param value
*/
public ReRendersSetMataData(String value) {
_reRender = AjaxRendererUtils.asSet(value);
}
/* (non-Javadoc)
* @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
*/
public void applyMetadata(FaceletContext ctx, Object instance) {
((AjaxComponent) instance).setReRender(_reRender);
}
}
}