當前位置: 首頁>>代碼示例>>Java>>正文


Java Application.createComponent方法代碼示例

本文整理匯總了Java中javax.faces.application.Application.createComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.createComponent方法的具體用法?Java Application.createComponent怎麽用?Java Application.createComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.application.Application的用法示例。


在下文中一共展示了Application.createComponent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadCompositeComponent

import javax.faces.application.Application; //導入方法依賴的package包/類
public static void loadCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id) {
    // Prepare.
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);

    // This basically creates <ui:component> based on <composite:interface>.
    Resource resource = application.getResourceHandler().createResource(resourceName, libraryName);
    UIComponent composite = application.createComponent(context, resource);
    composite.setId(id); // Mandatory for the case composite is part of UIForm! Otherwise JSF can't find inputs.

    // This basically creates <composite:implementation>.
    UIComponent implementation = application.createComponent(UIPanel.COMPONENT_TYPE);
    implementation.setRendererType("javax.faces.Group");
    composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, implementation);

    // Now include the composite component tmpFileUploadPart in the given parent.
    parent.getChildren().clear();
    parent.getChildren().add(composite);
    parent.pushComponentToEL(context, composite); // This makes #{cc} available.
    try {
        faceletContext.includeFacelet(implementation, resource.getURL());
    } catch (IOException e) {
        throw new FacesException(e);
    } finally {
        parent.popComponentFromEL(context);
    }
}
 
開發者ID:Blue4x4Rebel,項目名稱:kirke,代碼行數:29,代碼來源:SourceWizardBean.java

示例2: includeCompositeComponent

import javax.faces.application.Application; //導入方法依賴的package包/類
public static void includeCompositeComponent(final UIComponent parent,
        final String libraryName, final String resourceName,
        final String id,
        final Map<String, ValueExpression> mapValueExpression) {

    // Prepare.
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    FaceletContext faceletContext = (FaceletContext) context
            .getAttributes().get("javax.faces.FACELET_CONTEXT");

    // This basically creates <ui:component> based on <composite:interface>.
    Resource resource = application.getResourceHandler().createResource(
            resourceName, libraryName);
    UIComponent composite = application.createComponent(context, resource);
    // Mandatory for the case composite is part of
    // UIForm! Otherwise JSF can't find inputs.
    composite.setId(id);

    // This for set the attribute and the action
    for (Map.Entry<String, ValueExpression> entry : mapValueExpression
            .entrySet()) {
        composite.setValueExpression(entry.getKey(), entry.getValue());
    }

    // This basically creates <composite:implementation>.
    UIComponent implementation = application
            .createComponent(UIPanel.COMPONENT_TYPE);
    implementation.setRendererType("javax.faces.Group");
    composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME,
            implementation);

    // Now include the composite component file in the given parent.
    parent.getChildren().add(composite);
    // This makes #{cc} available.
    parent.pushComponentToEL(context, composite);

    try {
        faceletContext.includeFacelet(implementation, resource.getURL());
    } catch (IOException e) {
        throw new FacesException(e);
    } finally {
        parent.popComponentFromEL(context);
    }
}
 
開發者ID:disit,項目名稱:iclos,代碼行數:46,代碼來源:CCUtility.java


注:本文中的javax.faces.application.Application.createComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。