本文整理了Java中com.vaadin.flow.dom.Element.getChild()
方法的一些代码示例,展示了Element.getChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getChild()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:getChild
[英]Returns the child element at the given position.
If property "innerHTML" has been set explicitly then its value (the new element structure) won't be populated on the server side and this method will not work.
[中]返回给定位置的子元素。
如果已显式设置属性“innerHTML”,则其值(新元素结构)将不会在服务器端填充,并且此方法将不起作用。
代码示例来源:origin: com.vaadin/flow-server
private void setTextContent(String textContent) {
Element child;
if (getChildCount() == 1 && getChild(0).isTextNode()) {
child = getChild(0).setText(textContent);
} else {
child = createText(textContent);
}
removeAllChildren();
appendChild(child);
}
代码示例来源:origin: com.vaadin/vaadin-accordion-flow
private static Optional<AccordionPanel> getOpenedPanel(Accordion accordion, Integer index) {
return index == null || index >= accordion.getChildren().count() ? Optional.empty() :
accordion.getElement().getChild(index).getComponent().map(AccordionPanel.class::cast);
}
代码示例来源:origin: com.vaadin/flow-data
/**
* Gets the index of the child element that represents the given item.
*
* @param item
* the item to look for
* @return the index of the child element that represents the item, or -1 if
* the item is not found
*/
default int getItemPosition(T item) {
if (item == null) {
return -1;
}
return IntStream.range(0, getElement().getChildCount()).filter(i -> {
Optional<Component> c = getElement().getChild(i).getComponent();
return c.isPresent() && c.get() instanceof ItemComponent
&& item.equals(((ItemComponent<?>) c.get()).getItem());
}).findFirst().orElse(-1);
}
}
内容来源于网络,如有侵权,请联系作者删除!