| Method from org.apache.myfaces.trinidad.component.UIXComponentBase Detail: |
void __encodeRecursive(FacesContext context,
UIComponent component) throws IOException {
if (component.isRendered())
{
component.encodeBegin(context);
if (component.getRendersChildren())
{
component.encodeChildren(context);
}
else
{
if (component.getChildCount() > 0)
{
for(UIComponent child : component.getChildren())
{
__encodeRecursive(context, child);
}
}
}
component.encodeEnd(context);
}
}
render a component. this is called by renderers whose
getRendersChildren() return true. |
static StringBuilder __getSharedStringBuilder() {
StringBuilder sb = _STRING_BUILDER.get();
if (sb == null)
{
sb = new StringBuilder();
_STRING_BUILDER.set(sb);
}
// clear out the stringBuilder by setting the length to 0
sb.setLength(0);
return sb;
}
This gets a single threadlocal shared stringbuilder instance, each time you call
__getSharedStringBuilder it sets the length of the stringBuilder instance to 0.
This allows you to use the same StringBuilder instance over and over.
You must call toString on the instance before calling __getSharedStringBuilder again.
Example that works
StringBuilder sb1 = __getSharedStringBuilder();
sb1.append(a).append(b);
String c = sb1.toString();
StringBuilder sb2 = __getSharedStringBuilder();
sb2.append(b).append(a);
String d = sb2.toString();
Example that doesn't work, you must call toString on sb1 before
calling __getSharedStringBuilder again.
StringBuilder sb1 = __getSharedStringBuilder();
StringBuilder sb2 = __getSharedStringBuilder();
sb1.append(a).append(b);
String c = sb1.toString();
sb2.append(b).append(a);
String d = sb2.toString();
|
void __rendererDecode(FacesContext context) {
_cacheRenderer(context);
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.decode(context, this);
}
}
|
public static MethodExpression adaptMethodBinding(MethodBinding binding) {
return new MethodBindingMethodExpression(binding);
}
Given a MethodBinding, create a MethodExpression that
adapts it. |
protected void addAttributeChange(String attributeName,
Object attributeValue) {
AttributeComponentChange aa =
new AttributeComponentChange(attributeName, attributeValue);
RequestContext adfContext = RequestContext.getCurrentInstance();
adfContext.getChangeManager().addComponentChange(getFacesContext(), this, aa);
}
|
public void addAttributeChangeListener(AttributeChangeListener acl) {
addFacesListener(acl);
}
|
protected void addFacesListener(FacesListener listener) {
if (listener == null)
throw new NullPointerException();
getFacesBean().addEntry(_LISTENERS_KEY, listener);
}
|
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event == null)
throw new NullPointerException();
if (_LOG.isFine())
_LOG.fine("Broadcasting event " + event + " to " + this);
UIComponent component = event.getComponent();
if (component != null)
{
RequestContext adfContext = RequestContext.getCurrentInstance();
if (adfContext != null)
adfContext.partialUpdateNotify(component);
}
Iterator< FacesListener > iter =
(Iterator< FacesListener >)getFacesBean().entries(_LISTENERS_KEY);
while (iter.hasNext())
{
FacesListener listener = iter.next();
if (event.isAppropriateListener(listener))
{
event.processListener(listener);
}
}
if (event instanceof AttributeChangeEvent)
{
broadcastToMethodExpression(event, getAttributeChangeListener());
}
}
|
protected final void broadcastToMethodBinding(FacesEvent event,
MethodBinding method) throws AbortProcessingException {
if (method != null)
{
try
{
FacesContext context = getFacesContext();
method.invoke(context, new Object[] { event });
}
catch (EvaluationException ee)
{
Throwable t = ee.getCause();
// Unwrap AbortProcessingExceptions
if (t instanceof AbortProcessingException)
throw ((AbortProcessingException) t);
throw ee;
}
}
} Deprecated!
Broadcast an event to a MethodBinding.
This can be used to support MethodBindings such as the "actionListener"
binding on ActionSource components:
<tr:commandButton actionListener="#{mybean.myActionListener}"> |
protected final void broadcastToMethodExpression(FacesEvent event,
MethodExpression method) throws AbortProcessingException {
if (method != null)
{
try
{
FacesContext context = getFacesContext();
method.invoke(context.getELContext(), new Object[] { event });
}
catch (ELException ee)
{
Throwable t = ee.getCause();
// Unwrap AbortProcessingExceptions
if (t instanceof AbortProcessingException)
throw ((AbortProcessingException) t);
throw ee;
}
}
}
Broadcast an event to a MethodExpression.
This can be used to support MethodBindings such as the "actionListener"
binding on ActionSource components:
<tr:commandButton actionListener="#{mybean.myActionListener}"> |
protected FacesBean createFacesBean(String rendererType) {
FacesBean bean = FacesBeanFactory.createFacesBean(getClass(),
rendererType);
UIXFacesBean uixBean = (UIXFacesBean) bean;
uixBean.init(this, getBeanType());
return uixBean;
}
|
public void decode(FacesContext context) {
if (context == null)
throw new NullPointerException();
// Find all the partialTriggers and save on the context
Map< String, Object > attrs = getAttributes();
Object triggers = attrs.get("partialTriggers");
if (triggers instanceof String[])
{
RequestContext adfContext = RequestContext.getCurrentInstance();
if (adfContext != null)
adfContext.addPartialTriggerListeners(this, (String[]) triggers);
}
__rendererDecode(context);
}
|
protected final void decodeChildren(FacesContext context) {
LifecycleRenderer renderer = getLifecycleRenderer(context);
// if there is a HierarchyRenderer for this component
if (renderer != null)
{
if (renderer.decodeChildren(context, this))
return;
}
decodeChildrenImpl(context);
}
Delegates to LifecycleRenderer, if present,
otherwise calls decodeChildrenImpl. |
protected void decodeChildrenImpl(FacesContext context) {
Iterator< UIComponent > kids = getFacetsAndChildren();
while (kids.hasNext())
{
UIComponent kid = kids.next();
kid.processDecodes(context);
}
}
Calls processDecodes on all facets and children of this
component. |
public void encodeAll(FacesContext context) throws IOException {
if (context == null)
throw new NullPointerException();
// This code ends up calling isRendered() once overall,
// plus up to three times more for encodeBegin(),
// encodeChildren(), and encodeEnd().
__encodeRecursive(context, this);
}
Encodes a component and all of its children, whether
getRendersChildren() is true or false. When rendersChildren
is false, each child whose "rendered" property is true
will be sequentially rendered; facets will be ignored. |
public void encodeBegin(FacesContext context) throws IOException {
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
_cacheRenderer(context);
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.encodeBegin(context, this);
}
}
|
public void encodeChildren(FacesContext context) throws IOException {
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.encodeChildren(context, this);
}
}
|
public void encodeEnd(FacesContext context) throws IOException {
if (context == null)
throw new NullPointerException();
if (isRendered())
{
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.encodeEnd(context, this);
}
}
}
|
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));
}
}
|
public MethodExpression getAttributeChangeListener() {
return (MethodExpression) getProperty(_ATTRIBUTE_CHANGE_LISTENER_KEY);
}
|
public AttributeChangeListener[] getAttributeChangeListeners() {
return (AttributeChangeListener[])
getFacesListeners(AttributeChangeListener.class);
}
|
public Map getAttributes() {
if (_attributes == null)
_init(null);
return _attributes;
}
|
protected FacesBean.Type getBeanType() {
return TYPE;
}
|
protected boolean getBooleanProperty(PropertyKey key,
boolean defaultValue) {
Object o = getFacesBean().getProperty(key);
if (defaultValue)
return !Boolean.FALSE.equals(o);
else
return Boolean.TRUE.equals(o);
}
|
public int getChildCount() {
if (_children == null)
return 0;
return getChildren().size();
}
|
public List getChildren() {
if (_children == null)
_children = new ChildArrayList(this);
return _children;
}
|
public String getClientId(FacesContext context) {
// NOTE - client ids cannot be cached because the generated
// value has to be dynamically calculated in some cases (UIData)
String clientId = getId();
if (clientId == null)
{
clientId = (String) getProperty(_GENERATED_ID_KEY);
if (clientId == null)
{
clientId = context.getViewRoot().createUniqueId();
setProperty(_GENERATED_ID_KEY, clientId);
}
}
// Search for an ancestor that is a naming container
UIComponent containerComponent = getParent();
while (null != containerComponent)
{
if (containerComponent instanceof NamingContainer)
{
String contClientId;
// Pass additional context information to naming containers which extend UIXComponent:
if (containerComponent instanceof UIXComponent)
contClientId = ((UIXComponent)containerComponent).getContainerClientId(context, this);
else
contClientId = containerComponent.getContainerClientId(context);
StringBuilder bld = __getSharedStringBuilder();
bld.append(contClientId).append(NamingContainer.SEPARATOR_CHAR).append(clientId);
clientId = bld.toString();
break;
}
containerComponent = containerComponent.getParent();
}
Renderer renderer = getRenderer(context);
if (null != renderer)
clientId = renderer.convertClientId(context, clientId);
return clientId;
}
|
public String getContainerClientId(FacesContext context,
UIComponent child) {
return getContainerClientId(context);
}
|
public FacesBean getFacesBean() {
if (_facesBean == null)
_init(null);
return _facesBean;
}
|
protected FacesContext getFacesContext() {
// If we ever have a way for a component to get notified
// when it's finished being used for a given request,
// we could cache this as an instance variable.
return FacesContext.getCurrentInstance();
}
|
protected FacesListener[] getFacesListeners(Class clazz) {
if (clazz == null)
throw new NullPointerException();
if (!FacesListener.class.isAssignableFrom(clazz))
throw new IllegalArgumentException();
return (FacesListener[])
getFacesBean().getEntries(_LISTENERS_KEY, clazz);
}
|
public UIComponent getFacet(String facetName) {
if (facetName == null)
throw new NullPointerException();
if (_facets == null)
return null;
return getFacets().get(facetName);
}
|
public int getFacetCount() {
if (_facets == null)
return 0;
return _facets.size();
}
Return the number of facets. This is more efficient than
calling getFacets().size(); |
public Iterator getFacetNames() {
if (_facets == null)
return _EMPTY_STRING_ITERATOR;
return _facets.keySet().iterator();
}
Returns an Iterator over the names of all facets.
Unlike getFacets().keySet().iterator(), this does
not require instantiating a Map if there are
no facets. (Note that this is not part of the
UIComponent API.) |
public Map getFacets() {
if (_facets == null)
_facets = new FacetHashMap(this);
return _facets;
}
|
public Iterator getFacetsAndChildren() {
// =-=AEW Is this supposed to be an immutable Iterator?
if (_facets == null)
{
if (_children == null)
return _EMPTY_UICOMPONENT_ITERATOR;
return _children.iterator();
}
else
{
if (_children == null)
return _facets.values().iterator();
}
ArrayList< UIComponent > childrenAndFacets = new ArrayList< UIComponent >();
for(UIComponent facet : _facets.values())
{
childrenAndFacets.add(facet);
}
for(UIComponent child : _children)
{
childrenAndFacets.add(child);
}
if (childrenAndFacets.isEmpty())
return _EMPTY_UICOMPONENT_ITERATOR;
return childrenAndFacets.iterator();
}
|
abstract public String getFamily()
|
public String getId() {
return (String) getProperty(ID_KEY);
}
Gets the identifier for the component. |
protected int getIntProperty(PropertyKey key,
int defaultValue) {
Number n = (Number) getFacesBean().getProperty(key);
if (n == null)
return defaultValue;
return n.intValue();
}
|
protected LifecycleRenderer getLifecycleRenderer(FacesContext context) {
LifecycleRenderer renderer = _cachedLifecycleRenderer;
if (renderer != _UNDEFINED_LIFECYCLE_RENDERER)
return renderer;
return _getLifecycleRendererImpl(context);
}
|
public UIComponent getParent() {
return _parent;
}
|
protected Object getProperty(PropertyKey key) {
return getFacesBean().getProperty(key);
}
|
protected PropertyKey getPropertyKey(String name) {
PropertyKey key = getBeanType().findKey(name);
if (key == null)
key = PropertyKey.createPropertyKey(name);
return key;
}
|
protected Renderer getRenderer(FacesContext context) {
Renderer renderer = _cachedRenderer;
if (renderer != _UNDEFINED_RENDERER)
return renderer;
return _getRendererImpl(context);
}
|
public String getRendererType() {
// Don't create the FacesBean just to get the renderer type;
// Generally, rendererType will be the first property
// set, which will trigger the code below in setRendererType()
// to run correctly.
if (_facesBean == null)
return null;
return (String) getProperty(RENDERER_TYPE_KEY);
}
|
public boolean getRendersChildren() {
Renderer renderer = getRenderer(getFacesContext());
if (renderer == null)
return false;
return renderer.getRendersChildren();
}
|
public ValueBinding getValueBinding(String name) {
if (name == null)
throw new NullPointerException();
PropertyKey key = getPropertyKey(name);
// Support standard RI behavior where getValueBinding()
// doesn't complain about being asked for a ValueBinding -
// but continue supporting strict behavior at FacesBean layer.
if (!key.getSupportsBinding())
return null;
return getFacesBean().getValueBinding(key);
}
|
public ValueExpression getValueExpression(String name) {
if (name == null)
throw new NullPointerException();
PropertyKey key = getPropertyKey(name);
// Support standard RI behavior where getValueBinding()
// doesn't complain about being asked for a ValueBinding -
// but continue supporting strict behavior at FacesBean layer.
if (!key.getSupportsBinding())
return null;
return getFacesBean().getValueExpression(key);
}
|
public boolean isRendered() {
return getBooleanProperty(RENDERED_KEY, true);
}
|
public boolean isTransient() {
return getBooleanProperty(TRANSIENT_KEY, false);
}
|
public void markInitialState() {
// -= Simon Lessard =-
// FIXME: Set to true, but never read
//_initialStateMarked = true;
getFacesBean().markInitialState();
}
|
public void processDecodes(FacesContext context) {
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
// Process all facets and children of this component
decodeChildren(context);
// Process this component itself
decode(context);
}
|
public void processRestoreState(FacesContext context,
Object state) {
if (context == null)
throw new NullPointerException();
if (_LOG.isFiner())
_LOG.finer("processRestoreState() on " + this);
// If we saved a "TreeState", use it to restore everything
if (state instanceof TreeState)
{
((TreeState) state).restoreState(context, this);
}
// Otherwise, we had no children or facets, and just use
// the "state" object
else
{
restoreState(context, state);
}
}
|
public Object processSaveState(FacesContext context) {
if (context == null)
throw new NullPointerException();
if (_LOG.isFiner())
_LOG.finer("processSaveState() on " + this);
if (((_children == null) || _children.isEmpty()) &&
((_facets == null) || _facets.isEmpty()))
{
return saveState(context);
}
else
{
TreeState state = new TreeState();
state.saveState(context, this);
if (state.isEmpty())
return null;
return state;
}
}
|
public void processUpdates(FacesContext context) {
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
// Process all facets and children of this component
updateChildren(context);
}
|
public void processValidators(FacesContext context) {
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
// Process all facets and children of this component
validateChildren(context);
}
|
public void queueEvent(FacesEvent event) {
if (event == null)
throw new NullPointerException();
UIComponent parent = getParent();
if (parent == null)
throw new IllegalStateException();
parent.queueEvent(event);
}
|
public void removeAttributeChangeListener(AttributeChangeListener acl) {
removeFacesListener(acl);
}
|
protected void removeFacesListener(FacesListener listener) {
if (listener == null)
throw new NullPointerException();
getFacesBean().removeEntry(_LISTENERS_KEY, listener);
}
|
public void restoreState(FacesContext context,
Object stateObj) {
getFacesBean().restoreState(context, stateObj);
}
|
public Object saveState(FacesContext context) {
return getFacesBean().saveState(context);
}
|
public void setAttributeChangeListener(MethodExpression mb) {
setProperty(_ATTRIBUTE_CHANGE_LISTENER_KEY, mb);
}
|
public void setAttributeChangeListener(MethodBinding mb) {
setAttributeChangeListener(adaptMethodBinding(mb));
}
|
protected void setBooleanProperty(PropertyKey key,
boolean value) {
getFacesBean().setProperty(key, value ? Boolean.TRUE : Boolean.FALSE);
}
|
public void setId(String id) {
// =-=AEW Currently, setId() assumes that resetting to
// the same value *is not* short-circuited.
_validateId(id);
// If we're setting the ID to null, don't discard
// the _GENERATED_ID
if (id != null)
setProperty(_GENERATED_ID_KEY, null);
setProperty(ID_KEY, id);
}
Sets the identifier for the component. The identifier
must follow a subset of the syntax allowed in HTML:
- Must not be a zero-length String.
- First character must be an ASCII letter (A-Za-z) or an underscore ('_').
- Subsequent characters must be an ASCII letter or digit (A-Za-z0-9), an underscore ('_'), or a dash ('-').
|
protected void setIntProperty(PropertyKey key,
int value) {
getFacesBean().setProperty(key, Integer.valueOf(value));
}
|
public void setParent(UIComponent parent) {
_parent = parent;
}
|
protected void setProperty(PropertyKey key,
Object value) {
getFacesBean().setProperty(key, value);
}
|
public void setRendered(boolean rendered) {
setBooleanProperty(RENDERED_KEY, rendered);
}
|
public void setRendererType(String rendererType) {
String oldRendererType = getRendererType();
if (oldRendererType == null)
{
if (rendererType == null)
return;
}
else if (oldRendererType.equals(rendererType))
{
return;
}
// prepare the faces bean
_init(rendererType);
setProperty(RENDERER_TYPE_KEY, rendererType);
}
|
public void setTransient(boolean newTransient) {
setBooleanProperty(TRANSIENT_KEY, newTransient);
}
|
public void setValueBinding(String name,
ValueBinding binding) {
if (name == null)
throw new NullPointerException();
PropertyKey key = getPropertyKey(name);
getFacesBean().setValueBinding(key, binding);
}
|
public void setValueExpression(String name,
ValueExpression expression) {
if (name == null)
throw new NullPointerException();
if ((expression != null) && expression.isLiteralText())
{
ELContext context =
FacesContext.getCurrentInstance().getELContext();
getAttributes().put(name, expression.getValue(context));
}
else
{
PropertyKey key = getPropertyKey(name);
getFacesBean().setValueExpression(key, expression);
}
}
|
public String toString() {
String className = getClass().getName();
int periodIndex = className.lastIndexOf('.");
if (periodIndex >= 0)
className = className.substring(periodIndex + 1);
return className + "[" + getFacesBean().toString() + ", id=" + getId() + "]";
}
|
protected final void updateChildren(FacesContext context) {
LifecycleRenderer renderer = getLifecycleRenderer(context);
// if there is a ExtendedRenderer for this component
if (renderer != null)
{
if (renderer.updateChildren(context, this))
return;
}
updateChildrenImpl(context);
}
Delegates to LifecycleRenderer, if present,
otherwise calls upateChildrenImpl. |
protected void updateChildrenImpl(FacesContext context) {
// Process all the facets and children of this component
Iterator< UIComponent > kids = getFacetsAndChildren();
while (kids.hasNext())
{
UIComponent kid = kids.next();
kid.processUpdates(context);
}
}
|
protected final void validateChildren(FacesContext context) {
LifecycleRenderer renderer = getLifecycleRenderer(context);
// if there is a ExtendedRenderer for this component
if (renderer != null)
{
if (renderer.validateChildren(context, this))
return;
}
validateChildrenImpl(context);
}
Delegates to LifecycleRenderer, if present,
otherwise calls validateChildrenImpl. |
protected void validateChildrenImpl(FacesContext context) {
// Process all the facets and children of this component
Iterator< UIComponent > kids = getFacetsAndChildren();
while (kids.hasNext())
{
UIComponent kid = kids.next();
kid.processValidators(context);
}
}
Calls processValidators on all facets and children of this
component. |