code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@SuppressWarnings("unchecked")
public final Component setDefaultModelObject(final Object object)
{
final IModel<Object> model = (IModel<Object>)getDefaultModel();
// Check whether anything can be set at all
if (model == null)
{
throw new IllegalStateException(
"Attempt to set a model object on a component without a model! " +
"Either pass an IModel to the constructor or use #setDefaultModel(new SomeModel(object)). " +
"Component: " + getPageRelativePath());
}
// Check authorization
if (!isActionAuthorized(ENABLE))
{
throw new UnauthorizedActionException(this, ENABLE);
}
// Check whether this will result in an actual change
if (!getModelComparator().compare(this, object))
{
modelChanging();
model.setObject(object);
modelChanged();
}
return this;
}
|
Sets the backing model object. Unlike <code>getDefaultModel().setObject(object)</code>, this
method checks authorisation and model comparator, and invokes <code>modelChanging</code> and
<code>modelChanged</code> if the value really changes.
@param object
The object to set
@return This
@throws IllegalStateException If the component has neither its own model nor any of its
parents uses {@link IComponentInheritedModel}
|
setDefaultModelObject
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final Component setOutputMarkupId(final boolean output)
{
setFlag(FLAG_OUTPUT_MARKUP_ID, output);
return this;
}
|
Sets whether or not component will output id attribute into the markup. id attribute will be
set to the value returned from {@link Component#getMarkupId()}.
@param output
True if the component will output the id attribute into markup. Please note that
the default behavior is to use the same id as the component. This means that your
component must begin with [a-zA-Z] in order to generate a valid markup id
according to: http://www.w3.org/TR/html401/types.html#type-name
@return this for chaining
|
setOutputMarkupId
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final Component setOutputMarkupPlaceholderTag(final boolean outputTag)
{
if (outputTag != getFlag(FLAG_PLACEHOLDER))
{
if (outputTag)
{
setOutputMarkupId(true);
setFlag(FLAG_PLACEHOLDER, true);
}
else
{
setFlag(FLAG_PLACEHOLDER, false);
// I think it's better to not setOutputMarkupId to false...
// user can do it if she want
}
}
return this;
}
|
Render a placeholder tag when the component is not visible. The tag is of form:
<componenttag style="display:none;" id="markupid"/>. This method will also call
<code>setOutputMarkupId(true)</code>.
This is useful, for example, in ajax situations where the component starts out invisible and
then becomes visible through an ajax update. With a placeholder tag already in the markup you
do not need to repaint this component's parent, instead you can repaint the component
directly.
When this method is called with parameter <code>false</code> the outputmarkupid flag is not
reverted to false.
@param outputTag
@return this for chaining
|
setOutputMarkupPlaceholderTag
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final Component setRenderBodyOnly(final boolean renderTag)
{
setFlag(FLAG_RENDER_BODY_ONLY, renderTag);
return this;
}
|
If false the component's tag will be printed as well as its body (which is default). If true
only the body will be printed, but not the component's tag.
@param renderTag
If true, the component tag will not be printed
@return This
|
setRenderBodyOnly
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final <C extends IRequestablePage> void setResponsePage(final Class<C> cls)
{
getRequestCycle().setResponsePage(cls, (PageParameters)null);
}
|
Sets the page that will respond to this request
@param <C>
@param cls
The response page class
@see RequestCycle#setResponsePage(Class)
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final <C extends IRequestablePage> void setResponsePage(final Class<C> cls,
PageParameters parameters)
{
getRequestCycle().setResponsePage(cls, parameters);
}
|
Sets the page class and its parameters that will respond to this request
@param <C>
@param cls
The response page class
@param parameters
The parameters for this bookmarkable page.
@see RequestCycle#setResponsePage(Class, PageParameters)
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public Component setVersioned(boolean versioned)
{
setFlag(FLAG_VERSIONED, versioned);
return this;
}
|
@param versioned
True to turn on versioning for this component, false to turn it off for this
component and any children.
@return This
|
setVersioned
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
@Override
public String toString()
{
return toString(false);
}
|
Gets the string representation of this component.
@return The path to this component
|
toString
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public String toString(final boolean detailed)
{
try
{
final StringBuilder buffer = new StringBuilder();
buffer.append("[Component id = ").append(getId());
if (detailed)
{
final Page page = findPage();
if (page == null)
{
buffer.append(", page = <No Page>, path = ")
.append(getPath())
.append('.')
.append(Classes.simpleName(getClass()));
}
else
{
buffer.append(", page = ")
.append(Classes.name(getPage().getPageClass()))
.append(", path = ")
.append(getPageRelativePath())
.append(", type = ")
.append(Classes.name(getClass()))
.append(", isVisible = ")
.append((determineVisibility()))
.append(", isVersioned = ")
.append(isVersioned());
}
if (markup != null)
{
buffer.append(", markup = ").append(new MarkupStream(getMarkup()).toString());
}
}
buffer.append(']');
return buffer.toString();
}
catch (Exception e)
{
log.warn("Error while building toString()", e);
return String.format(
"[Component id = %s <attributes are not available because exception %s was thrown during toString()>]",
getId(), e.getClass().getName());
}
}
|
@param detailed
True if a detailed string is desired
@return The string
|
toString
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final CharSequence urlFor(final Behavior behaviour,
final RequestListenerInterface listener, final PageParameters parameters)
{
int id = getBehaviorId(behaviour);
IRequestHandler handler = createRequestHandler(listener, parameters, id);
return getRequestCycle().urlFor(handler);
}
|
Gets a URL for the listener interface on a behavior (e.g. IBehaviorListener on
AjaxPagingNavigationBehavior).
@param behaviour
The behavior that the URL should point to
@param listener
The listener interface that the URL should call
@param parameters
The parameters that should be rendered into the urls
@return The URL
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
private IRequestHandler createRequestHandler(RequestListenerInterface listener,
PageParameters parameters, Integer id)
{
Page page = getPage();
PageAndComponentProvider provider = new PageAndComponentProvider(page, this, parameters);
if (page.isPageStateless()
|| (page.isBookmarkable() && page.wasCreatedBookmarkable()))
{
return new BookmarkableListenerInterfaceRequestHandler(provider, listener, id);
}
else
{
return new ListenerInterfaceRequestHandler(provider, listener, id);
}
}
|
Create a suitable request handler depending whether the page is stateless or bookmarkable.
|
createRequestHandler
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final CharSequence urlFor(final IRequestHandler requestHandler)
{
return getRequestCycle().urlFor(requestHandler);
}
|
Returns a URL that references the given request target.
@see RequestCycle#urlFor(IRequestHandler)
@param requestHandler
the request target to reference
@return a URL that references the given request target
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final CharSequence urlFor(final RequestListenerInterface listener,
final PageParameters parameters)
{
IRequestHandler handler = createRequestHandler(listener, parameters, null);
return getRequestCycle().urlFor(handler);
}
|
Gets a URL for the listener interface (e.g. ILinkListener).
@see RequestCycle#urlFor(IRequestHandler)
@param listener
The listener interface that the URL should call
@param parameters
The parameters that should be rendered into the urls
@return The URL
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final CharSequence urlFor(final ResourceReference resourceReference,
PageParameters parameters)
{
return getRequestCycle().urlFor(resourceReference, parameters);
}
|
Returns a URL that references a shared resource through the provided resource reference.
@see RequestCycle#urlFor(IRequestHandler)
@param resourceReference
The resource reference
@param parameters
parameters or {@code null} if none
@return The url for the shared resource
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final <R, C extends MarkupContainer> R visitParents(final Class<C> parentClass,
final IVisitor<C, R> visitor)
{
return visitParents(parentClass, visitor, IVisitFilter.ANY);
}
|
Traverses all parent components of the given class in this parentClass, calling the visitor's
visit method at each one.
@param <R>
the type of the result object
@param parentClass
Class
@param visitor
The visitor to call at each parent of the given type
@return First non-null value returned by visitor callback
|
visitParents
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
@SuppressWarnings("unchecked")
public final <R, C extends MarkupContainer> R visitParents(final Class<C> parentClass,
final IVisitor<C, R> visitor, IVisitFilter filter)
{
Args.notNull(filter, "filter");
// Start here
MarkupContainer current = getParent();
Visit<R> visit = new Visit<R>();
// Walk up containment hierarchy
while (current != null)
{
// Is current an instance of this class?
if (parentClass.isInstance(current) && filter.visitObject(current))
{
visitor.component((C)current, visit);
if (visit.isStopped())
{
return visit.getResult();
}
}
// Check parent
current = current.getParent();
}
return null;
}
|
Traverses all parent components of the given class in this parentClass, calling the visitor's
visit method at each one.
@param <R>
the type of the result object
@param parentClass
the class of the parent component
@param visitor
The visitor to call at each parent of the given type
@param filter
a filter that adds an additional logic to the condition whether a parent container
matches
@return First non-null value returned by visitor callback
|
visitParents
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final void warn(final Serializable message)
{
getFeedbackMessages().warn(this, message);
addStateChange();
}
|
Registers a warning feedback message for this component.
@param message
The feedback message
|
warn
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
private void notifyBehaviorsComponentBeforeRender()
{
for (Behavior behavior : getBehaviors())
{
if (isBehaviorAccepted(behavior))
{
behavior.beforeRender(this);
}
}
}
|
{@link Behavior#beforeRender(Component)} Notify all behaviors that are assigned to this
component that the component is about to be rendered.
|
notifyBehaviorsComponentBeforeRender
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
private void notifyBehaviorsComponentRendered()
{
// notify the behaviors that component has been rendered
for (Behavior behavior : getBehaviors())
{
if (isBehaviorAccepted(behavior))
{
behavior.afterRender(this);
}
}
}
|
{@link Behavior#afterRender(Component)} Notify all behaviors that are assigned to this
component that the component has rendered.
|
notifyBehaviorsComponentRendered
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final void addStateChange()
{
checkHierarchyChange(this);
final Page page = findPage();
if (page != null)
{
page.componentStateChanging(this);
}
}
|
TODO WICKET-NG rename to something more useful - like componentChanged(), this method used to
be called with a Change object
Adds state change to page.
|
addStateChange
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final void checkComponentTag(final ComponentTag tag, final String name)
{
if (!tag.getName().equalsIgnoreCase(name))
{
String msg = String.format("Component [%s] (path = [%s]) must be "
+ "applied to a tag of type [%s], not: %s", getId(), getPath(), name,
tag.toUserDebugString());
findMarkupStream().throwMarkupException(msg);
}
}
|
Checks whether the given type has the expected name.
@param tag
The tag to check
@param name
The expected tag name
@throws MarkupException
Thrown if the tag is not of the right name
|
checkComponentTag
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final void checkComponentTagAttribute(final ComponentTag tag, final String key,
final String... values)
{
if (key != null)
{
final String tagAttributeValue = tag.getAttributes().getString(key);
boolean found = false;
if (tagAttributeValue != null)
{
for (String value : values)
{
if (value.equalsIgnoreCase(tagAttributeValue))
{
found = true;
break;
}
}
}
if (found == false)
{
String msg = String.format("Component [%s] (path = [%s]) must be applied to a tag "
+ "with [%s] attribute matching any of %s, not [%s]", getId(), getPath(), key,
Arrays.toString(values), tagAttributeValue);
findMarkupStream().throwMarkupException(msg);
}
}
}
|
Checks that a given tag has a required attribute value.
@param tag
The tag
@param key
The attribute key
@param values
The required value for the attribute key
@throws MarkupException
Thrown if the tag does not have the required attribute value
|
checkComponentTagAttribute
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected void checkHierarchyChange(final Component component)
{
// Throw exception if modification is attempted during rendering
if (getFlag(FLAG_RENDERING) && !component.isAuto())
{
throw new WicketRuntimeException(
"Cannot modify component hierarchy after render phase has started (page version cant change then anymore)");
}
}
|
Checks whether the hierarchy may be changed at all, and throws an exception if this is not
the case.
@param component
the component which is about to be added or removed
|
checkHierarchyChange
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected void detachModel()
{
IModel<?> model = getModelImpl();
if (model != null)
{
model.detach();
}
// also detach the wrapped model of a component assigned wrap (not
// inherited)
if (model instanceof IWrapModel && !getFlag(FLAG_INHERITABLE_MODEL))
{
((IWrapModel<?>)model).getWrappedModel().detach();
}
}
|
Detaches the model for this component if it is detachable.
|
detachModel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final String exceptionMessage(final String message)
{
return message + ":\n" + toString();
}
|
Suffixes an exception message with useful information about this. component.
@param message
The message
@return The modified message
|
exceptionMessage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final MarkupStream findMarkupStream()
{
return new MarkupStream(getMarkup());
}
|
Finds the markup stream for this component.
@return The markup stream for this component. Since a Component cannot have a markup stream,
we ask this component's parent to search for it.
|
findMarkupStream
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final Page findPage()
{
// Search for page
return (Page)(this instanceof Page ? this : findParent(Page.class));
}
|
If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in
the component hierarchy. If no Page parent can be found, {@code null} is returned.
@return The Page or {@code null} if none can be found
|
findPage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public <M extends Behavior> List<M> getBehaviors(Class<M> type)
{
return new Behaviors(this).getBehaviors(type);
}
|
Gets the subset of the currently coupled {@link Behavior}s that are of the provided type as
an unmodifiable list. Returns an empty list if there are no behaviors coupled to this
component.
@param type
The type or null for all
@return The subset of the currently coupled behaviors that are of the provided type as an
unmodifiable list
@param <M>
A class derived from Behavior
|
getBehaviors
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final IModel<?> getInnermostModel(final IModel<?> model)
{
IModel<?> nested = model;
while (nested != null && nested instanceof IWrapModel)
{
final IModel<?> next = ((IWrapModel<?>)nested).getWrappedModel();
if (nested == next)
{
throw new WicketRuntimeException("Model for " + nested + " is self-referential");
}
nested = next;
}
return nested;
}
|
Finds the innermost IModel object for an IModel that might contain nested IModel(s).
@param model
The model
@return The innermost (most nested) model
|
getInnermostModel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public IModelComparator getModelComparator()
{
return defaultModelComparator;
}
|
Gets the component's current model comparator. Implementations can be used for testing the
current value of the components model data with the new value that is given.
@return the value defaultModelComparator
|
getModelComparator
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected boolean getStatelessHint()
{
return true;
}
|
Returns whether the component can be stateless. Also the component behaviors must be
stateless, otherwise the component will be treat as stateful. In order for page to be
stateless (and not to be stored in session), all components (and component behaviors) must be
stateless.
@return whether the component can be stateless
|
getStatelessHint
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected IModel<?> initModel()
{
IModel<?> foundModel = null;
// Search parents for IComponentInheritedModel (i.e. CompoundPropertyModel)
for (Component current = getParent(); current != null; current = current.getParent())
{
// Get model
// Don't call the getModel() that could initialize many in between
// completely useless models.
// IModel model = current.getDefaultModel();
IModel<?> model = current.getModelImpl();
if (model instanceof IWrapModel && !(model instanceof IComponentInheritedModel))
{
model = ((IWrapModel<?>)model).getWrappedModel();
}
if (model instanceof IComponentInheritedModel)
{
// return the shared inherited
foundModel = ((IComponentInheritedModel<?>)model).wrapOnInheritance(this);
setFlag(FLAG_INHERITABLE_MODEL, true);
break;
}
}
// No model for this component!
return foundModel;
}
|
Called when a null model is about to be retrieved in order to allow a subclass to provide an
initial model.
<p>
By default this implementation looks components in the parent chain owning a
{@link IComponentInheritedModel} to provide a model for this component via
{@link IComponentInheritedModel#wrapOnInheritance(Component)}.
<p>
For example a {@link FormComponent} has the opportunity to instantiate a model on the fly
using its {@code id} and the containing {@link Form}'s model, if the form holds a
{@link CompoundPropertyModel}.
@return The model
|
initModel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected boolean isBehaviorAccepted(final Behavior behavior)
{
// Ignore AttributeModifiers when FLAG_IGNORE_ATTRIBUTE_MODIFIER is set
if ((behavior instanceof AttributeModifier) &&
(getFlag(FLAG_IGNORE_ATTRIBUTE_MODIFIER) != false))
{
return false;
}
return behavior.isEnabled(this);
}
|
Components are allowed to reject behavior modifiers.
@param behavior
@return False, if the component should not apply this behavior
|
isBehaviorAccepted
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final boolean isIgnoreAttributeModifier()
{
return getFlag(FLAG_IGNORE_ATTRIBUTE_MODIFIER);
}
|
If true, all attribute modifiers will be ignored
@return True, if attribute modifiers are to be ignored
|
isIgnoreAttributeModifier
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected void onAfterRender()
{
setFlag(FLAG_AFTER_RENDERING, false);
}
|
Called just after a component is rendered.
|
onAfterRender
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
@SuppressWarnings("deprecation")
protected void onComponentTag(final ComponentTag tag)
{
// We can't try to get the ID from markup. This could be different than
// id returned from getMarkupId() prior first rendering the component
// (due to transparent resolvers and borders which break the 1:1
// component <-> markup relation)
if (getFlag(FLAG_OUTPUT_MARKUP_ID))
{
tag.putInternal(MARKUP_ID_ATTR_NAME, getMarkupId());
}
DebugSettings debugSettings = getApplication().getDebugSettings();
String componentPathAttributeName = debugSettings.getComponentPathAttributeName();
if (Strings.isEmpty(componentPathAttributeName) && debugSettings.isOutputComponentPath())
{
// fallback to the old 'wicketpath'
componentPathAttributeName = "wicketpath";
}
if (Strings.isEmpty(componentPathAttributeName) == false)
{
String path = getPageRelativePath();
path = path.replace("_", "__");
path = path.replace(':', '_');
tag.put(componentPathAttributeName, path);
}
// The markup sourcing strategy may also want to work on the tag
getMarkupSourcingStrategy().onComponentTag(this, tag);
}
|
Processes the component tag.
Overrides of this method most likely should call the super implementation.
@param tag
Tag to modify
|
onComponentTag
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected void onDetach()
{
setFlag(FLAG_DETACHING, false);
}
|
Called to allow a component to detach resources after use.
Overrides of this method MUST call the super implementation, the most logical place to do
this is the last line of the override method.
|
onDetach
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected void onRemove()
{
setFlag(FLAG_REMOVING_FROM_HIERARCHY, false);
}
|
Called to notify the component it is being removed from the component hierarchy
Overrides of this method MUST call the super implementation, the most logical place to do
this is the last line of the override method.
|
onRemove
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final void renderComponentTag(ComponentTag tag)
{
if (needToRenderTag(tag))
{
// apply behaviors that are attached to the component tag.
if (tag.hasBehaviors())
{
Iterator<? extends Behavior> tagBehaviors = tag.getBehaviors();
while (tagBehaviors.hasNext())
{
final Behavior behavior = tagBehaviors.next();
if (behavior.isEnabled(this))
{
behavior.onComponentTag(this, tag);
}
behavior.detach(this);
}
}
// Apply behavior modifiers
List<? extends Behavior> behaviors = getBehaviors();
if ((behaviors != null) && !behaviors.isEmpty() && !tag.isClose() &&
(isIgnoreAttributeModifier() == false))
{
tag = tag.mutable();
for (Behavior behavior : behaviors)
{
// Components may reject some behavior components
if (isBehaviorAccepted(behavior))
{
behavior.onComponentTag(this, tag);
}
}
}
if ((tag instanceof WicketTag) && !tag.isClose() &&
!getFlag(FLAG_IGNORE_ATTRIBUTE_MODIFIER))
{
ExceptionSettings.NotRenderableErrorStrategy notRenderableErrorStrategy = ExceptionSettings.NotRenderableErrorStrategy.LOG_WARNING;
if (Application.exists())
{
notRenderableErrorStrategy = getApplication().getExceptionSettings().getNotRenderableErrorStrategy();
}
String tagName = tag.getNamespace() + ":" + tag.getName();
String componentId = getId();
if (getFlag(FLAG_OUTPUT_MARKUP_ID))
{
String message = String.format("Markup id set on a component that is usually not rendered into markup. " +
"Markup id: %s, component id: %s, component tag: %s.",
getMarkupId(), componentId, tagName);
if (notRenderableErrorStrategy == ExceptionSettings.NotRenderableErrorStrategy.THROW_EXCEPTION)
{
throw new IllegalStateException(message);
}
log.warn(message);
}
if (getFlag(FLAG_PLACEHOLDER))
{
String message = String.format(
"Placeholder tag set on a component that is usually not rendered into markup. " +
"Component id: %s, component tag: %s.", componentId, tagName);
if (notRenderableErrorStrategy == ExceptionSettings.NotRenderableErrorStrategy.THROW_EXCEPTION)
{
throw new IllegalStateException(message);
}
log.warn(message);
}
}
// Write the tag
tag.writeOutput(getResponse(), !needToRenderTag(null),
getMarkup().getMarkupResourceStream().getWicketNamespace());
}
}
|
Writes a simple tag out to the response stream. Any components that might be referenced by
the tag are ignored. Also undertakes any tag attribute modifications if they have been added
to the component.
@param tag
The tag to write
|
renderComponentTag
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final void replaceComponentTagBody(final MarkupStream markupStream,
final ComponentTag tag, final CharSequence body)
{
// The tag might have been changed from open-close to open. Hence
// we'll need what was in the markup itself
ComponentTag markupOpenTag = null;
// If tag has a body
if (tag.isOpen())
{
// Get what tag was in the markup; not what the user it might
// have changed it to.
markupOpenTag = markupStream.getPreviousTag();
// If it was an open tag in the markup as well, than ...
if (markupOpenTag.isOpen())
{
// skip any raw markup in the body
markupStream.skipRawMarkup();
}
}
if (body != null)
{
// Write the new body
getResponse().write(body);
}
// If we had an open tag (and not an openclose tag) and we found a
// close tag, we're good
if (tag.isOpen())
{
// If it was an open tag in the markup, than there must be
// a close tag as well.
if ((markupOpenTag != null) && markupOpenTag.isOpen() && !markupStream.atCloseTag())
{
// There must be a component in this discarded body
markupStream.throwMarkupException("Expected close tag for '" + markupOpenTag +
"' Possible attempt to embed component(s) '" + markupStream.get() +
"' in the body of this component which discards its body");
}
}
}
|
Replaces the body with the given one.
@param markupStream
The markup stream to replace the tag body in
@param tag
The tag
@param body
The new markup
|
replaceComponentTagBody
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final Component setAuto(final boolean auto)
{
setFlag(FLAG_AUTO, auto);
return this;
}
|
@param auto
True to put component into auto-add mode
|
setAuto
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final Component setIgnoreAttributeModifier(final boolean ignore)
{
setFlag(FLAG_IGNORE_ATTRIBUTE_MODIFIER, ignore);
return this;
}
|
If true, all attribute modifiers will be ignored
@param ignore
If true, all attribute modifiers will be ignored
@return This
|
setIgnoreAttributeModifier
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
protected final <V> IModel<V> wrap(final IModel<V> model)
{
if (model instanceof IComponentAssignedModel)
{
return ((IComponentAssignedModel<V>)model).wrapOnAssignment(this);
}
return model;
}
|
@param <V>
The model type
@param model
The model to wrap if need be
@return The wrapped model
|
wrap
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
@Override
public Component get(final String path)
{
// Path to this component is an empty path
if (path.length() == 0)
{
return this;
}
throw new IllegalArgumentException(
exceptionMessage("Component is not a container and so does not contain the path " +
path));
}
|
Gets the component at the given path.
@param path
Path to component
@return The component at the path
|
get
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final boolean isAuto()
{
// Search up hierarchy for FLAG_AUTO
for (Component current = this; current != null; current = current.getParent())
{
if (current.getFlag(FLAG_AUTO))
{
return true;
}
}
return false;
}
|
@return True if this component or any of its parents is in auto-add mode
|
isAuto
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
boolean isPreparedForRender()
{
return getFlag(FLAG_PREPARED_FOR_RENDER);
}
|
@return <code>true</code> if component has been prepared for render
|
isPreparedForRender
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
final void renderClosingComponentTag(final MarkupStream markupStream,
final ComponentTag openTag, final boolean renderBodyOnly)
{
// Tag should be open tag and not openclose tag
if (openTag.isOpen())
{
// If we found a close tag and it closes the open tag, we're good
if (markupStream.atCloseTag() && markupStream.getTag().closes(openTag))
{
// Render the close tag
if ((renderBodyOnly == false) && needToRenderTag(openTag))
{
getResponse().write(openTag.syntheticCloseTagString());
}
}
else if (openTag.requiresCloseTag())
{
// Missing close tag. Some tags, e.g. <p> are handled like <p/> by most browsers and
// thus will not throw an exception.
markupStream.throwMarkupException("Expected close tag for " + openTag);
}
}
}
|
Renders the close tag at the current position in the markup stream.
@param markupStream
the markup stream
@param openTag
the tag to render
@param renderBodyOnly
if true, the tag will not be written to the output
|
renderClosingComponentTag
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
final Component setId(final String id)
{
if (!(this instanceof Page))
{
if (Strings.isEmpty(id))
{
throw new WicketRuntimeException("Null or empty component ID's are not allowed.");
}
}
if ((id != null) && (id.indexOf(':') != -1 || id.indexOf('~') != -1))
{
throw new WicketRuntimeException("The component ID must not contain ':' or '~' chars.");
}
this.id = id;
return this;
}
|
Sets the id of this component.
@param id
The non-null id of this component
|
setId
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final void setParent(final MarkupContainer parent)
{
if (this.parent != null && log.isDebugEnabled())
{
log.debug("Replacing parent " + this.parent + " with " + parent);
}
this.parent = parent;
}
|
THIS IS A WICKET INTERNAL API. DO NOT USE IT.
Sets the parent of a component. Typically what you really want is parent.add(child).
<p/>
Note that calling setParent() and not parent.add() will connect the child to the parent, but
the parent will not know the child. This might not be a problem in some cases, but e.g.
child.onDetach() will not be invoked (since the parent doesn't know it is his child).
@param parent
The parent container
|
setParent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
final void setRenderAllowed(boolean renderAllowed)
{
setFlag(FLAG_IS_RENDER_ALLOWED, renderAllowed);
}
|
Sets the render allowed flag.
@param renderAllowed
|
setRenderAllowed
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
void setRenderAllowed()
{
setRenderAllowed(isActionAuthorized(RENDER));
}
|
Sets the render allowed flag.
Visit all this page's children (overridden in MarkupContainer) to check rendering
authorization, as appropriate. We set any result; positive or negative as a temporary boolean
in the components, and when a authorization exception is thrown it will block the rendering
of this page
|
setRenderAllowed
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final Component setVisibilityAllowed(boolean allowed)
{
setFlag(FLAG_VISIBILITY_ALLOWED, allowed);
return this;
}
|
Sets whether or not this component is allowed to be visible. This method is meant to be used
by components to control visibility of other components. A call to
{@link #setVisible(boolean)} will not always have a desired effect because that component may
have {@link #isVisible()} overridden. Both {@link #setVisibilityAllowed(boolean)} and
{@link #isVisibilityAllowed()} are <code>final</code> so their contract is enforced always.
@param allowed
@return <code>this</code> for chaining
|
setVisibilityAllowed
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final boolean isVisibilityAllowed()
{
return getFlag(FLAG_VISIBILITY_ALLOWED);
}
|
Gets whether or not visibility is allowed on this component. See
{@link #setVisibilityAllowed(boolean)} for details.
@return true if this component is allowed to be visible, false otherwise.
|
isVisibilityAllowed
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final boolean determineVisibility()
{
return isVisible() && isRenderAllowed() && isVisibilityAllowed();
}
|
Determines whether or not a component should be visible, taking into account all the factors:
{@link #isVisible()}, {@link #isVisibilityAllowed()}, {@link #isRenderAllowed()}
@return <code>true</code> if the component should be visible, <code>false</code> otherwise
|
determineVisibility
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public boolean isEnabledInHierarchy()
{
if (getRequestFlag(RFLAG_ENABLED_IN_HIERARCHY_SET))
{
return getRequestFlag(RFLAG_ENABLED_IN_HIERARCHY_VALUE);
}
final boolean state;
Component parent = getParent();
if (parent != null && !parent.isEnabledInHierarchy())
{
state = false;
}
else
{
state = isEnabled() && isEnableAllowed();
}
setRequestFlag(RFLAG_ENABLED_IN_HIERARCHY_SET, true);
setRequestFlag(RFLAG_ENABLED_IN_HIERARCHY_VALUE, state);
return state;
}
|
Calculates enabled state of the component taking its hierarchy into account. A component is
enabled iff it is itself enabled ({@link #isEnabled()} and {@link #isEnableAllowed()} both
return <code>true</code>), and all of its parents are enabled.
@return <code>true</code> if this component is enabled</code>
|
isEnabledInHierarchy
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public final boolean isRendering()
{
return getFlag(FLAG_RENDERING);
}
|
Says if the component is rendering or not checking the corresponding flag.
@return true if this component is rendering, false otherwise.
|
isRendering
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public boolean canCallListenerInterface(Method method)
{
return isEnabledInHierarchy() && isVisibleInHierarchy();
}
|
Checks whether or not a listener method can be invoked on this component. Usually components
deny these invocations if they are either invisible or disabled in hierarchy. Components can
examine which listener interface is being invoked by examining the declaring class of the
passed in {@literal method} parameter.
<p>
WARNING: be careful when overriding this method because it may open security holes - such as
allowing a user to click on a link that should be disabled.
</p>
<p>
Example usecase for overriding: Suppose you are building an component that displays images.
The component generates a callback to itself using {@link IRequestListener} interface and
uses this callback to stream image data. If such a component is placed inside a disabled
webmarkupcontainer we still want to allow the invocation of the request listener callback
method so that image data can be streamed. Such a component would override this method and
return {@literal true} if the listener method belongs to {@link IRequestListener}.
</p>
@param method
listener method about to be invoked on this component. Could be {@code null} - in
this case it means <em>any</em> method.
@return {@literal true} iff the listener method can be invoked on this component
|
canCallListenerInterface
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
@Override
public void renderHead(IHeaderResponse response)
{
// noop
}
|
Render to the web response whatever the component wants to contribute to the head section.
@param response
Response object
|
renderHead
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public Component remove(final Behavior... behaviors)
{
Behaviors helper = new Behaviors(this);
for (Behavior behavior : behaviors)
{
helper.remove(behavior);
}
return this;
}
|
Removes behavior from component
@param behaviors
behaviors to remove
@return this (to allow method call chaining)
|
remove
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public Component add(final Behavior... behaviors)
{
new Behaviors(this).add(behaviors);
return this;
}
|
Adds a behavior modifier to the component.
@param behaviors
The behavior modifier(s) to be added
@return this (to allow method call chaining)
|
add
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/Component.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/Component.java
|
MIT
|
public static RequestListenerInterface forName(final String interfaceName)
{
return interfaces.get(interfaceName);
}
|
Looks up a request interface listener by name.
@param interfaceName
The interface name
@return The RequestListenerInterface object, or null if none is found
|
forName
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public Class<? extends IRequestListener> getListenerInterfaceClass()
{
return listenerInterfaceClass;
}
|
@return The interface class, which must extend IRequestListener.
|
getListenerInterfaceClass
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public boolean isIncludeRenderCount()
{
return includeRenderCount;
}
|
@return whether the render count should be included in url
|
isIncludeRenderCount
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public boolean isRenderPageAfterInvocation()
{
return renderPageAfterInvocation;
}
|
@return whether the page should be rendered after invocation of this interface (during
non-ajax requests)
|
isRenderPageAfterInvocation
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public final Method getMethod()
{
return method;
}
|
@return The method for this request listener interface
|
getMethod
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public final String getName()
{
return name;
}
|
@return The name of this request listener interface
|
getName
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public final void invoke(final IRequestableComponent rcomponent)
{
// we are in Wicket core land
final Component component = (Component)rcomponent;
ComponentContext.push(new ComponentContext(component));
try {
if (!component.canCallListenerInterface(method))
{
// just return so that we have a silent fail and just re-render the
// page
log.info("component not enabled or visible; ignoring call. Component: " + component);
throw new ListenerInvocationNotAllowedException(this, component, null,
"Component rejected interface invocation");
}
internalInvoke(component, component);
} finally {
ComponentContext.pop();
}
}
|
Invokes a given interface on a component.
@param rcomponent
The component
@throws ListenerInvocationNotAllowedException
when listener invocation attempted on a component that does not allow it
|
invoke
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public void register()
{
// Register this listener interface
registerRequestListenerInterface(this);
}
|
Method to call to register this interface for use
|
register
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
private void registerRequestListenerInterface(final RequestListenerInterface requestListenerInterface)
{
// Check that a different interface method with the same name has not
// already been registered
final RequestListenerInterface existingInterface = RequestListenerInterface.forName(requestListenerInterface.getName());
if (existingInterface != null)
{
if (existingInterface.getMethod().equals(requestListenerInterface.getMethod()) == false)
{
throw new IllegalStateException("Cannot register listener interface " +
requestListenerInterface +
" because it conflicts with the already registered interface " + existingInterface);
}
}
else
{
// Save this interface method by the non-qualified class name
interfaces.put(requestListenerInterface.getName(), requestListenerInterface);
log.info("registered listener interface " + this);
}
}
|
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
<p>
In previous versions of Wicket, request listeners were manually registered by calling this
method. Now there is a first class RequestListenerInterface object which should be
constructed as a constant member of the interface to enable automatic interface registration.
<p>
Adds a request listener interface to the map of interfaces that can be invoked by outsiders.
@param requestListenerInterface
The request listener interface object
|
registerRequestListenerInterface
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public static Collection<RequestListenerInterface> getRegisteredInterfaces()
{
return Collections.unmodifiableCollection(interfaces.values());
}
|
@return collection of all registered interfaces
|
getRegisteredInterfaces
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
|
MIT
|
public static Url getOriginalUrl()
{
Url originalUrl = null;
InterceptData data = InterceptData.get();
if (data != null)
{
originalUrl = data.getOriginalUrl();
}
return originalUrl;
}
|
@return the url of the request when the interception happened or {@code null}
or {@code null} if there was no interception yet
|
getOriginalUrl
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
|
MIT
|
protected boolean canBeHandled(final Url url)
{
List<String> segments = url.getSegments();
return (segments.size() >= 4 &&
urlStartsWith(url, getContext().getNamespace(), getContext().getResourceIdentifier()) &&
Strings.isEmpty(segments.get(3)) == false
);
}
|
Checks whether the passed Url can be handled by this mapper
@param url
the Url to check
@return {@code true} - if the Url can be handled, {@code false} - otherwise
|
canBeHandled
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java
|
MIT
|
protected PagingNavigator newPagingNavigator(final String navigatorId,
final DataTable<?, ?> table)
{
return new PagingNavigator(navigatorId, table);
}
|
Factory method used to create the paging navigator that will be used by the datatable
@param navigatorId
component id the navigator should be created with
@param table
dataview used by datatable
@return paging navigator that will be used to navigate the data table
|
newPagingNavigator
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigationToolbar.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigationToolbar.java
|
MIT
|
protected WebComponent newNavigatorLabel(final String navigatorId, final DataTable<?, ?> table)
{
return new NavigatorLabel(navigatorId, table);
}
|
Factory method used to create the navigator label that will be used by the datatable
@param navigatorId
component id navigator label should be created with
@param table
dataview used by datatable
@return navigator label that will be used to navigate the data table
|
newNavigatorLabel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigationToolbar.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigationToolbar.java
|
MIT
|
private Map<String, Object> addDefaultVars(Map<String, Object> params)
{
// create and fill the new params map
final HashMap<String, Object> fullParams;
if (params == null)
{
fullParams = new HashMap<>(6);
}
else
{
fullParams = new HashMap<>(params.size() + 6);
fullParams.putAll(params);
}
// add the input param if not already present
if (!fullParams.containsKey("input"))
{
fullParams.put("input", getInput());
}
// add the name param if not already present
if (!fullParams.containsKey("name"))
{
fullParams.put("name", getId());
}
// add the label param if not already present
if (!fullParams.containsKey("label"))
{
fullParams.put("label", getLabel());
}
return fullParams;
}
|
Creates a new params map that additionally contains the default input, name, label
parameters
@param params
original params map
@return new params map
|
addDefaultVars
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
private String getLabel()
{
final FormComponent<T> fc = FormComponent.this;
String label = null;
// first try the label model ...
if (fc.getLabel() != null)
{
label = fc.getLabel().getObject();
}
// ... then try a resource of format [form-component-id] with
// default of '[form-component-id]'
if (label == null)
{
label = fc.getDefaultLabel();
}
return label;
}
|
@return value of label param for this form component
|
getLabel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final String getDefaultLabel()
{
return getDefaultLabel(getId());
}
|
Gets the string the component would use as a label when one was requested but no label model
was set via {@link #getLabel()}. The value of this string is usually set in a property file;
if the value is not set the default value equivalent to component id will be returned.
@return localized label
|
getDefaultLabel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final String getDefaultLabel(String defaultValue)
{
return getLocalizer().getString(getId(), getParent(), defaultValue);
}
|
Gets the string the component would use as a label when one was requested but no label model
was set via {@link #getLabel()}. The value of this string is usually set in a property file;
if the value is not set the {@code defaultValue} will be returned.
@param defaultValue
@return localized label
|
getDefaultLabel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings({ "rawtypes", "unchecked" })
public final FormComponent<T> add(final IValidator<? super T> validator)
{
Args.notNull(validator, "validator");
if (validator instanceof Behavior)
{
add((Behavior)validator);
}
else
{
add((Behavior)new ValidatorAdapter(validator));
}
return this;
}
|
Adds a validator to this form component
@param validator
validator to be added
@return <code>this</code> for chaining
@throws IllegalArgumentException
if validator is null
@see IValidator
|
add
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings("unlikely-arg-type")
public final FormComponent<T> remove(final IValidator<? super T> validator)
{
Args.notNull(validator, "validator");
Behavior match = null;
for (Behavior behavior : getBehaviors())
{
if (behavior.equals(validator))
{
match = behavior;
break;
}
else if (behavior instanceof ValidatorAdapter)
{
if (((ValidatorAdapter<?>)behavior).getValidator().equals(validator))
{
match = behavior;
break;
}
}
}
if (match != null)
{
remove(match);
}
else
{
throw new IllegalStateException(
"Tried to remove validator that was not previously added. "
+ "Make sure your validator's equals() implementation is sufficient");
}
return this;
}
|
Removes a validator from the form component.
@param validator
validator
@throws IllegalArgumentException
if validator is null or not found
@see IValidator
@see #add(IValidator)
@return form component for chaining
|
remove
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SafeVarargs
public final FormComponent<T> add(final IValidator<? super T>... validators)
{
Args.notNull(validators, "validators");
for (IValidator<? super T> validator : validators)
{
add(validator);
}
// return this for chaining
return this;
}
|
Adds a validator to this form component.
@param validators
The validator(s) to be added
@return This
@throws IllegalArgumentException
if validator is null
@see IValidator
|
add
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public boolean checkRequired()
{
if (isRequired())
{
final String input = getInput();
// when null, check whether this is natural for that component, or
// whether - as is the case with text fields - this can only happen
// when the component was disabled
if (input == null && !isInputNullable() && !isEnabledInHierarchy())
{
// this value must have come from a disabled field
// do not perform validation
return true;
}
// perform validation by looking whether the value is null or empty
return !Strings.isEmpty(input);
}
return true;
}
|
Checks if the form component's 'required' requirement is met by first checking
{@link #isRequired()} to see if it has to check for requirement. If that is true then by
default it checks if the input is null or an empty String
{@link Strings#isEmpty(CharSequence)}
<p>
Subclasses that overwrite this method should also call {@link #isRequired()} first.
</p>
@return true if the 'required' requirement is met, false otherwise
@see Strings#isEmpty(CharSequence)
@see #isInputNullable()
|
checkRequired
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public void error(IValidationError error)
{
Args.notNull(error, "error");
MessageSource source = new MessageSource();
Serializable message = error.getErrorMessage(source);
if (message == null)
{
StringBuilder buffer = new StringBuilder();
buffer.append("Could not locate error message for component: ");
buffer.append(Classes.simpleName(getClass()));
buffer.append("@");
buffer.append(getPageRelativePath());
buffer.append(" and error: ");
buffer.append(error.toString());
buffer.append(". Tried keys: ");
Iterator<String> keys = source.triedKeys.iterator();
while (keys.hasNext())
{
buffer.append(keys.next());
if (keys.hasNext())
{
buffer.append(", ");
}
}
buffer.append('.');
message = buffer.toString();
logger.warn(message.toString());
}
error(message);
}
|
Reports a validation error against this form component.
The actual error is reported by creating a {@link ValidationErrorFeedback} object that holds
both the validation error and the generated error message - so a custom feedback panel can
have access to both.
@param error
validation error
|
error
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final T getConvertedInput()
{
return convertedInput;
}
|
Gets the converted input. The converted input is set earlier though the implementation of
{@link #convertInput()}.
{@link FormComponentPanel} often access this method when constructing their converted input
value which is often the combination of converted values of the embedded FormComponents
To access the model object resulted by the full form processing, use
{@link #getModelObject()} instead, that is an generified version of
{@link #getDefaultModelObject()}
@return value of input possibly converted into an appropriate type
|
getConvertedInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final void setConvertedInput(T convertedInput)
{
this.convertedInput = convertedInput;
}
|
Sets the converted input. This method is typically not called by clients, unless they
override {@link #convertInput()}, in which case they should call this method to update the
input for this component instance.
@param convertedInput
the converted input
|
setConvertedInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public Form<?> getForm()
{
Form<?> form = Form.findForm(this);
if (form == null)
{
throw new WicketRuntimeException("Could not find Form parent for " + this);
}
return form;
}
|
@return The parent form for this form component
|
getForm
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public String getInput()
{
String[] input = getInputAsArray();
if (input == null || input.length == 0)
{
return null;
}
else
{
return trim(input[0]);
}
}
|
Gets the request parameter for this component as a string.
@return The value in the request for this component
|
getInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public String[] getInputAsArray()
{
List<StringValue> list = getParameterValues(getInputName());
String[] values = null;
if (list != null)
{
values = new String[list.size()];
for (int i = 0; i < list.size(); ++i)
{
values[i] = list.get(i).toString();
}
}
if (!isInputNullable())
{
if (values != null && values.length == 1 && values[0] == null)
{
// we the key got passed in (otherwise values would be null),
// but the value was set to null.
// As the servlet spec isn't clear on what to do with 'empty'
// request values - most return an empty string, but some null -
// we have to workaround here and deliberately set to an empty
// string if the the component is not nullable (text components)
return EMPTY_STRING_ARRAY;
}
}
return values;
}
|
Gets the request parameters for this component as strings.
@return The values in the request for this component
|
getInputAsArray
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected List<StringValue> getParameterValues(String inputName)
{
String method = Form.METHOD_POST;
final Request request = getRequest();
if (getRequest().getContainerRequest() instanceof HttpServletRequest)
{
method = ((HttpServletRequest)getRequest().getContainerRequest()).getMethod();
}
else
{
final Form<?> form = findParent(Form.class);
if (form != null)
{
method = form.getMethod();
}
}
final IRequestParameters parameters;
switch (method.toLowerCase(Locale.ROOT))
{
case Form.METHOD_POST:
parameters = request.getPostParameters();
break;
case Form.METHOD_GET:
parameters = request.getQueryParameters();
break;
default:
parameters = EmptyRequestParameters.INSTANCE;
}
return parameters.getParameterValues(inputName);
}
|
Reads the value(s) of the request parameter with name <em>inputName</em>
from either the query parameters for <em>GET</em> method or the request body
for <em>POST</em> method.
@param inputName
The name of the request parameter
@return The parameter's value(s)
|
getParameterValues
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public String getInputName()
{
String inputName = Form.getRootFormRelativeId(this);
Form<?> form = findParent(Form.class);
if (form != null)
{
return form.getInputNamePrefix() + inputName;
}
else
{
return inputName;
}
}
|
Gets the string to be used for the <tt>name</tt> attribute of the form element. Generated
using the path from the form to the component, excluding the form itself. Override it if you
want even a smaller name. E.g. if you know for sure that the id is unique within a form.
@return The string to use as the form element's name attribute
|
getInputName
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final String getRawInput()
{
return NO_RAW_INPUT.equals(rawInput) ? null : rawInput;
}
|
Use hasRawInput() to check if this component has raw input because null can mean 2 things: It
doesn't have rawinput or the rawinput is really null.
@return The raw form input that is stored for this formcomponent
|
getRawInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings("unchecked")
public final Class<T> getType()
{
return typeName == null ? null : (Class<T>)WicketObjects.resolveClass(typeName);
}
|
@return the type to use when updating the model for this form component
|
getType
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public String getValidatorKeyPrefix()
{
Form<?> form = findParent(Form.class);
if (form != null)
{
return getForm().getValidatorKeyPrefix();
}
return null;
}
|
@see Form#getValidatorKeyPrefix()
@return prefix used when constructing validator key messages
|
getValidatorKeyPrefix
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings("unchecked")
public final List<IValidator<? super T>> getValidators()
{
final List<IValidator<? super T>> list = new ArrayList<>();
for (Behavior behavior : getBehaviors())
{
if (behavior instanceof IValidator)
{
list.add((IValidator<? super T>)behavior);
}
}
return Collections.unmodifiableList(list);
}
|
Gets an unmodifiable list of validators for this FormComponent.
@return List of validators
|
getValidators
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final String getValue()
{
if (NO_RAW_INPUT.equals(rawInput))
{
return getModelValue();
}
else
{
if (getEscapeModelStrings() && rawInput != null)
{
return Strings.escapeMarkup(rawInput).toString();
}
return rawInput;
}
}
|
Gets current value for a form component, which can be either input data entered by the user,
or the component's model object if no input was provided.
@return The value
|
getValue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final boolean hasRawInput()
{
return !NO_RAW_INPUT.equals(rawInput);
}
|
Returns whether this component has raw input. Raw input is unconverted input straight from
the client.
@return boolean whether this component has raw input.
|
hasRawInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final void inputChanged()
{
if (isVisibleInHierarchy() && isEnabledInHierarchy())
{
// Get input as String array
final String[] input = getInputAsArray();
// If there is any input
if (input != null && input.length > 0 && input[0] != null)
{
// join the values together with ";", for example, "id1;id2;id3"
rawInput = StringList.valueOf(input).join(VALUE_SEPARATOR);
}
else if (isInputNullable())
{
// no input
rawInput = null;
}
else
{
rawInput = NO_RAW_INPUT;
}
}
}
|
Used by Form to tell the FormComponent that a new user input is available
|
inputChanged
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final void invalid()
{
onInvalid();
}
|
Indicate that validation of this form component failed.
|
invalid
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public boolean isInputNullable()
{
return true;
}
|
Gets whether this component's input can be null. By default, components that do not get input
will have null values passed in for input. However, component TextField is an example
(possibly the only one) that never gets a null passed in, even if the field is left empty
UNLESS it had attribute <code>disabled="disabled"</code> set.
@return True if this component's input can be null. Returns true by default.
|
isInputNullable
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public boolean isRequired()
{
return getFlag(FLAG_REQUIRED);
}
|
@return whether or not this component's value is required
|
isRequired
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.