
org.apache.myfaces.commons.facelets.util.FaceletsFunctionLibrary Maven / Gradle / Ivy
The newest version!
/*
* 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.commons.facelets.util;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletFunction;
public final class FaceletsFunctionLibrary
{
public FaceletsFunctionLibrary()
{
super();
}
/**
* Return a UIComponent instance based on the passed findComponent
* expression. The viewRoot instance is used as component reference
*
* @param expr
* @return
*/
@JSFFaceletFunction(name="mc:findComponent")
public static UIComponent findComponent(String expr)
{
return FacesContext.getCurrentInstance().
getViewRoot().findComponent(expr);
}
/**
* Return the client id of the component returned by the findComponent
* expression.
*
* @param expr
* @return
*/
@JSFFaceletFunction(name="mc:outputClientId")
public static String outputClientId(String expr)
{
FacesContext ctx = FacesContext.getCurrentInstance();
return ctx.getViewRoot().findComponent(expr).getClientId(ctx);
}
/**
* Invoke findComponent() taking as reference the passed component
* and as param the expression defined.
*
* @param c
* @param expr
* @return
*/
@JSFFaceletFunction(name="mc:findComponentFrom")
public static UIComponent findComponentFrom(UIComponent c, String expr)
{
if (c != null)
{
return c.findComponent(expr);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy