/* * The contents of this file are subject to the terms * of the Common Development and Distribution License * (the License). You may not use this file except in * compliance with the License. * * You can obtain a copy of the license at * https://jsftemplating.dev.java.net/cddl1.html or * jsftemplating/cddl1.txt. * See the License for the specific language governing * permissions and limitations under the License. * * When distributing Covered Code, include this CDDL * Header Notice in each file and include the License file * at jsftemplating/cddl1.txt. * If applicable, add the following below the CDDL Header, * with the fields enclosed by brackets [] replaced by * you own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. */ package com.sun.jsftemplating.component.factory.sun; import com.sun.jsftemplating.annotation.UIComponentFactory; import com.sun.jsftemplating.component.factory.ComponentFactoryBase; import com.sun.jsftemplating.layout.descriptors.LayoutComponent; import com.sun.jsftemplating.util.LogUtil; import com.sun.jsftemplating.util.Util; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; /** *
This factory is responsible for instantiating a TableRowGroup
* UIComponent.
The {@link com.sun.jsftemplating.layout.descriptors.ComponentType} * id for this factory is: "sun:tableRowGroup".
* * @author Ken Paulsen (ken.paulsen@sun.com) */ @UIComponentFactory("sun:tableRowGroup") public class TableRowGroupFactory extends ComponentFactoryBase { /** * This is the factory method responsible for creating the
* UIComponent.
FacesContext
* @param descriptor The {@link LayoutComponent} descriptor associated
* with the requested UIComponent.
* @param parent The parent UIComponent
*
* @return The newly created TableRowGroup.
*/
public UIComponent create(FacesContext context, LayoutComponent descriptor, UIComponent parent) {
// Create the UIComponent
UIComponent comp = context.getApplication().createComponent(COMPONENT_TYPE);
// This needs to be done here (before setOptions) so that $...{...}
// expressions can be resolved... may want to defer these?
if (parent != null) {
addChild(context, descriptor, parent, comp);
}
// Set all the attributes / properties
setOptions(context, descriptor, comp);
// Handle "data" option specially...
Object data = descriptor.getEvaluatedOption(context, "data", comp);
if (data != null) {
// Create a DataProvider
if (!(data instanceof List)) {
throw new IllegalArgumentException("TableRowGroupFactory "
+ "only supports values of type \"java.util.List\" "
+ "for the 'data' attribute.");
}
if ((((List) data).size() > 0) &&
!(((List) data).get(0) instanceof List)) {
Object obj = ((List) data).get(0);
if (obj == null) {
if (LogUtil.configEnabled()) {
LogUtil.config("WEBUI0008");
}
} else {
obj = obj.getClass().getName();
// We don't have a List of List of Object!
throw new IllegalArgumentException("TableRowGroupFactory "
+ "expects a ListThis is a factory method for creating an appropriate * DataProvider.
*/ private Object createDataProvider(List The UIComponent type that must be registered in the
* faces-config.xml file mapping to the UIComponent class
* to use for this UIComponent.