Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.layout.descriptors;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.sun.jsftemplating.layout.LayoutDefinitionManager;
import com.sun.jsftemplating.layout.descriptors.handler.Handler;
import com.sun.jsftemplating.layout.event.AfterLoopEvent;
import com.sun.jsftemplating.layout.event.BeforeLoopEvent;
/**
*
This class defines a LayoutForEach {@link LayoutElement}. The
* LayoutForEach provides the functionality necessary to iteratively
* display a portion of the layout tree. The list property contains
* the List of items to iterate over.
*
* @author Ken Paulsen ([email protected])
*/
public class LayoutForEach extends LayoutComponent {
private static final long serialVersionUID = 1L;
/**
*
Constructor.
*
* @param parent The parent {@link LayoutElement}
* @param listBinding The List to iterate over
* @param key The ServletRequest attribute key
* used to store the object being processed
*/
public LayoutForEach(LayoutElement parent, String listBinding, String key) {
super(parent, null,
LayoutDefinitionManager.getGlobalComponentType(null, "foreach"));
if ((listBinding == null) || listBinding.equals("")) {
throw new IllegalArgumentException("'listBinding' is required!");
}
if ((key == null) || key.equals("")) {
throw new IllegalArgumentException("'key' is required!");
}
addOption("list", listBinding);
addOption("key", key);
if (listBinding.equals("$property{list}")) {
_doubleEval = true;
}
}
/**
*
This method always returns true. The condition is based on an
* Iterator.hasNext() call instead of here because
* the {@link #encode(FacesContext, UIComponent)} method
* evaluates this and then calls the super. Performing the check
* here would cause the condition to be evaluated twice.
*
* @param context The FacesContext.
* @param component The UIComponent.
*
* @return true
*/
public boolean encodeThis(FacesContext context, UIComponent component) {
return true;
}
/**
*
This method evaluates the list binding for this
* LayoutForEach. This is expected to evaulate to a
* List object. If it doesn't, this method will throw a
* NullPointerException (if it evaulates to
* null), or an IllegalArgumentException if
* it doesn't evaluate to a List.
*
* @param context The FacesContext
*
* return The List of objects to iterate over
*/
protected List