Units of Measure for Columns

If you want to implement the units of measure (dimension) in a custom page, you can use ENOVIA Business Process Services's tag library.

The following topics are discussed:

Tag Lib Parameters

When using the taglib, the UOMAttribute class should only be used with attributes that are configured with a dimension. If no dimension is configured for an attribute, then the "asentered" value is used regardless of the specified parameters.

Use the UOMAttribute tag to display the attribute value with the unit of measure.

The format for the UOMAttribute tag is:

<framework:UOMAttribute

objectID="<object ID>"

name="<attribute name>"

mode="<view / edit>"

format="<asentered/metric/english>"

/>

This table defines the parameters shown above:

Tag Lib Parameter Description Possible/Default Values

objectID

Object ID of the object that the attribute is associated with.

If the ObjectID is not provide, the attribute value will be shown as empty and the units defined in the dimension will be listed in the drop-down box.

Not applicable in a create dialog page.

ObjectID of the business object

name

Name of the attribute configured with a dimension

Weight

mode

Defines whether or not the attribute value is displayed as read-only text or as an editable textbox/combobox field.

View (default) Edit

format

Converts the normalized value stored in the database to the defined format for display purposes. The preference units are the units selected by the user as their preference.

When the mode=Edit, the asentered format is used even if the format is set to a different value.

Not applicable in a create or edit dialog page.

asentered (default) english metric preference

Example Using the UOMAttribute Tag in a Create JSP

In a create dialog JSP page, this code specifies the unit of measure for an attribute:

<framework:UOMAttribute name="AttributeName" mode="Edit"/>

AttributeName can be the symbolic or actual name of the attribute that is configured with a dimension. If you use the symbolic name, the code retrieves the attribute's actual name and uses that for further processing. This example shows how to use the tag lib to define a field:

<tr>
    <td class="label" width=150>Weight</td>
    <td class="inputField" colspan="1">
     <framework:UOMAttribute name="Weight" mode="edit"/>
    <td>
</tr>

The result of this code would look like this:



The text box displays the default attribute value. If no default is defined, then the text box is empty. The combo box contains the list of defined units for the dimension, with the default units (kg in this example) displayed.

The name of the text box is AttributeName (as defined in the tag lib call). The processing page uses this name to retrieve the value entered by the user. The name of the combo box is units_AttributeName and can be used by the processing page to retrieve the units specified by the user.

To define a custom name (other than the attribute name) for the text field and combo box, include the fieldName attribute in the tag lib call. In this case, the text box name is fieldName and the units combo box name is units_fieldName. For example:

<tr>
<td class="label" width=150>Weight</td>
<td class="inputField" colspan="1">
     <framework:UOMAttribute name="Weight" mode="edit" 
fieldName="Part Weight"/>
<td>
</tr>

In this example, the text box name is "Part Weight", and the combo box name is "units_Part Weight".

Example Using the UOMAttribute Tag in a Processing Page

In a processing page, the Text box value = emxGetParameter(request, "Attribute Name") and the Combo box value = emxGetParameter(request, "units_Attribute Name"). The values should be concatenated as follows:

Text box value + " " + Combo box value

For example:

String sWeight  = emxGetParameter(request, "Weight");
String sWeightUnit = emxGetParameter(request, "units_Weight");
sWeight = sWeight + " " + sWeightUnit;
//Use sWeight as UOM attribute value for processing purpose

Example Using the UOMAttribute Tag in a View Page

When displaying an attribute configured with a dimension in a view page, follow this example:

<framework:UOMAttribute objectId = "Object Id" 
name="AttributeName" mode="view"/>

AttributeName can be the symbolic or actual name of the attribute that is configured with a dimension. If you use the symbolic name, the code retrieves the attribute's actual name and uses that for further processing. This example shows how to use the tag lib to define a field:

<tr>
    <td class="label" width="150">Weight</td>
    <td class="field">
    <framework:UOMAttribute name="Weight" objectId="<%=partId%>" 
mode="View"/>
    </td>
</tr>

The view page displays the above code as:



The fieldName attribute is not applicable on a view page.

The tag lib uses the As Entered value/units in the view page. To display the English or Metric system values, or the user's preference, you must include the format tag lib attribute as follows:

<tr>
    <td class="label" width="150">Weight</td>
    <td class="field">
    <framework:UOMAttribute name="Weight" objectId="<%=partId%>" 
mode="View" format="English"/>
    </td>
</tr>

The page displays the As Entered value, followed by the format-specified value:



Example Using the UOMAttribute Tag in an Edit Page

You can use the tag lib in an edit page:

<framework:UOMAttribute objectId = "Object Id" 
name="AttributeName" mode="Edit"/>

AttributeName can be the symbolic or actual name of the attribute that is configured with a dimension. If you use the symbolic name, the code retrieves the attribute's actual name and uses that for further processing. This example shows how to use the tag lib to define a field:

<tr>
    <td class="label" width="150">Weight</td>
    <td class="inputField"> 
    <framework:UOMAttribute name="Weight" objectId="<%=partId%>" 
mode="Edit"/>
    </td>
</tr>

This field on the edit dialog page looks like this:



The edit page always displays the As Entered value/units, regardless of the user preferences.

The name of the text box is AttributeName (as defined in the tag lib call). The processing page uses this name to retrieve the value entered by the user. The name of the combo box is units_AttributeName and can be used by the processing page to retrieve the units specified by the user.

To define a custom name (other than the attribute name) for the text field and combo box, include the fieldName attribute in the tag lib call. In this case, the text box name is fieldName and the units combo box name is units_fieldName. For example:

<tr>
    <td class="label" width="150">Weight</td>
    <td class="inputField"> 
    <framework:UOMAttribute name="Weight" objectId="<%=partId%>" 
mode="Edit" fieldName = "Part Weight"/>
    </td>
</tr>

In this example, the text box name is "Part Weight", and the combo box name is "units_Part Weight".