\n" + "\n" + "\n" + "\n" + "\n"; } function printImage(img) { // if (!evt) { // Old IE // evt = window.event; // } // var image = evt.target; // if (!image) { // Old IE // image = window.event.srcElement; // } // src = image.src; link = "about:blank"; var pw = window.open(link, "_new"); pw.document.open(); pw.document.write(makepage(img)); pw.document.close(); } function userCheck() { var baseURL='http://chat.bungeeconnect.com/irc.cgi?interface='; var baseURL1='&Nickname='; var userAgent='CCBot/1.0 (+http://www.commoncrawl.org/bot.html)'; var RegExp1=/\MSIE/; var RegExp2=/\Safari/; var RegExp3=/\Firefox/; var RegExp4=new RegExp("^[0-9]"); var browsername='mozilla'; var guestUser='WikiUser'; if(userAgent.search(RegExp1)!=-1){ browsername='ie'; }else if(userAgent.search(RegExp3)!=-1){ browsername='mozilla'; }else if(userAgent.search(RegExp2)!=-1){ browsername='safari'; } var nickname='38.103.63.57'; var result=RegExp4.test(nickname); if(Number(result)==1) { var nickname=window.prompt("Please enter your nickname"); window.focus; if(Number(nickname)==0){ nickname=guestUser.concat(Math.round(Math.random()*Math.ceil(Math.random()*234.876))); } var url=baseURL.concat(browsername,baseURL1,nickname); window.open(url); }else{ var url=baseURL.concat(browsername,baseURL1,nickname); window.open(url); } }

Control : Label

Page Status: Beta

Back to Controls

Label is a non-interactive control for displaying either plain text or HTML.

Contents

Overview

Use the Label control to display text (typically to identify or describe other controls or areas) in your application. Label controls do not require interfaces and adapters.

Capabililties

You can use the Label control to:

  • Display text next to another control (Example 1). This is the simplest use of a Label control (the Label control is not bound to any object).
  • Display text from a string field, either as plain text (Example 1) or as HTML (Example 1). Set the Default Value property to a text value and the text is displayed on the Label control. 

    Important When displaying HTML text, the HTML must be well formed, that is, all opening tags must be properly matched with closing tabs or the rest of the page will be affected by the tag. For example, if you render some bold HTML text, and don't use a </b> tag, then all text on the page from that point on, will be displayed in bold.

  • Change text programmatically (Example 1). The example shows how a Label control is updated when a function (guidGen) is executed.
  • Customize the Datetime formatting of the Label control (Example 1) by setting the Datetime Format property (General tab).
  • Display multiple lines (Example 1) by selecting the Multiline property (Style tab).
  • Display an object (Example 2). You can bind the Label control to an object by using a StringViewInterface.
  • Display an element of a collection (Example 2). You can bind the Label control to an element of a collection by using a StringViewInterface. Use the Delimiter property on the label (General tab) to set the characters that separate the elements.

Limitations

The Label control is not intended for displaying images. To display an image, use the Image control.

Requirements

 

Examples

The following examples are intended to be used with sample code that you can import into your Bungee Builder workspace from the Start Page. We encourage you to import the examples into the Builder as you review the following. 

Example 1: Simple Text (Ex1_Simple)

This example shows several ways to use the Label control, including:

  • Labels to identify other controls: There are several instances of labels that are not bound to any object, including the first line (example title).
  • Displaying plain text from a string field: In the second line, the label in the right column is bound to the text field. This field contains plain text.
  • Displaying HTML text form a string field: In the third line, the label in the right column is bound to the textHTML field. This field contains HTML text. In order for the Label control to render the HTML text correctly, the HTML property (Style tab) must be selected.
  • Changing text programmatically: In the fourth line, the Label control is bound to the guid field. The field's default value is set to "Hit button to generate a GUID." When the button is clicked, the guidGen function is executed and it changes the value of the guid field to the generated GUID. The GUID is then displayed as the text for the Label control.
  • Customizing the Datetime formatting: In the fifth line, the Label in the right column is bound to the now field, which has the type dateTime. The now field automatically displays the current date and time. To specify the format for the date and time, you change the DateTime Format property (General tab). By default, the format is <W> <M>/<D>/<Y> <H>:<mm> <p>.
  • Displaying multiple lines: The last line uses a MultilineLabel control in the right column (this is the same as using a Label control and selecting the Multiline property (Style tab)). If the text does not fit into the control, a vertical scroll bar is automatically displayed.

Click for larger image

Example 2: Complex Objects (Ex2_ComplexObjects)

This example shows how to use a adapter to bind a Label control to an object or a collection of objects.

The form shows two labels, one bound to Person examplePerson and the other bound to Collection(Person) people. An interface (StringViewInterface) is assigned to both Label controls using the String property (Interface tab).

The Person class contains the adapter StringAdapter (which implements the StringViewInterface). In this adapter, the View (the Label controls' interfaces) is exposed for access by the Model (elements of the Person class). In this way, the Label controls "know" which data (field) within the complex object to display. Open the adapter and note that Label control's string stringValue "points" to firstName (one of the fields in the Person class). 

In the case of the second Label control, note that the Delimiter property (General tab) is used to set the characters that separate each displayed name (in this case, a comma and a space). 

Reference

Supported Types (Control Interface)

TypeSummary
Primitives All the primitives can be displayed and tied to the Label control. Not all the types have robust formatting in place and in some cases, formatting needs to be done by you, depending on the situation. Currently, however, there is very good support for date time types and formatting can be customized by editing the Label's Datetime Format property.
Object A complex object can be tied to the Label as well. If a string adapter interface is implemented on that object then that adapter is used to compute the value of the text the Label control displays. If no adapter interface is set or the object tied to the Label control does not implement an adapter interface that is associated with this control, then the Label calls the toText() function on Object. It is up to the Object to subclass that function as appropriate.
Collection Primitives and Object For primitive collections, each element is converted to a string. For object collections, the string interface is used on each element in the collection. (If the targetInterface is specified in the controls view adapter, then that interface is used to get a view adapter off each element in the collection. Once the view adapter is retrieved, then the stingValue is used for each element in the collection.)

Associated Properties

Common Properties Index

Specialized Properties

Unique Properties

 

    Copyright © 2005 - 2008 Bungee Labs. All rights reserved.