Class Component<T extends Component<?>>
- Type Parameters:
T
- The component type
- Direct Known Subclasses:
ActivityStream
,ActivityStreamItem
,Badge
,BaseFilter
,Blockquote
,Breadcrumb
,Breadcrumb.BreadcrumdList
,Button
,Calendar
,Card
,CardAccordion
,CardBody
,CardDeck
,CardFooter
,CardGroup
,CardHeader
,ChartCanvas
,CodeViewer
,Column
,Container
,ContextMenu
,Counter
,Div
,DropDownButton
,DropDownButton.DropDownMenuItem
,FileMiniature
,Form
,FormBlock
,FormColumn
,FormItem
,Header
,HorizontalSplitter
,HTMLFlow
,IBox
,Image
,Link
,ListBox
,ListGrid
,ListItem
,LoadButton
,MenuBar
,MenuBarBrand
,ModalWindow
,ModalWindow.ModalFooter
,ModalWindow.ModalHeader
,NavBar
,NavBarFooterButton
,NavBarFooterButtonPopup
,Paragraph
,ProcessIndicator
,ProgressBar
,Row
,SelectorWindow
,SeriesTitle
,Small
,Span
,Sparkline
,StaticText
,Tab
,TabHeader
,Table
,TableCell
,TableHeader
,TableRow
,TabPage
,Timeline
,TimelineItem
,Toolbar
,Treeview
,VerticalSplitter
,VideoBox
,Wizard
,Wizard.WizardFooter
,WizardStep
,xData
,yData
,zData
The component base class
Every component must extend from this class. This class ensures the basic operations of every component, for example, the drawing process, authorization handling, etc.
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Modifier and TypeFieldDescriptionprotected Animation
protected Color
protected Color
protected Color
protected HotKeyEventHandler
protected Map<EventType,
List<BrowserEventHandler>> protected Map<Integer,
HotKeyEventHandler> protected TextAlign
protected String
protected ToolTipPosition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected T
_hide()
protected T
_setAttribute
(String name, Object value) addAllowedRole
(String roleCode) Adds the specified role to have access to the component.addComponent
(Component<?> component) Adds the specified component as a subcomponent, and redraws the component immediatelyprotected T
addComponent
(Component<?> component, boolean draw) Adds the specified component as a subcomponentaddComponents
(Component<?>... components) Adds multiple components to the componentaddDeniedRole
(String roleCode) Denies access to the component to the specified role.protected final T
addHandler
(EventType eventType, Object handler) final T
addStyle
(StyleElement... styles) Adds a style element to the component.addStyleClass
(String styleClass) Adds the specified CSS class to the componentaddStyleClasses
(String... styleClasses) Adds the specified style classes to the componentvoid
The operations to be executed after the drawing of the componentclearfix
(boolean clearfix) Removes all float settings.protected final String
Closes the specified HTML tagprotected T
combinateAccess
(com.jbstrap.ui.Access parentAccess) boolean
containsStyle
(StyleElement style) Checks if the specified style element is included in the component.boolean
containsStyleClass
(String styleClass) Determines if the specified style class has been assigned to the component.final String
draw
(StringWriter writer) drawSubComponents
(StringWriter writer) Draws the component's subcomponentsfinal T
Shows the specified error message on the client that has the component currently displayed.protected com.jbstrap.ui.Access
Gets the component's access mode.Gets a list of the allowed roles (Roles that have access)final Object
getAttribute
(String name) Gets an HTML Attribute value from the component.Gets the HTML attributes of the componentGets the component�s background color.Gets the component�s border color.final Client
Gets the client, that currently has the component displayed.Component<?>
Gets the specified component.Gets every previously added subcomponentgetComponents
(Predicate<Component<?>> filter) Gets a list of components, according to the specified predicate.final <E> List<E>
getComponentsByClass
(Class<E> clazz) Gets the components, that are specified by class.final Object
getData()
Gets the previously set custom dataGets a list of the denied roles (Roles that do not have access)final List<BrowserEventHandler>
getHandlers
(EventType eventType) Gets the handlers of the specified event typegetId()
Gets the component's IDGets the component's language code.getName()
Gets the component name.final Object
Gets the component's parent component<E> E
Gets the first parent component of the component, according to the specified class.Gets the specified inline style elementGets a list of every style class that was assigned to the component.Gets the component�s text color.Gets the text of the component's tooltipGets the tooltip positionprotected final String
Gets the component namefinal UI
getUI()
Gets theUI
, where the component is currently.void
init()
The component initialization method.insertComponentAfter
(Component<?> component) Inserts the specified component after the componentinsertComponentBefore
(Component<?> component) Inserts the specified component before the componentboolean
Determines if the specified role has access to the component.boolean
isDrawn()
Determines if the component is drawn on the client.boolean
Determines if the component is enabled.boolean
boolean
Determines the component visibilityvoid
onHide()
The operations to be executed after the component is hidden on the clientprotected void
onHotKeyEventHandler
(HotKeyEvent event) void
onShow()
The operations to be executed after the component is displayed on the clientprotected final String
Opens the specified HTML tag during the drawing of the component.redraw()
Redraws the component.Removes every subcomponent from the componentremoveAllowedRole
(String roleCode) Removes access from the previously added role.Removes every specified style class from the componentfinal T
removeAttribute
(String name) Removes the specified HTML attribute from the componentremoveComponent
(Component<?> component) Removes the specified subcomponent.removeComponent
(Predicate<Component<?>> filter) Removes the specified component(s), according to the specified predicate.removeComponents
(Component<?>... components) Removes the specified components.removeDeniedRole
(String roleCode) Removes the specified role from the denied roles.final T
removeHandler
(EventType eventType, Object handler) Removes the specified handler from the component.final T
removeStyle
(StyleElement... styles) Removes a style element from the component.final T
removeStyle
(String attributeName) Removes the specified style element from the inline styleremoveStyleClass
(String styleClass) Removes the specified style class from the componentremoveStyleClasses
(String... styleClasses) Removes the specified style classes from the componentreplaceComponent
(Component<?> oldComponent, Component<?> newComponent) Replaces a previously added subcomponent with the specified new subcomponent.replaceStyleClass
(String oldStyleClass, String newStyleClass) Replaces a previously placed CSS style class.protected void
final T
runJavaScript
(String javaScript) Runs the specified JavaScript on the client, that has the component currently displayed.final T
runJavaScript
(String... javaScripts) Runs the specified JavaScript on the client, that has the component currently displayed.final T
runJavaScript
(List<String> javaScripts) Runs the specified JavaScripts on the client, that has the component currently displayed.protected void
Runs every on hide method of the component and subcomponentsprotected void
final T
setAttribute
(String name, Object value) Sets an HTML attribute on the component.setBackgroundColor
(Color color) Sets the component�s background color.Sets the component�s border.setBorderColor
(Color color) Sets the border color for the component.final T
Sets custom data on the componentsetDisplayType
(DisplayType... displayType) Set how the component is displayedsetEnabled
(boolean enabled) Sets the component to be enabled.setEventBubbling
(boolean bubbling) Flexible component display setting for all screen sizes.setFloating
(FloatingType... floating) Component float settings.Sets the component height to 100%.Sets the component height to 25%.Sets the component height to 50%.Sets the component height to 75%.Automatically sets the component's height.protected T
setLanguage
(String language) Sets the component language.Component margin settings.Sets the name of the component (name HTML attribute)setOverflow
(Boolean overflow) Sets if scrolling is enabled in the component.setPadding
(Padding... paddings) Sets the component padding.final T
setScrollable
(Boolean scrollable) Sets if scrolling is enabled in the component.Sets the content selection types (of how users can select content elements).Sets the component shadow.final T
Sets an Inline style on the componentsetTextAlign
(TextAlign textAlign) setTextColor
(Color color) Sets the text color for the component.setToolTip
(String toolTip) Sets the text of the component's tooltipsetToolTipPosition
(ToolTipPosition toolTipPosition) Sets the tooltip position.setVisible
(boolean visible) Sets the visibility of the component.Sets the component width to 100%.Sets the component width to 25%.Sets the component width to 50%.Sets the component width to 75%.Automatically sets the component's width.final T
showNotification
(NotificationType notificationType, String title) Shows the specified notification on the client that has the component currently displayed.final T
showNotification
(NotificationType notificationType, String title, String message) Shows the specified notification on the client that has the component currently displayed.protected final T
showProcessIndicator
(boolean show) Sets the Process Indicator to be shown or hidden on the client.toggleStyleClass
(String styleClass) Removes or adds a style class to/from the component.abstract boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
-
Field Details
-
color
-
backgroundColor
-
borderColor
-
textAlign
-
attributes
-
styleClasses
-
toolTip
-
toolTipPosition
-
animation
-
handlers
-
hotKeys
-
defaultHotKeyHandler
-
-
Constructor Details
-
Component
Creates a new component with the specified language.- Parameters:
language
- The client language code. If specified asnull
, the component will use the default language. The default language is set in theDEFAULT_LANGUAGE_CODE
JBStrap parameter- Throws:
IllegalStateException
- If the component is set to be both Private and Public.
-
Component
Creates a new component with the specified language.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)language
- The client language code. If specified asnull
, the component will use the default language. The default language is set in theDEFAULT_LANGUAGE_CODE
JBStrap parameter- Throws:
IllegalStateException
- If the component is set to be both Private and Public.
-
-
Method Details
-
getTypeName
Gets the component name- Returns:
- Component type name
-
addAllowedRole
Adds the specified role to have access to the component. If the specified role is among the denied roles, it will not be overwritten, and the role won't have access to the component- Parameters:
roleCode
- The code of the role to be granted access- Returns:
- The component
-
removeAllowedRole
Removes access from the previously added role. If the role was given access through an annotation, it won't be removed.- Parameters:
roleCode
- The code of the role to be removed- Returns:
- The component
-
addDeniedRole
Denies access to the component to the specified role. If this role is among those that have access, and that access was granted through the program, it's access will be revoked, and it will be to the denied roles. If the role was assigned through an annotation, it won't be added to the denied roles, and it will still have access to the component.- Parameters:
roleCode
- The code of the role to be denied.- Returns:
- The component
-
removeDeniedRole
Removes the specified role from the denied roles. If the role was added to the component through an annotation, or was assigned through an annotation, it won't be removed.- Parameters:
roleCode
- The code of the role to be removed- Returns:
- The component
-
getAccessMode
Gets the component's access mode.- Returns:
- The component's access mode. The modes can be found in the
AccessMode
enum. If the access mode wasn't defined, it will return withnull
.
-
getAllowedRoles
Gets a list of the allowed roles (Roles that have access)- Returns:
- A list containing the role codes that are allowed, or
null
, if the component doesn't have any roles assigned.
-
getDeniedRoles
Gets a list of the denied roles (Roles that do not have access)- Returns:
- A list containing the role codes that are denied, or
null
, if the component doesn't have any roles assigned.
-
getAccess
protected com.jbstrap.ui.Access getAccess()- Returns:
- The combined access or
null
, if the component hierarchy is not done yet.
-
combinateAccess
- Parameters:
parentAccess
- The parent component's combined access- Returns:
- The component
- Throws:
IllegalStateException
- If the parent component was already specified, but it's combined access isnull
-
isAccess
Determines if the specified role has access to the component.- Parameters:
role
- The role code ornull
, if there isn't a logged in user, or if the user has no roles assigned to it.- Returns:
true
, if the user has access, otherwisefalse
-
setLanguage
Sets the component language.- Parameters:
language
- The language code- Returns:
- The component
-
setAttribute
Sets an HTML attribute on the component. If the attribute was already assigned, the attribute will be overwritten. If the attribute value is specified asnull
, the attribute will be removed.- Parameters:
name
- The attribute namevalue
- The attribute value- Returns:
- The component
-
getAttributes
Gets the HTML attributes of the component- Returns:
- A map containing the HTML attributes of the component. If the component has no HTML attributes, the map will be empty
-
_setAttribute
- Parameters:
name
- The attribute namevalue
- The attribute value- Returns:
- The component
-
getAttribute
Gets an HTML Attribute value from the component. If not found, returns with null.- Parameters:
name
- The name of the attribute- Returns:
- The attribute value or
null
, if not found
-
setName
Sets the name of the component (name HTML attribute)- Parameters:
name
- The component name- Returns:
- The component
-
getName
Gets the component name.- Returns:
- The component name or
null
, if no name was set
-
removeAttribute
Removes the specified HTML attribute from the component- Parameters:
name
- The attribute name- Returns:
- The component
-
addStyleClass
Adds the specified CSS class to the component- Parameters:
styleClass
- The name of the CSS style class- Returns:
- The component
-
replaceStyleClass
Replaces a previously placed CSS style class. If the original class is not found, the new one still gets added to the component.- Parameters:
oldStyleClass
- The name old style class that will be replaced (removed)newStyleClass
- The name new style class- Returns:
- The component
-
getStyleClasses
Gets a list of every style class that was assigned to the component.- Returns:
- A list of the style classes. If none were assigned to the component, the list will be empty.
-
toggleStyleClass
Removes or adds a style class to/from the component. If the specified class is already on the component, it gets removed, if it does not, it gets added to the component.- Parameters:
styleClass
- The name of the style class- Returns:
- The component
-
containsStyleClass
Determines if the specified style class has been assigned to the component.- Parameters:
styleClass
- The name of the style class- Returns:
true
if it is assigned, otherwisefalse
-
addStyleClasses
Adds the specified style classes to the component- Parameters:
styleClasses
- The name of the style classes- Returns:
- The component
-
removeStyleClass
Removes the specified style class from the component- Parameters:
styleClass
- The name of the style class- Returns:
- The component
-
removeStyleClasses
Removes the specified style classes from the component- Parameters:
styleClasses
- The name of the style classes- Returns:
- The component
-
removeAllStyleClasses
Removes every specified style class from the component- Returns:
- The component
-
getId
Gets the component's ID- Returns:
- The component ID
-
removeComponent
Removes the specified subcomponent.- Parameters:
component
- The component instance- Returns:
- The component
-
replaceComponent
Replaces a previously added subcomponent with the specified new subcomponent. The new component will be in the place of the old one, meaning the order of the components won't change.- Parameters:
oldComponent
- The to be replaced component.newComponent
- The new component- Returns:
- The component
-
removeComponents
Removes the specified components.- Parameters:
components
- The components that will be removed- Returns:
- The component
-
removeAllComponents
Removes every subcomponent from the component- Returns:
- The component
-
removeComponent
Removes the specified component(s), according to the specified predicate.- Parameters:
filter
- The filter for the removal- Returns:
- The component
-
addComponent
Adds the specified component as a subcomponent, and redraws the component immediately- Parameters:
component
- The component to be added- Returns:
- The component
-
addComponent
Adds the specified component as a subcomponent- Parameters:
component
- The component to be addeddraw
- Determines if the component will be redrawn immediately. Iftrue
, it will be redrawn, iffalse
, it won't be. This means the component will be drawn after other components are added to it, or it has to be drawn manually, with the redraw method, so the newly added components will appear.- Returns:
- The component
-
insertComponentAfter
Inserts the specified component after the component- Parameters:
component
- The component to be added- Returns:
- The component
-
insertComponentBefore
Inserts the specified component before the component- Parameters:
component
- The component to be added- Returns:
- The component
-
runAfterDraw
protected void runAfterDraw() -
runOnShow
protected void runOnShow() -
runOnHide
protected void runOnHide()Runs every on hide method of the component and subcomponents -
addComponents
Adds multiple components to the component- Parameters:
components
- The instances of the new, to be added components- Returns:
- The component
-
getComponents
Gets every previously added subcomponent- Returns:
- A collection of every subcomponent that was added to the component. If there are none, the collection will be empty
-
flattendComponentTree
-
getComponentById
Gets the specified component. It can be specified by its ID. If it has subcomponents, the method will look among the subcomponets too.- Parameters:
id
- The component id- Returns:
- If found, returns with the component instance. If not, returns with
null
-
getParent
Gets the component's parent component- Returns:
- The parent component instance
-
setParent
- Parameters:
parent
- The parent component, or UI instance- Returns:
- The component
-
getUI
Gets theUI
, where the component is currently. If the component isn't drawn yet, the UI won't be found, and the method will return withnull
.- Returns:
- The UI instance, where the component is currently on. If the component isn't currently drawn,
it will return with
null
.
-
getComponentsByClass
Gets the components, that are specified by class. If they have subcomponents, the method will look among the subcomponets too.- Type Parameters:
E
- The component type- Parameters:
clazz
- The class that will be used as a reference for the operation- Returns:
- A list containing the component instances. If none was found, the list will be empty.
- Throws:
NullPointerException
- If the specified class isnull
-
getComponents
Gets a list of components, according to the specified predicate. If they have subcomponents, the method will look among the subcomponets too. This means that the list may contain components, that are not the component's direct subcomponent, but are subcomponents of a direct subcomponent.- Parameters:
filter
- The predicate filter- Returns:
- A list containing the components that meets the specified conditions. If there are none, the list will be empty
-
setEnabled
Sets the component to be enabled. Defaults totrue
- Parameters:
enabled
-true
, the component is enabled, otherwise it's disabled- Returns:
- The component
-
isEnabled
public boolean isEnabled()Determines if the component is enabled.- Returns:
true
if it's enabled, otherwisefalse
-
openTag
Opens the specified HTML tag during the drawing of the component. The opened tag will contain the previously added component attributes, style classes and the unique id.
This method doesn't need to be used during application development. This method is used when developing a custom component.
- Parameters:
tag
- The HTML tag that will be opened (ie: div, table, etc.)- Returns:
- The full HTML string, that opens the specified tag
-
closeTag
Closes the specified HTML tag
This method doesn't need to be used during application development. This method is used when developing a custom component.
- Parameters:
tag
- The HTML tag to be closed- Returns:
- The full HTML string, that closes the specified tag
-
drawSubComponents
Draws the component's subcomponents
This method doesn't need to be used during application development. This method is used when developing a custom component.
- Parameters:
writer
- The HTML string writer StringWriter instance. This is where the subcomponent's HTML string is written.- Returns:
- The component
-
addHandler
- Parameters:
eventType
- The event type. For a list of types, see theEventType
enum.handler
- The event handler implementation.- Returns:
- The component
- Throws:
NullPointerException
- If the specified event type isnull
-
getHandlers
Gets the handlers of the specified event type- Parameters:
eventType
- The event type. For a list of types, see theEventType
enum.- Returns:
- A list containing the handlers, or
null
if no applicable handlers were found.
-
removeHandler
Removes the specified handler from the component.- Parameters:
eventType
- The event type, that will have the handler removed from. For a list of types, see theEventType
enum.handler
- The event handler implementation- Returns:
- The component
-
getToolTip
Gets the text of the component's tooltip- Returns:
- The tooltip text, if it was previously set. If not, it will return with
null
-
setToolTip
Sets the text of the component's tooltip- Parameters:
toolTip
- The tooltip text- Returns:
- The component
-
getToolTipPosition
Gets the tooltip position- Returns:
- The tooltip position
-
setToolTipPosition
Sets the tooltip position. It can be placed around the component. The placement can also be automatic. If automatic, the tooltip will appear where it will have the most free space, and where it will be able to be fully visible. By default, the tooltip position is set to be automatic.- Parameters:
toolTipPosition
- The tooltip position. If specified asnull
the position will be automatic. For a list of the applicable positions, see theToolTipPosition
enum.- Returns:
- The component
-
setVisible
Sets the visibility of the component. If not visible, the component won't appear on the interface, but it will be drawn in the HTML DOM. The visibility can be set anytime through code. By default, the component is visible- Parameters:
visible
- Iftrue
, the component is visible, iffalse
, it is hidden- Returns:
- The component
-
isVisible
public boolean isVisible()Determines the component visibility- Returns:
true
if visible, otherwisefalse
-
setData
Sets custom data on the componentEvery component can have custom data. The data specified here, can be any object instance. This means that a complex data structure can be stored within the component. This data isn't used, handled, or modified by the framework, and the data is available during the component's life cycle. The data is only accessible on the server side.
The component can only have one of this custom data added to it. If data was already assigned, it will be overwritten by the newly assigned data.
- Parameters:
data
- The custom data to be set- Returns:
- The component
-
getData
Gets the previously set custom data- Returns:
- The previously set custom data or
null
if none was set.
-
redraw
Redraws the component.All changes on the components, (even after drawing) are applied automatically. So for this reason, the components don't have to be redrawn. However, sometimes it is necessary to redraw the entire component. If this method is used, the component and all of its subcomponents will be re-sent to the client-side and the components will be re-initialized, a process that can take a significant amount of time, not to mention burden the communication channels. The use of this method for these reasons is not recommended.
- Returns:
- The component
-
getParent
Gets the first parent component of the component, according to the specified class. The defined parent class may not be the direct parent of the current component,- Type Parameters:
E
- The component type- Parameters:
clazz
- The class that will be used as a reference for the operation- Returns:
- The parent class instance or
null
if none are found
-
afterDraw
public void afterDraw()The operations to be executed after the drawing of the componentBy default, this is an empty method. It has to be overwritten on a component or page if additional operations have to be executed after the drawing process. One such operation is data retrieval, which shouldn't run in constructors so that the user could see results of an operation or navigation process.
-
onShow
public void onShow()The operations to be executed after the component is displayed on the clientBy default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is displayed. This method is nearly identical to the afterDraw() method, they differ in when they are executed. This method runs after the component is displayed on the client. Meaning that it is executed even if the component isn't redrawn, but only set to be visible after being hidden.
-
onHide
public void onHide()The operations to be executed after the component is hidden on the clientBy default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is hidden.
-
getRegisteredEvents
- Returns:
- A list of every event type that is registered to the component. If there are none, the list will be empty.
-
setStyle
Sets an Inline style on the component- Parameters:
attributeName
- The name of the inline style element (CSS key). If one was set previously, it will be overwritten.value
- The style element value (CSS value)- Returns:
- The component
-
addStyle
Adds a style element to the component.- Parameters:
styles
- Style element- Returns:
- Component
-
removeStyle
Removes a style element from the component.- Parameters:
styles
- Style element- Returns:
- Component
-
containsStyle
Checks if the specified style element is included in the component.- Parameters:
style
- Style element- Returns:
- If
true
, the specified style element is included in the component, otherwisefalse
-
removeStyle
Removes the specified style element from the inline style- Parameters:
attributeName
- The name of the inline style element (CSS key).- Returns:
- The component
-
getStyle
Gets the specified inline style element- Parameters:
attributeName
- The name of the inline style element(CSS key).- Returns:
- The style element value or
null
if not found
-
_hide
- Returns:
- The component
-
getClient
Gets the client, that currently has the component displayed.- Returns:
- The instance of the client that has the component displayed.
If the component isn't displayed, it will return with
null
-
runJavaScript
Runs the specified JavaScript on the client, that has the component currently displayed. If the component isn't displayed, the specified JavaScript will not be executed.The specified JavaScript won't run instantly. These instructions are first collected by the framework, and then when the current thread is finished, they will be sent to the client in a package, and then they will be executed. The execution order is the same as they were added, this is guaranteed by the framework.
Warning: If a package contains an illegal instruction, the execution of the package will stop after the first error. This error will be recorded to the browser's console, and the server log.
- Parameters:
javaScript
- The JavaScript to be executed- Returns:
- The component
-
runJavaScript
Runs the specified JavaScript on the client, that has the component currently displayed. If the component isn't displayed, the specified JavaScript will not be executed.The specified JavaScript won't run instantly. These instructions are first collected by the framework, and then when the current thread is finished, they will be sent to the client in a package, and then they will be executed. The execution order is the same as they were added, this is guaranteed by the framework.
Warning: If a package contains an illegal instruction, the execution of the package will stop after the first error. This error will be recorded to the browser's console, and the server log.
- Parameters:
javaScripts
- The JavaScripts to be executed- Returns:
- The component
-
runJavaScript
Runs the specified JavaScripts on the client, that has the component currently displayed. If the component isn't displayed, the specified JavaScript will not be executed.The specified JavaScript won't run instantly. These instructions are first collected by the framework, and then when the current thread is finished, they will be sent to the client in a package, and then they will be executed. The execution order is the same as they were added, this is guaranteed by the framework.
Warning: If a package contains an illegal instruction, the execution of the package will stop after the first error. This error will be recorded to the browser's console, and the server log.
- Parameters:
javaScripts
- The list containing the JavaScripts to be executed- Returns:
- The component
-
showNotification
Shows the specified notification on the client that has the component currently displayed. If no component is displayed, the notification won't be shown either.- Parameters:
notificationType
- The notification type. See theNotificationType
enum for applicable values.title
- The notification title (header text)- Returns:
- The component
-
showNotification
Shows the specified notification on the client that has the component currently displayed. If no component is displayed, the notification won't be shown either.- Parameters:
notificationType
- The notification type. See theNotificationType
enum for applicable values.title
- The notification title (header text)message
- The notification message- Returns:
- The component
-
error
Shows the specified error message on the client that has the component currently displayed. If no component is displayed, the message won't be shown either.- Parameters:
title
- The error title (header text)message
- The error message- Returns:
- The component
-
getLanguageCode
Gets the component's language code. If no language code was set, it will return with the default one. The default language code can be set in theDEFAULT_LANGUAGE_CODE
JBStrap parameter.- Returns:
- The language code
-
say
- Parameters:
title
- The message title (header text)message
- The warning message- Returns:
- The component
-
showProcessIndicator
Sets the Process Indicator to be shown or hidden on the client. If the component isn't displayed, the method won't be executed.- Parameters:
show
- Iftrue
the indicator is shown, iffalse
, it is hidden.- Returns:
- The component
-
setPadding
Sets the component padding.- Parameters:
paddings
- A list of paddings to be added Available padding types are listed in the enumPadding
.- Returns:
- Component
-
setMargin
Component margin settings. The specified margin has the same type for all screens.- Parameters:
margins
- A list of component margins Available margins are listed in theMargin
class.- Returns:
- Component
-
setBorder
Sets the component�s border.- Parameters:
border
- A list of component border settings Available border settings are listed in the enumBorder
.- Returns:
- Component
-
onHotKeyEventHandler
- Parameters:
event
- The event object
-
setHeightAuto
Automatically sets the component's height.- Returns:
- Component
-
setHeight25
Sets the component height to 25%.- Returns:
- Component
-
setHeight50
Sets the component height to 50%.- Returns:
- Component
-
setHeight75
Sets the component height to 75%.- Returns:
- Component
-
setHeight100
Sets the component height to 100%.- Returns:
- Component
-
setWidthAuto
Automatically sets the component's width.- Returns:
- Component
-
setWidth25
Sets the component width to 25%.- Returns:
- Component
-
setWidth50
Sets the component width to 50%.- Returns:
- Component
-
setWidth75
Sets the component width to 75%.- Returns:
- Component
-
setWidth100
Sets the component width to 100%.- Returns:
- Component
-
init
The component initialization method.Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.
- Throws:
JavaScriptLoadError
- If there was a JavaScript error during the initialization.
-
isDrawn
public boolean isDrawn()Determines if the component is drawn on the client.- Returns:
true
, if it is drawn, otherwisefalse
-
draw
- Parameters:
writer
- The writer class, that has every Component HTML code. If specified asnull
, a newStringWriter
class is created- Returns:
- The HTML content collecting writer class.
-
writeHTML
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
.- Returns:
- If the componentwas drawn,
true
, otherwisefalse
-
setTextColor
Sets the text color for the component.- Parameters:
color
- Text color Available colors are listed in the enumColor
.- Returns:
- Component
-
getTextColor
Gets the component�s text color.- Returns:
- The specified text color or
null
if not specified
-
setBackgroundColor
Sets the component�s background color.- Parameters:
color
- The background color to be set Available colors are listed in the enumColor
.- Returns:
- Component
-
getBackgroundColor
Gets the component�s background color.- Returns:
- Background color or
null
if not specified
-
setFloating
Component float settings.- Parameters:
floating
- Float settings for the component Available settings are listed in theFloatingType
class.- Returns:
- Component
-
clearfix
Removes all float settings. This setting must take effect on the parent component.- Parameters:
clearfix
- Iftrue
is specified, float settings are removed, otherwise not- Returns:
- Component
-
setSelectionType
Sets the content selection types (of how users can select content elements).- Parameters:
type
- Selection type Available selection types are listed in the enumSelectionType
.- Returns:
- Component
-
setScrollable
Sets if scrolling is enabled in the component. The default setting is the same as the browser�s.- Parameters:
scrollable
- Iftrue
is specified, scrolling is enabled Iffalse
is specified, scrolling is turned off. Ifnull
is specified, the default browser settings apply (the text overlaps the area).- Returns:
- Component
-
setOverflow
Sets if scrolling is enabled in the component. The default setting is the same as the browser�s.- Parameters:
overflow
- Iftrue
is specified, scrolling is enabled. Iffalse
is specified, scrolling is turned off. Ifnull
is specified, the default browser settings apply (the text overlaps the area).- Returns:
- Component
-
setDisplayType
Set how the component is displayed- Parameters:
displayType
- A list of display modes you want to use. For a list of available settings, see theDisplayType
enum- Returns:
- Component
-
setFlex
Flexible component display setting for all screen sizes. These settings apply only for flexible display settings.- Parameters:
flex
- Flexible display settings- Returns:
- Component
-
setShadow
Sets the component shadow.- Parameters:
shadow
- Component shadow setting Available shadow settings are listed in the enumShadow
.- Returns:
- Component
-
setTextAlign
-
getTextAlign
-
setBorderColor
Sets the border color for the component.- Parameters:
color
- Border color Available colors are listed in the enumColor
.- Returns:
- Component
-
getBorderColor
Gets the component�s border color.- Returns:
- The specified border color or
null
if not specified
-
setEventBubbling
-
isEventBubbling
public boolean isEventBubbling()
-