# JSPart

## Overview

The `JSPartWithConstants` class extends `JSPart` and adds support for prefixed constants through the `IPrefixedConstantsObject` interface. Should not be instantiated directly, as its constructor exists solely to meet interface requirements. The class provides a `getPrefix` method that returns the name of the `JSPart` class, enabling consistent handling of prefixed constants.

## Constants Summarized

| Type                                                                         | Name              | Summary                                             |
| ---------------------------------------------------------------------------- | ----------------- | --------------------------------------------------- |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [BODY](#body)     | Constant use for specifying the type of form parts. |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [FOOTER](#footer) | Constant use for specifying the type of form parts. |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [HEADER](#header) | Constant use for specifying the type of form parts. |

## Properties Summarized

| Type                                                                         | Name                      | Summary                                                         |
| ---------------------------------------------------------------------------- | ------------------------- | --------------------------------------------------------------- |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [background](#background) | The background color of the form part.                          |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [height](#height)         | The height of a selected part; specified in pixels.             |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [styleClass](#styleclass) | The Cascading Style Sheet (CSS) class name applied to the part. |

## Methods Summarized

| Type                                                                          | Name                                | Summary                                                                                                        |
| ----------------------------------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)  | [getComment()](#getcomment)         | Returns the comment of this component.                                                                         |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)  | [getPartType()](#getparttype)       | The type of this part.                                                                                         |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)  | [getPartYOffset()](#getpartyoffset) | The Y offset of the part on the form, this will include all the super forms parts if this form extends a form. |
| [UUID](https://docs.servoy.com/reference/servoycore/dev-api/application/uuid) | [getUUID()](#getuuid)               | Returns the UUID of this component.                                                                            |

## Constants Detailed

### BODY

Constant use for specifying the type of form parts.

This is the default part that is repeated for each record (being\
displayed and/or printed).

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var body = form.newPart(JSPart.BODY, 320);
```

### FOOTER

Constant use for specifying the type of form parts.

A footer is displayed at the bottom of each page when printed ad can\
contain summaries of the current selection of records. In List view, the\
footer is displayed at the bottom of the list of records.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var footer = form.newPart(JSPart.FOOTER, 440);
```

### HEADER

Constant use for specifying the type of form parts.

A header is displayed at the top of each page when printed and can contain\
summaries of the current selection of records. In List view the header is\
displayed above the list of records. In tableview the default column headers will\
not be there if this is specified.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var header = form.newPart(JSPart.HEADER, 80);
```

## Properties Detailed

### background

The background color of the form part.

NOTE: When no background color has been set, the default background\
color will be determined by the Look and Feel (LAF) that has been selected\
in Application Preferences.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
var body = form.newPart(JSPart.BODY, 320);
body.background = 'green';
```

### height

The height of a selected part; specified in pixels.

This height property is the lowerbound as its ending Y value (0 == top of the form).

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var part = form.newPart(JSPart.HEADER, 100);
part.height = 200;
```

### styleClass

The Cascading Style Sheet (CSS) class name applied to the part.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
var body = form.newPart(JSPart.BODY, 320);
body.styleClass = 'myBody';
```

## Methods Detailed

### getComment()

Returns the comment of this component.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the comment associated with this component.

**Sample**

```js
var comment = solutionModel.getForm("my_form").getButton("my_button").getComment();
application.output(comment);
```

### getPartType()

The type of this part.

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) A number representing the type of the form part.

**Sample**

```js
var allParts = form.getParts()
for (var i=0; i<allParts.length; i++) {
	if (allParts[i].getPartType() == JSPart.BODY)
		application.output('body Y offset: ' + allParts[i].getPartYOffset());
}
```

### getPartYOffset()

The Y offset of the part on the form, this will include all the super forms parts if this form extends a form.

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) A number holding the Y offset of the form part.

**Sample**

```js
var allParts = form.getParts()
for (var i=0; i<allParts.length; i++) {
	if (allParts[i].getPartType() == JSPart.BODY)
		application.output('body Y offset: ' + allParts[i].getPartYOffset());
}
```

### getUUID()

Returns the UUID of this component.

**Returns:** [UUID](https://docs.servoy.com/reference/servoycore/dev-api/application/uuid) the UUID of this component.

**Sample**

```js
var button_uuid = solutionModel.getForm("my_form").getButton("my_button").getUUID();
application.output(button_uuid.toString());
```

***
