Java 怎么查找JSF父窗体

2019年8月13日22:10:41 评论 30

1.简介

Java 怎么查找JSF父窗体?——请看下文。

2.代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UISelectItem;
import javax.faces.component.UISelectItems;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;

public class Main{
    private static String TRINIDAD_FORM_FAMILY = "org.apache.myfaces.trinidad.Form";
    public static UIComponent findParentForm(FacesContext context,
            UIComponent component) {
        UIComponent parent = component.getParent();

        while (parent != null) {
            if (parent instanceof UIForm)
                return parent;

            if (parent.getFamily().equals(TRINIDAD_FORM_FAMILY))
                return parent;

            parent = parent.getParent();
        }

        return null;
    }
}

 

3.总结

示例代码演示了 Java 如何查找JSF父窗体,具体步骤参见示例代码。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: