gpt4 book ai didi

com.github.bordertech.wcomponents.WebUtilities.getParentNamingContext()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 16:01:05 25 4
gpt4 key购买 nike

本文整理了Java中com.github.bordertech.wcomponents.WebUtilities.getParentNamingContext()方法的一些代码示例,展示了WebUtilities.getParentNamingContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebUtilities.getParentNamingContext()方法的具体详情如下:
包路径:com.github.bordertech.wcomponents.WebUtilities
类名称:WebUtilities
方法名:getParentNamingContext

WebUtilities.getParentNamingContext介绍

[英]Get this component's parent naming context.
[中]获取此组件的父命名上下文。

代码示例

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Derive the full id from its naming context.
 *
 * @param idName the component id name
 * @return the derived id in its context
 */
private String deriveId(final String idName) {
  // Find parent naming context
  NamingContextable parent = WebUtilities.getParentNamingContext(this);
  // No Parent
  if (parent == null) {
    return idName;
  }
  // Get ID prefix
  String prefix = parent.getNamingContextId();
  // No Prefix, just use id name
  if (prefix.length() == 0) {
    return idName;
  }
  // Add Prefix
  StringBuffer nameBuf = new StringBuffer(prefix.length() + idName.length() + 1);
  nameBuf.append(prefix);
  nameBuf.append(ID_CONTEXT_SEPERATOR);
  nameBuf.append(idName);
  return nameBuf.toString();
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * {@inheritDoc}
 */
@Override
public String getNamingContextId() {
  boolean append = isAppendID();
  if (!append) {
    // Check if this is the top level name context
    NamingContextable top = WebUtilities.getParentNamingContext(this);
    if (top != null) {
      // Not top context, so always append
      append = true;
    }
  }
  if (append) {
    return getId();
  } else {
    return "";
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Register this component's ID in its naming context.
 */
void registerInContext() {
  if (!ConfigurationProperties.getCheckDuplicateIds()) {
    return;
  }
  // Register Component if it has an ID name set
  if (getIdName() != null) {
    // Find parent context
    NamingContextable context = WebUtilities.getParentNamingContext(this);
    if (context == null) {
      // If this is the top context, then register itself
      if (WebUtilities.isActiveNamingContext(this)) {
        this.registerId(this);
      } else {
        LOG.warn("Component with id name [" + getIdName()
            + "] is not in a naming context and cannot be verified for duplicate id.");
      }
      return;
    }
    // Assume context is AbstractWComponent
    ((AbstractWComponent) context).registerId(this);
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testGetParentNamingContext() {
  // Create naming contexts
  WNamingContext context1 = new WNamingContext("A");
  WNamingContext context2 = new WNamingContext("B");
  WNamingContext context3 = new WNamingContext("C");
  // Children
  WContainer child1 = new WContainer();
  WContainer child2 = new WContainer();
  WContainer child3 = new WContainer();
  // Make context2 inactive
  context2.setNamingContext(false);
  // Make tree of components
  context1.add(child1);
  child1.add(context2);
  context2.add(child2);
  child2.add(context3);
  context3.add(child3);
  // Test tree
  Assert.assertNull("Naming context for context1 should be null", WebUtilities.
      getParentNamingContext(context1));
  Assert.assertEquals("Naming context for child1 should be context1", context1,
      WebUtilities.getParentNamingContext(child1));
  Assert.assertEquals("Naming context for child2 should be context1", context1,
      WebUtilities.getParentNamingContext(child2));
  Assert.assertEquals("Naming context for child3 should be context3", context3,
      WebUtilities.getParentNamingContext(child3));
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com