jakarta.faces.component.UINamingContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of myfaces-api Show documentation
Show all versions of myfaces-api Show documentation
The public API classes of the Apache MyFaces CORE JSF-2.1 project
/*
* 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 jakarta.faces.component;
import java.util.Collection;
import java.util.Map;
import jakarta.faces.component.visit.VisitCallback;
import jakarta.faces.component.visit.VisitContext;
import jakarta.faces.component.visit.VisitResult;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspProperty;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
/**
* Base class for components that provide a new "namespace" for the ids of their
* child components.
*
* See the javadocs for interface NamingContainer for further details.
*
*/
@JSFComponent(name="f:subview")
@JSFJspProperty(name="id", required=true)
public class UINamingContainer extends UIComponentBase implements NamingContainer, UniqueIdVendor
{
public static final String COMPONENT_TYPE = "jakarta.faces.NamingContainer";
public static final String COMPONENT_FAMILY = "jakarta.faces.NamingContainer";
public static final String SEPARATOR_CHAR_PARAM_NAME = "jakarta.faces.SEPARATOR_CHAR";
/**
* Construct an instance of the UINamingContainer.
*/
public UINamingContainer()
{
setRendererType(null);
}
@Override
public String getFamily()
{
return COMPONENT_FAMILY;
}
/**
*
* {@inheritDoc}
*
* @since 2.0
*/
@Override
public String createUniqueId(FacesContext context, String seed)
{
StringBuilder bld = _getSharedStringBuilder(context);
// Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX,
// and will be unique within this UIViewRoot.
if(seed == null)
{
Integer uniqueIdCounter = (Integer) getStateHelper().get(PropertyKeys.uniqueIdCounter);
uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1));
return bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString();
}
// Optionally, a unique seed value can be supplied by component creators
// which should be included in the generated unique id.
else
{
return bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(seed).toString();
}
}
/**
*
* @param context
* @return
*
* @since 2.0
*/
@SuppressWarnings("deprecation")
public static char getSeparatorChar(FacesContext context)
{
Map