本文整理匯總了Java中javax.faces.component.UIComponent.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java UIComponent.getParent方法的具體用法?Java UIComponent.getParent怎麽用?Java UIComponent.getParent使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIComponent的用法示例。
在下文中一共展示了UIComponent.getParent方法的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: _getContainingForm
點讚 3
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
private UIComponent _getContainingForm(UIComponent component)
{
UIComponent previous = component;
UIComponent parent = component.getParent();
while (parent != null)
{
if ((parent instanceof UIForm)
|| (parent instanceof UIXForm)
|| (parent instanceof UIXSubform))
return parent;
previous = parent;
parent = parent.getParent();
}
return previous;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:18,
示例2: doTestUpdateModelValues
點讚 3
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected void doTestUpdateModelValues(
FacesContext context,
UIViewRoot root,
UIComponent component)
{
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
// JavaServer Faces 1.0 Specification, section 2.2.4
// During the update-model-values phase,
// only the processUpdates lifecycle method may be called.
if (willChildrenBeProcessed(component))
mock.expects(once()).method("processUpdates");
// construct the UIComponent tree and
// execute the apply-request-values lifecycle phase
if (component.getParent() == null)
root.getChildren().add(component);
component.getChildren().add(child);
root.processUpdates(context);
mock.verify();
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,
示例3: getFormId
點讚 3
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Retrieves id of the form the component is contained in.
*
* @param context the faces context object
* @param component UIComponent whose container form id is to be retuirned
*
* @return String id of the form if one exists in component's hierarchy,
* otherwise null
*/
public static String getFormId(
FacesContext context,
UIComponent component)
{
UIComponent form = null;
while (component != null)
{
if ((component instanceof UIForm) ||
(component instanceof UIXForm))
{
form = component;
break;
}
component = component.getParent();
}
if (form == null)
return null;
return form.getClientId(context);
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:32,
示例4: _addPartialTargetImpl
點讚 3
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* @see #addPartialTarget(FacesContext, PartialPageContext, UIComponent)
* @see #setPartialTarget(FacesContext, PartialPageContext)
*/
private static void _addPartialTargetImpl(
FacesContext facesContext, PartialPageContext partialContext, UIComponent component)
{
if (component.getRendererType() == null)
{
if (component.getParent() != null)
{
// delegate to the parent component, assuming that no renderer type means that
// there is no suitable replacable DOM element for this component
addPartialTarget(facesContext, partialContext, component.getParent());
}
}
else
{
partialContext.addPartialTarget(component.getClientId(facesContext));
}
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,
示例5: add
點讚 3
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void add(int index, UIComponent element)
{
if (element == null)
throw new NullPointerException();
if ((index < 0) || (index > size()))
throw new IndexOutOfBoundsException(_LOG.getMessage(
"INDEX_SIZE", new Object[]{index, size()}));
UIComponent oldParent = element.getParent();
if (oldParent != null)
{
int adjustedIndex = __removeFromParent(element, index);
// Only adjust the index when the child is re-added to the same parent
if (oldParent == _parent)
{
index = adjustedIndex;
}
}
// do not change the order of these calls, see TRINIDAD-1674 for more info
super.add(index, element);
element.setParent(_parent);
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,
示例6: removeComponent
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
public static void removeComponent(String componentId) {
UIViewRoot root = getCurrentInstance().getViewRoot();
UIComponent component = root.findComponent(componentId);
if (component != null) {
UIComponent parent = component.getParent();
parent.getChildren().remove(component);
}
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:10,
示例7: addComponentChange
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void addComponentChange(
FacesContext facesContext,
UIComponent uiComponent,
ComponentChange change)
{
// if our component is a stamped component by UIXIterator, we
// don't want to persist the changes
UIComponent parent = uiComponent.getParent();
UIComponent root = facesContext.getViewRoot();
while (parent != null && parent != root)
{
if (parent.getClass() == UIXIterator.class)
{
_LOG.info("DONT_PERSIST_STAMPED_COMPONENT_INSIDE_ITERATOR");
return;
}
parent = parent.getParent();
}
if (facesContext == null || uiComponent == null || change == null)
throw new IllegalArgumentException(_LOG.getMessage(
"CANNOT_ADD_CHANGE_WITH_FACECONTEXT_OR_UICOMPONENT_OR_NULL"));
// add the change to the component
addComponentChangeImpl(facesContext, uiComponent, change);
// add a corresponding DocumentChange if possible
_addEquivalentDocumentChange(facesContext, uiComponent, change);
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:34,
示例8: encodeAll
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
protected final void encodeAll(
FacesContext context,
RenderingContext rc,
UIComponent component,
FacesBean bean
) throws IOException
{
UIComponent parent = component.getParent();
//
// complain if our parent isn't a FrameBorderLayout
//
if ((parent == null) ||
!HtmlFrameBorderLayout.COMPONENT_FAMILY.equals(parent.getFamily()))
{
_LOG.warning("FRAMES_MUST_INSIDE_FRAMEBORDERLAYOUTS");
}
else
{
ResponseWriter writer = context.getResponseWriter();
writer.startElement("frame", component);
renderId(context, component);
renderAllAttributes(context, rc, component, bean);
writer.endElement("frame");
}
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:29,
示例9: getLogicalParent
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Provides a logical parent for the component (a parent in the context of the document where the component was
* defined). The default implementation will simply call getParent() on the component. Components that get relocated during
* tag execution should have their original parent returned (if available).
* @param component - child component whose parent is being retrieved
* @return logical parent component
*/
public static UIComponent getLogicalParent(UIComponent component)
{
if (component instanceof UIXComponent)
{
return ((UIXComponent)component).getLogicalParent();
}
return component.getParent();
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:17,
示例10: _isParentPanelForm
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
private boolean _isParentPanelForm(
FacesContext context,
UIComponent component)
{
if (PanelFormLayoutRenderer.__isInPanelFormLayout(context, component))
{
return true;
}
// We must know if the immediate parent is a PanelForm because if there is
// even just one other component inbetween this component and a PanelForm,
// we must render different DOM--the same DOM as if there were no parent
// PanelForm.
UIComponent parentComponent = component.getParent();
String family = parentComponent.getFamily();
// FIXME: OK... This is another strong coupling
// We could add a an interface instead like ComponentHolder or something
// instead of checking against a specific component family.
while (UIXGroup.COMPONENT_FAMILY.equals(family))
{
// Special case:
// Since UIXGroup components are purely organizational, it is valid to
// have them inbetween panelForm-friendly components and the panelForm,
// so we need to look further up the chain:
parentComponent = parentComponent.getParent();
if (parentComponent == null)
{
return false;
}
family = parentComponent.getFamily();
}
if (UIXPanel.COMPONENT_FAMILY.equals(family))
{
String rendererType = parentComponent.getRendererType();
if (_isFormRendererType(rendererType))
return true;
}
return false;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:40,
示例11: _getAncestor
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Returns the nth ancestor of the passed in component.
* @param component The UIComponent whose nth ancestor has to be found
* @param level Indicates how many levels to go up from the component
* @return The nth ancestor of the component
*/
private static UIComponent _getAncestor(UIComponent component, int level)
{
assert(level >= 0);
while(level > 0)
{
component = component.getParent();
level--;
}
return component;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:18,
示例12: encodeAll
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void encodeAll(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent parent = this;
while (!(parent instanceof Map)) {
parent = parent.getParent();
}
Map mapComponent = (Map) parent;
String mapVar = mapComponent.getJsVariable();
writer.write(mapVar + ".addControl(new ol.control.ZoomSlider());\n");
}
開發者ID:elielwaltrick,項目名稱:ol3jsf,代碼行數:15,
示例13: encodeAll
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void encodeAll(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent parent = this;
while (!(parent instanceof Map)) {
parent = parent.getParent();
}
Map mapComponent = (Map) parent;
String mapVar = mapComponent.getJsVariable();
writer.write(mapVar + ".addControl(new ol.control.OverviewMap());\n");
}
開發者ID:elielwaltrick,項目名稱:ol3jsf,代碼行數:15,
示例14: _renderAsTable
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
private boolean _renderAsTable(
UIXRenderingContext context,
UINode node
)
{
UIComponent component = NodeUtils.getUIComponent(context, node);
if (component.getParent() instanceof CorePanelButtonBar)
return false;
return true;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:12,
示例15: _getParentNamingContainerOrViewRoot
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
private static UIComponent _getParentNamingContainerOrViewRoot (
UIComponent from)
{
while (from.getParent() != null)
{
from = from.getParent();
if (from instanceof NamingContainer)
break;
}
return from;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:12,
示例16: _getValidatedDestinationContainer
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Returns the destination container if passed non-null after doing needed validations. If null
* destinationContainer is passed, determines it from the supplied insertBeforeComponent.
*/
private static UIComponent _getValidatedDestinationContainer(
UIComponent destinationContainer,
UIComponent insertBeforeComponent)
{
if (insertBeforeComponent != null)
{
UIComponent parent = insertBeforeComponent.getParent();
if (destinationContainer == null)
{
destinationContainer = parent;
}
// if container was supplied, it better be parent of component to move next to
else if (destinationContainer != parent)
{
throw new IllegalArgumentException(
_LOG.getMessage("DESTINATION_CONTAINER_NOT_INSERTBEFORES_PARENT"));
}
}
else if (destinationContainer == null)
{
throw new IllegalArgumentException(_LOG.getMessage("DESTINATION_CONTAINER_REQUIRED"));
}
return destinationContainer;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:32,
示例17: __removeFromParent
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
static int __removeFromParent(
UIComponent component,
int index)
{
UIComponent parent = component.getParent();
assert(parent != null);
if (parent.getChildCount() > 0)
{
List children = parent.getChildren();
int size = children.size();
for (int i = 0; i < size; i++)
{
if (children.get(i) == component)
{
children.remove(i);
if (index > i)
index--;
return index;
}
}
}
// TRINIDAD-2369: Until TRINIDAD-2368 is fixed, we have to call remove() on the map
// returned by getFacets() rather than calling remove() on getFacets().values()
// Note that the old code used to call getFacets().values().contains(), which would iterate on the entry set.
// The new code performs the same iteration, so it should not be any slower.
Map facets = parent.getFacets();
for (Map.Entry entry: facets.entrySet())
{
if (entry.getValue() == component)
{
facets.remove(entry.getKey());
return index;
}
}
// Not good - the child thought it was in a parent,
// but it wasn't.
assert(false);
return index;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:45,
示例18: _findRelativeComponentDeprecated
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Find a component relative to another.
* This method is the same as the 'old' public findRelativeComponent.
* This method is around so that the
* new findRelativeComponent method is backward compatibility.
*
* The relative ID must account for NamingContainers. If the component is already inside
* of a naming container, you can use a single colon to start the search from the root,
* or multiple colons to move up through the NamingContainers - "::" will search from
* the parent naming container, ":::" will search from the grandparent
* naming container, etc.
*
*
* @param from the component to search relative to
* @param relativeId the relative path to the component to find
* @return the component if found, null otherwise
*/
private static UIComponent _findRelativeComponentDeprecated(
UIComponent from,
String relativeId)
{
UIComponent originalFrom = from;
String originalRelativeId = relativeId;
int idLength = relativeId.length();
// Figure out how many colons
int colonCount = 0;
while (colonCount < idLength)
{
if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
break;
colonCount++;
}
// colonCount == 0: fully relative
// colonCount == 1: absolute (still normal findComponent syntax)
// colonCount > 1: for each extra colon after 1, go up a naming container
// (to the view root, if naming containers run out)
if (colonCount > 1)
{
relativeId = relativeId.substring(colonCount);
for (int j = 1; j < colonCount; j++)
{
while (from.getParent() != null)
{
from = from.getParent();
if (from instanceof NamingContainer)
break;
}
}
}
UIComponent found = from.findComponent(relativeId);
if (found != null)
{
_LOG.warning("DEPRECATED_RELATIVE_ID_SYNTAX",
new Object[] {originalRelativeId, originalFrom});
}
return found;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:61,
示例19: _calculateClientId
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Calculates the clientId for the component
*/
private String _calculateClientId(FacesContext context)
{
// the clientId is always at least the id of the current component
// our implementation of getId() guarantees that this always
// returns a non-null value
String clientId = getId();
// Search for an ancestor that is a naming container
UIComponent lastParent = null;
UIComponent currParent = getParent();
while (true)
{
// prepend the NamingContainer portion of the id
if (currParent instanceof NamingContainer)
{
String contClientId;
// Pass additional context information to naming containers which extend UIXComponent:
if (currParent instanceof UIXComponent)
contClientId = ((UIXComponent)currParent).getContainerClientId(context, this);
else
contClientId = currParent.getContainerClientId(context);
StringBuilder bld = __getSharedStringBuilder();
bld.append(contClientId).append(NamingContainer.SEPARATOR_CHAR).append(clientId);
clientId = bld.toString();
break;
}
else if (currParent == null)
{
if (lastParent instanceof UIViewRoot)
{
// we got to the top of the component tree, so done looping
break;
}
else
{
// the component isn't in the component tree, which can cause the cached client id to be wrong.
// =-= btsulliv see Trinidad-2374. We can't do this right now because of a couple of bogus Trinidad Renderers
break;
/*
throw new IllegalStateException("Calling getClientId() on component " + this +
" when it is not in the component tree. Ancestor path:" +_getAncestorPath());
*/
}
}
lastParent = currParent;
currParent = lastParent.getParent();
}
Renderer renderer = getRenderer(context);
if (null != renderer)
clientId = renderer.convertClientId(context, clientId);
return clientId;
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:64,
示例20: findComponent
點讚 2
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public UIComponent findComponent(String id)
{
if (id == null)
throw new NullPointerException();
if ("".equals(id))
throw new IllegalArgumentException();
UIComponent from = this;
// If it starts with the separator character, it's
// an absolute path: start at the top
if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR)
{
id = id.substring(1);
while (from.getParent() != null)
from = from.getParent();
}
// If it's a NamingContainer, start right here
else if (this instanceof NamingContainer)
{
;
}
// Otherwise, go up to look for NamingContainer (or the top)
else
{
while (from.getParent() != null)
{
from = from.getParent();
if (from instanceof NamingContainer)
break;
}
}
// Evaluate each part of the expression
String searchId;
int separatorIndex = id.indexOf(NamingContainer.SEPARATOR_CHAR);
if (separatorIndex < 0)
searchId = id;
else
searchId = id.substring(0, separatorIndex);
if (searchId.equals(from.getId()))
{
// Don't need to look inside if we're already there
;
}
else
{
from = _findInsideOf(from, searchId);
}
// Final ID: break, and return whatever we've found
if (separatorIndex < 0)
{
return from;
}
// Just an intermediate step. Make sure we're at a NamingContainer,
// and then ask it to find the rest of the expression.
else
{
if (from == null)
return null;
if (!(from instanceof NamingContainer))
throw new IllegalArgumentException();
return from.findComponent(id.substring(separatorIndex + 1));
}
}
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:70,
注:本文中的javax.faces.component.UIComponent.getParent方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。