org.apache.myfaces.tobago.compat.FacesInvokeOnComponent12 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tobago-jsf-compat Show documentation
Show all versions of tobago-jsf-compat Show documentation
Tobago JSF 1.1-1.2 Compatibility Bridge
(makes Tobago independent from differences between JSF 1.1 and JSF 1.2).
package org.apache.myfaces.tobago.compat;
/*
* 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.
*/
import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
public class FacesInvokeOnComponent12 {
public static boolean invokeOnComponent(
FacesContext context, UIComponent component, String clientId, ContextCallback callback) {
String thisClientId = component.getClientId(context);
if (clientId.equals(thisClientId)) {
callback.invokeContextCallback(context, component);
return true;
} else if (component instanceof NamingContainer) {
// This component is a naming container. If the client id shows it's inside this naming container,
// then process further.
// Otherwise we know the client id we're looking for is not in this naming container,
// so for improved performance short circuit and return false.
if (clientId.startsWith(thisClientId)
&& (clientId.charAt(thisClientId.length()) == NamingContainer.SEPARATOR_CHAR)) {
if (invokeOnComponentFacetsAndChildren(context, component, clientId, callback)) {
return true;
}
}
} else {
if (invokeOnComponentFacetsAndChildren(context, component, clientId, callback)) {
return true;
}
}
return false;
}
private static boolean invokeOnComponentFacetsAndChildren(
FacesContext context, UIComponent component, String clientId, ContextCallback callback) {
for (java.util.Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
UIComponent child = it.next();
if (child.invokeOnComponent(context, clientId, callback)) {
return true;
}
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy