Class RibbonItem
The ribbon runtime (juneau-ribbon.js) implements every behavior; this type only names it and carries its
parameters. toMap() produces the same {type, ...} entry the runtime reads from viewDef.ribbon.
Setters are not gated per item type, but toMap() fails loudly rather than emit a key the runtime ignores
for that type (for example form on a refresh, or symbol on an optionGroup), and
checks the invariants the runtime cannot: a top-level option needs column or param (exactly
one) plus a value, and a group's default must name a member. Group members take only
id, title, symbol, column, param and value.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionappearance(String v) Sets how this item's button is drawn.static RibbonItemThe ribbon's collapse-all-detail-rows button.Scopes anoptionto a table column.Marks anoptionas on until the user (or persisted state) says otherwise.defaultOption(String memberId) Selects anoptionGroupmember until the user (or persisted state) says otherwise.deselectable(boolean v) Lets anoptionGroup's selected member be clicked again to deselect it.static RibbonItemA ribbon button that opens a modal dialog.static RibbonItemdivider()A visual separator between ribbon items; it also closes any open item cluster.Sets the URL a dialog item's form submits to.static RibbonItemThe ribbon's export menu, offering the named buttons.Sets the form-source URL supplying a dialog item's input fields.Clusters this item with adjacent items sharing the same group name.Sets this item's stable id.Sets the non-safe HTTP method a dialog item's form submits with.Sets what the runtime does with a successful dialog submission.static RibbonItemA server-query toggle button.Adds export buttons that are omitted, rather than rendered disabled, when their library is absent.static RibbonItemoptionGroup(String id, RibbonItem... members) A group of mutually exclusiveoptiontoggles.Scopes anoptionto a URL query parameter.static RibbonItemThe ribbon's pause/resume auto-refresh toggle.persist(boolean v) Sets whether this option's (or group's) state is remembered across page loads.static RibbonItemA ribbon button that publishes a message when clicked.static RibbonItemrefresh()The ribbon's reload-the-table button.Sets the icon name overriding this item's default icon.Sends this item's command to another card instead of its own table.Sets this item's title/label text.toMap()Builds this item's ribbon entry.static voidValidates an authored ribbon item map (for example from a JSON5 card body) with exactly the rulestoMap()applies to a built item: a knowntype, only keys the runtime reads, anexportwith at least one valid button, anoptionwith exactly one ofcolumnorparamplus avalue, adefaultthat suits the item, a validappearanceandtarget, a well-formedvisibleWhen(a list offield/oprules with a known op), and the same rules for eachoptionGroupmember.visibleWhen(VisibilityRule... rules) Hides this item unless every rule matches the console's facts.
-
Method Details
-
divider
A visual separator between ribbon items; it also closes any open item cluster.- Returns:
- A new
RibbonItem.
-
refresh
The ribbon's reload-the-table button.- Returns:
- A new
RibbonItem.
-
collapseAll
The ribbon's collapse-all-detail-rows button.- Returns:
- A new
RibbonItem.
-
pausePolling
The ribbon's pause/resume auto-refresh toggle.- Returns:
- A new
RibbonItem.
-
export
The ribbon's export menu, offering the named buttons.A button here is required: if its library is missing at runtime (JSZip for
excel, pdfMake forpdf) it renders disabled and logs an error. Useoptional(String...)for buttons that should simply be omitted when their library is absent. The menu may consist of optional buttons alone, buttoMap()rejects one with no buttons at all.- Parameters:
buttons- The required buttons, each one ofcopy,csv,print,excelorpdf.- Returns:
- A new
RibbonItem. - Throws:
IllegalArgumentException- Ifbuttonsnames a button not in that set.
-
dialog
A ribbon button that opens a modal dialog.- Parameters:
actionId- This item's stable id (also the dialog's logical name). Must not benull or blank.- Returns:
- A new
RibbonItem. - Throws:
IllegalArgumentException- IfactionIdisnull or blank.
-
option
A server-query toggle button.Set exactly one of
column(String)(a BeanQuery$-expressionvalueagainst that column) orparam(String)(a URL query parameter). Checked bytoMap().- Parameters:
id- The toggle's stable id. Must not benull or blank.- Returns:
- A new
RibbonItem. - Throws:
IllegalArgumentException- Ifidisnull or blank.
-
optionGroup
A group of mutually exclusiveoptiontoggles.A member may omit
column/param/value; selecting it then applies no filter (an "All" member).- Parameters:
id- The group's stable id. Must not benull or blank.members- The members, each created byoption(String). Must not be empty.- Returns:
- A new
RibbonItem. - Throws:
IllegalArgumentException- Ifidisnull or blank, ormembersis empty or holds anything other than anoption.
-
publish
A ribbon button that publishes a message when clicked. The topic must be a custom topic declared in the page'stopicsor a card'spublishes, orcmd:<cardId>; the console's wiring check enforces that. Rendered only on a console page (no bus, no button).- Parameters:
title- The button label.topic- The topic to publish.payload- A JSON-serializable payload, ornull for{}.- Returns:
- A new
RibbonItem. - Throws:
IllegalArgumentException- Iftitleortopicisnull or blank.
-
target
Sends this item's command to another card instead of its own table. Accepted onrefresh,collapseAll,pausePolling,optionandoptionGroup;toMap()rejects it elsewhere.- Parameters:
cardId- The target card id; the console's wiring check verifies it names a card that handles the op.- Returns:
- This object.
- Throws:
IllegalArgumentException- IfcardIdis not a valid card id.
-
visibleWhen
Hides this item unless every rule matches the console's facts. Evaluated by the client; this only serializes the rules. Accepted on every item type; not on anoptionGroupmember.- Parameters:
rules- The rules, ANDed together. None clears them.- Returns:
- This object.
-
id
Sets this item's stable id.The id is emitted on the item's ribbon entry, where it is scoped to its card (it is not stamped as a DOM id).
toMap()rejects an id on the types the runtime ignores it for (dividerandexport).- Parameters:
v- The id. Must not benull or blank.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifvisnull or blank.
-
title
Sets this item's title/label text.On an
optionGroupthe title is not drawn; it becomes the group's accessible name (role="group"witharia-label).- Parameters:
v- The title. Can benull to unset.- Returns:
- This object.
-
group
Clusters this item with adjacent items sharing the same group name.- Parameters:
v- The group name. Can benull to unset.- Returns:
- This object.
-
appearance
Sets how this item's button is drawn.- Parameters:
v- The appearance; currently onlyicon. Can benull to unset.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifvis not a known appearance.
-
symbol
Sets the icon name overriding this item's default icon.- Parameters:
v- The icon name. Can benull to unset.- Returns:
- This object.
-
form
Sets the form-source URL supplying a dialog item's input fields.- Parameters:
url- The form URL. Can benull to unset.- Returns:
- This object.
-
endpoint
Sets the URL a dialog item's form submits to.- Parameters:
url- The endpoint URL. Can benull to unset.- Returns:
- This object.
-
method
Sets the non-safe HTTP method a dialog item's form submits with.- Parameters:
m- The method. Must not benull .- Returns:
- This object.
-
onSuccess
Sets what the runtime does with a successful dialog submission.- Parameters:
s- The success behavior. Must not benull .- Returns:
- This object.
-
optional
Adds export buttons that are omitted, rather than rendered disabled, when their library is absent.- Parameters:
names- The buttons, eachexcelorpdf.- Returns:
- This object.
- Throws:
IllegalArgumentException- If a name is not one of those, or is already a required button.
-
column
Scopes anoptionto a table column.- Parameters:
name- The row-data column name. Can benull to unset.- Returns:
- This object.
-
param
Scopes anoptionto a URL query parameter.- Parameters:
name- The parameter name. Can benull to unset.- Returns:
- This object.
-
value
Sets anoption's value: a BeanQuery$-expression for acolumn-scoped option, or the raw parameter value for aparam-scoped one.- Parameters:
v- The value. Can benull to unset.- Returns:
- This object.
-
persist
Sets whether this option's (or group's) state is remembered across page loads.- Parameters:
v- Whether to persist.- Returns:
- This object.
-
defaultOn
Marks anoptionas on until the user (or persisted state) says otherwise.- Returns:
- This object.
-
defaultOption
Selects anoptionGroupmember until the user (or persisted state) says otherwise.- Parameters:
memberId- The member's id; checked against the members bytoMap().- Returns:
- This object.
- Throws:
IllegalArgumentException- If this item is a plainoption(usedefaultOn()).
-
deselectable
Lets anoptionGroup's selected member be clicked again to deselect it.- Parameters:
v- Whether the group is deselectable.- Returns:
- This object.
-
toMap
Builds this item's ribbon entry.- Returns:
- The entry,
typefirst, then only the keys that were set. - Throws:
IllegalArgumentException- If the item sets a key the runtime ignores for its type, a top-leveloptionsets neither or both ofcolumnandparamor novalue, anexporthas no buttons, or adefaultdoes not suit the item (anoptiontakesdefaultOn(); anoptionGrouptakesdefaultOption(String)naming a member), or atargetis set on a type the runtime does not route.
-
validate
Validates an authored ribbon item map (for example from a JSON5 card body) with exactly the rulestoMap()applies to a built item: a knowntype, only keys the runtime reads, anexportwith at least one valid button, anoptionwith exactly one ofcolumnorparamplus avalue, adefaultthat suits the item, a validappearanceandtarget, a well-formedvisibleWhen(a list offield/oprules with a known op), and the same rules for eachoptionGroupmember.- Parameters:
item- The authored item. Must not benull .- Throws:
IllegalArgumentException- If the item is not valid.
-