The ContentPanel class implements a control that is used to display arbitrary XHTML content. The content panel can either be foldable (allows users to toggle it open and close) or static. Like all controls the content panel has an optional caption. But unlike for other controls, this caption area is an interactive area that can be used to expand and collapse a foldable content panel. Thus, foldable content panel should always have captions.
ExpandedStateChanged
This event is fired when the expanded state of the content area has changed.
[ContentPanel] new ContentPanel(String id, String caption, String content, Boolean foldable, Boolean expanded)
Creates a new instance of the ContentPanel class.
id
Unique identifier for the control. Can be retrieved using the id property defined in the UIElement class that this control inherits from. Useful for example to identify the source of an event in event callback functions or to apply a CSS rule to only this particular control. The identifier can be null, in which case no id will be set for the control.
caption
The caption text for the control. A null caption can be used to hide the caption area. This is not recommended if the content panel is folding since users cannot expand or collapse a foldable content panel without the caption area being present.
content
The content for the panel. If the argument is omitted or null then the content area will be empty.
foldable
Specifies the foldability of the content panel. Specify true to make the content panel foldable and false to make it static. If the argument is omitted or null then the content panel will default to being static.
expanded
Specifies the expanded state of a foldable content panel. Specify true to make the content panel expanded and false to make it collapse. If the argument is omitted or null then the content panel will default to being expanded.
A new instance of the ContentPanel class.
Creating a foldable content panel with content:
var panel1 = new ContentPanel("panel1", "Example Panel", "This is some content");
Creating a static content panel with content:
var panel2 = new ContentPanel("panel2", "Example Panel", "This is some content", false);
Creating a foldable content panel and given it content in a separate step:
var panel3 = new ContentPanel("panel3", "Example Panel"); panel3.setContent("This is some content");
[String] ContentPanel.getContent(void)
Retrieves the current content (an XHTML fragment) of the content panel.
This method does not take any arguments.
The current content of the content area.
[void] ContentPanel.setContent(String content)
Sets the content for the content panel as a fragment of XHTML. If null is specified as the content then the content area will be empty.
content
A fragment of XHTML to set as content for the content area of the content panel. A null value can be used to make the content area empty.
This method does not return a value.
[Boolean] ContentPanel.isExpanded(void)
Retrieves the expanded state of the content area.
This method does not take any arguments.
The current expanded state of the content area; true if expanded, false if collapsed.
[void] ContentPanel.setExpanded(Boolean state)
Sets the expanded state of the content area for a foldable content panel.
state
The new expanded state for the content area; true to expand, false to collapse.
This method does not return a value.
[HTMLElement] ContentPanel.contentElement
The contentElement property allows direct access to the content of a content panel. Typically content is set to a content panel using the setContent() method, passing it an XHTML fragment as a string but if DOM methods are preferred then the contentElement can be used as a root HTML element to attach content to, e.g. using the DOM appendChild() method.