Module wicket.bootstrap.core
Class CodeBehavior
java.lang.Object
org.apache.wicket.behavior.Behavior
de.agilecoders.wicket.core.markup.html.bootstrap.block.CodeBehavior
- All Implemented Interfaces:
Serializable,IComponentAwareEventSink,IComponentAwareHeaderContributor,IClusterable
#### Description
Wrap inline snippets of code with
and use for multiple
lines of code. Angle brackets will be escaped in the code for proper rendering.
#### Usage
```java
component.add(new CodeBehavior()
.setShowLineNumbers(true) // whether to show line numbers or not
.setLanguage(Language.JAVA) // use java as code language; default is dynamic
.setStartFromLine(20)); // hide first 20 lines
```
```html
<code wicket:id="id">content</code>
```
It's possible to use `pre`, `code` and `xmp` as tag name.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumenum that holds all possible languages -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidfinal booleanvoidonComponentTag(Component component, ComponentTag tag) voidonConfigure(Component component) voidrenderHead(Component component, IHeaderResponse response) final CodeBehaviorsetLanguage(CodeBehavior.Language language) sets the language.final CodeBehaviorsetShowLineNumbers(boolean showLineNumbers) adds line numbers on the left side of code block.final CodeBehaviorsetStartFromLine(int from) defines from which line number the counting will start.voidMethods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, canCallListener, getStatelessHint, isEnabled, isTemporary, onAttribute, onEvent, onException, onRemove, onTag
-
Constructor Details
-
CodeBehavior
public CodeBehavior()Constructor.
-
-
Method Details
-
detach
-
renderHead
- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classBehavior
-
bind
-
unbind
-
onConfigure
- Overrides:
onConfigurein classBehavior
-
hasLineNumbers
public final boolean hasLineNumbers()- Returns:
- true, if line numbers will be rendered
-
setShowLineNumbers
adds line numbers on the left side of code block.- Returns:
- this instance
-
setStartFromLine
defines from which line number the counting will start.- Parameters:
from- which line the numbers will count- Returns:
- this instance
-
setLanguage
sets the language.- Parameters:
language- the language to use- Returns:
- this instance
-
onComponentTag
- Overrides:
onComponentTagin classBehavior
-