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.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2005-2007 The Apache Software Foundation
*
* Licensed 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 com.sun.faces.facelets.component;
import static com.sun.faces.cdi.CdiUtils.createDataModel;
import static com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter.BEHAVIOR_SOURCE_PARAM;
import java.io.IOException;
import java.io.Serializable;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.ContextCallback;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.component.UINamingContainer;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitHint;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import javax.faces.event.PhaseId;
import javax.faces.event.PostValidateEvent;
import javax.faces.event.PreValidateEvent;
import javax.faces.model.ArrayDataModel;
import javax.faces.model.DataModel;
import javax.faces.model.IterableDataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.ResultSetDataModel;
import javax.faces.model.ScalarDataModel;
import javax.faces.render.Renderer;
import com.sun.faces.facelets.tag.IterationStatus;
public class UIRepeat extends UINamingContainer {
public static final String COMPONENT_TYPE = "facelets.ui.Repeat";
public static final String COMPONENT_FAMILY = "facelets";
private final static DataModel EMPTY_MODEL =
new ListDataModel<>(Collections.emptyList());
// our data
private Object value;
private transient DataModel model;
// variables
private String var;
private String varStatus;
private int index = -1;
private Integer begin;
private Integer end;
private Integer step;
private Integer size;
public UIRepeat() {
this.setRendererType("facelets.ui.Repeat");
}
@Override
public String getFamily() {
return COMPONENT_FAMILY;
}
public void setEnd(Integer end) {
this.end = end;
}
public Integer getEnd() {
if (this.end != null) {
return end;
}
ValueExpression ve = this.getValueExpression("end");
if (ve != null) {
return (Integer) ve.getValue(getFacesContext().getELContext());
}
return null;
}
public void setSize(Integer size) {
this.size = size;
}
public Integer getSize() {
if (this.size != null) {
return size;
}
ValueExpression ve = this.getValueExpression("size");
if (ve != null) {
return (Integer) ve.getValue(getFacesContext().getELContext());
}
return null;
}
public void setOffset(Integer offset) {
this.begin = offset;
}
public Integer getOffset() {
if (this.begin != null) {
return this.begin;
}
ValueExpression ve = this.getValueExpression("offset");
if (ve != null) {
return (Integer) ve.getValue(getFacesContext().getELContext());
}
return null;
}
public void setBegin(Integer begin) {
this.begin = begin;
}
public Integer getBegin() {
if (this.begin != null) {
return this.begin;
}
ValueExpression ve = this.getValueExpression("begin");
if (ve != null) {
return (Integer) ve.getValue(getFacesContext().getELContext());
}
return null;
}
public void setStep(Integer step) {
this.step = step;
}
public Integer getStep() {
if (this.step != null) {
return this.step;
}
ValueExpression ve = this.getValueExpression("step");
if (ve != null) {
return (Integer) ve.getValue(getFacesContext().getELContext());
}
return null;
}
public String getVar() {
return this.var;
}
public void setVar(String var) {
this.var = var;
}
public String getVarStatus() {
return varStatus;
}
public void setVarStatus(String varStatus) {
this.varStatus = varStatus;
}
private void resetDataModel() {
if (this.isNestedInIterator()) {
this.setDataModel(null);
}
}
private void setDataModel(DataModel model) {
//noinspection unchecked
this.model = model;
}
private DataModel getDataModel() {
if (this.model == null) {
Object val = this.getValue();
if (val == null) {
Integer begin = getBegin();
Integer end = getEnd();
if (end == null) {
if (begin == null) {
this.model = EMPTY_MODEL;
} else {
throw new IllegalArgumentException("end");
}
} else {
int b = (begin == null) ? 0 : begin;
int e = end;
int d = (b < e) ? 1 : (b > e) ? -1 : 0;
int s = Math.abs(e - b) + 1;
Integer[] array = new Integer[s];
for (int i = 0; i < s; i++) {
array[i] = b + (i * d);
}
this.model = new ArrayDataModel<>(array);
setBegin(0);
setEnd(s);
}
} else if (val instanceof DataModel) {
//noinspection unchecked
this.model = (DataModel