When representing boolean values Notes applications have traditionally used checkboxes and radio-buttons. In this article we look at some of the modern alternatives available when designing modern Domino applications.
2. Booleans
• Boolean values are an integral part
of the life of a programmer used
when a variable has two values, a
true/false or off/on state.
• Booleans are supported in Java,
LotusScript, and even @Formula.
• Historically we have displayed
boolean values in our UI using
check boxes or radio buttons.
• Modern interfaces have developed
with slicker versions these controls.
• For mobile devices check-boxes
and radio buttons are rarely used
as they are often difficult to
operate using a fat thumb.
learn. do. dream.
www.redpilldevelopment.com
3. Mobile Toggle Switch
• The XPages mobile controls includes a toggle switch.
This is based on dojox/mobile/Switch.
• Touching the control with a tap or drag gesture
triggers the state of the control being flipped.
• Toggle switches are a little different to most other
input controls in that there is not a true value binding
between the control and the underlying property
being edited. Care must there be taken in how these
are coded.
Instructions
1. To implement a toggle switch is is usually a good idea
to develop a toggleMyfield() method in your java
bean that toggles the state of each boolean. This
method will be used later.
Example:
public void toggleDefault() {
setDefault(!isDefault());
}
learn. do. dream.
www.redpilldevelopment.com
4. Mobile Toggle Switch
2. Unlike most booleans the toggle switch uses values of “on” and “off”. We can use an
immediate if statement in EL to convert an existing boolean value to off/on.
Example:
value=“#{(mybean.default)?’on’:’off’}”
3. To update the value of a boolean we must invoke our toggle method in an
onStateChanged event. This event should (usually) trigger a partial refresh only to
update the value of the field.
learn. do. dream.
www.redpilldevelopment.com
5. State Buttons
• An alternative to the toggle switch is the state button. This provides a control that can easily used on a
mobile device using a tap gesture as well as on a desktop device using a mouse.
• State buttons are especially useful when you have a group of boolean values.
• State buttons can be any commonly used button control such as a button or tab bar button.
• The current boolean value is used to assign a “selected” class to the button when true. We can the add
CSS to style the button in a different way when its state is “on” or “true”.
• The click event can then invoke our toggle method to update the boolean value.
learn. do. dream.
www.redpilldevelopment.com