org.icefaces.ace.component.stackpane.StackPane Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icefaces-ace Show documentation
Show all versions of icefaces-ace Show documentation
The advanced component library for ICEfaces.
/*
* Copyright 2004-2014 ICEsoft Technologies Canada Corp.
*
* 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 org.icefaces.ace.component.stackpane;
import org.icefaces.ace.component.panelstack.PanelStack;
import javax.faces.component.UIComponent;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitHint;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.PhaseId;
import java.util.*;
import java.util.logging.Logger;
public class StackPane extends StackPaneBase {
private static final Logger logger = Logger.getLogger(StackPane.class.toString());
public static final String CONTENT_SELECTED = "ace-stackpane ";
public static final String CONTENT_HIDDEN = "ace-stackpane-hidden ";
private static final List NO_CHILDREN = new LinkedList();
private Runnable createChildren;
/* public void processDecodes(FacesContext context) {
if (isSelected()) {
createChildren();
super.processDecodes(context);
}
}
public void processValidators(FacesContext context) {
if (isSelected()) {
super.processValidators(context);
}
}
public void processUpdates(FacesContext context) {
if (isSelected()) {
super.processUpdates(context);
}
}
public void processRestoreState(FacesContext context, Object state) {
if (isSelected()) {
super.processRestoreState(context, state);
}
}
public Object processSaveState(FacesContext context) {
if (isSelected()) {
return super.processSaveState(context);
} else {
return null;
}
}
public boolean visitTree(VisitContext context, VisitCallback callback) {
PhaseId currentPhaseId = context.getFacesContext().getCurrentPhaseId();
//visit the tree to restore and respectively save the state of the children between JSF lifecycles
if (context.getHints().contains(VisitHint.SKIP_ITERATION)) {
return false;
}
if (currentPhaseId == PhaseId.RESTORE_VIEW || currentPhaseId == PhaseId.RENDER_RESPONSE) {
return super.visitTree(context, callback);
} else {
if (isSelected()) {
createChildren();
return super.visitTree(context, callback);
}
}
return false;
}
public boolean isSelected() {
UIComponent parent = this.getParent();
while (!(parent instanceof PanelStack) && parent != null) {
parent = parent.getParent();
}
if (parent != null) {
PanelStack panelStack = (PanelStack) parent;
String selectedId = panelStack.getSelectedId();
return getId().equals(selectedId);
} else {
logger.warning("StackPane must be nested within a PanelStack: " + this.getClientId());
return false;
}
}
public void delayChildrenCreation(Runnable createChildren) {
this.createChildren = createChildren;
}
public void createChildren() {
if (!isClient() && isFacelet()) {
List children = getChildren();
if (isSelected()) {
if (children == null || children.isEmpty()) {
FacesContext facesContext = getFacesContext();
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy