Skip to main content
Skip table of contents

Create entries in pop-up or auto-completion fields

Within a pop-up or in the auto-completion field, a new asset or asset feature can now be generated.

Introduction

If text exists in the text entry field, then an entry for creating a new entry is displayed at the end of the suggestion list. The text is displayed in the text input field within the entry, for example, "New Person' 'Smith'". A definable action with the text in the text input field as a parameter is called. A dialogue to create the new entry is displayed. By confirming the dialogue, a new entry will be created, selected and the cursor moves to the next input field.

Typically, this mechanism is used to create new assets (for example a new address) or new master data (for example a new asset feature value) directly from an Asset dialogue, without having to switch between windows or even applications. In the first step, it is only possible to generate new assets, with no features.

Configuration

The widget has the following syntax:

XML
<xe:popupmenu ...>
  <xe:options ...>
    <xe:generator expression=""/>
    <xe:option label="">
      <cs:command name="">
        <cs:param name="">
          <asset type=.../>
        </cs:param>
        <cs:param name="dialog-key" value=""/>
      </cs:command>
    </xe:option>
  </xe:options>
</xe:popupmenu>


This feature is available for the XML editor widgets "popup menu" and "auto-completion field" is available.

The option for creating a new entry must be assigned to the widget within the definition dialogue as an additional option (own element "xe: option"). As a sub-element this option requires a generic command invocation (cs:command). Once this option is selected from the pop-up menu, the associated command is executed asynchronously.

XML
<cs:command name="create-new-asset">
   <cs:param name="asset">
     <asset type=.../>
   </cs:param>
   <cs:param name="dialog-key" value=""/>
</cs:command>


The name of the command must be an UIAction, which is registered under this name in the file "java-client-app-def actions.xml". Basically, any UIAction can be called. This mechanism works only reasonably for those actions which implement the command interface. Currently, with version 4.4 there exists only one such UIAction ("create-new-asset"), which is used to create a new asset. However, it is possible that additional actions become implemented in the future, for example, to create new master data.

Optionally, extra parameters can be handed over to the command. A parameter node may also have an xsl-stylesheet node, which will then be used for the generation of the contents of the node parameters (see example below). The command "create-new-asset" supports these two parameters:
The parameter "asset" specifies an asset-prototype which serves to preallocate certain metadata of the asset, for example, asset type or asset name.
The parameter "dialog-key" to specify a dialogue-key, if a different import dialogue should be displayed.

XML
<cs:param name="asset">
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"   xmlns="http://www.w3.org/1999/xhtml">
    <xsl:template match="/">
      <asset type="picture.logo." name="{asset/@name}"/>
    </xsl:template>
  </xsl:stylesheet>
</cs:param>


The command "create-new-asset" performs a standard import action. That means, first a dialogue appears for the metadata of the asset to be created afterwards. Then the asset is imported in the censhare database. Once the asset has been created, the asset ID is added to the referenced location in the XML document via the source attribute of the widget and its associated label/name is displayed in the pop-up or text field. This means the newly generated asset is automatically selected in the widget.

Example 1:

Creating a new image asset within a pop-up menu. Type and name of the new asset are preassigned. 

XML
<xe:popupmenu source="asset_feature[feature='mf:asset-ref2',value_long2='0']@value_asset_id" width="200">
  <xe:options label-key="@name" value-key="@id">
    <xe:generator expression="=:cs:asset()[@censhare:asset.type='picture.logo.*']"/>
    <xe:option label="Neues Logo">
      <cs:command name="create-new-asset">
        <cs:param name="asset">
          <asset type="picture.logo." name="=:asset/@name"/>
        </cs:param>
        <cs:param name="dialog-key" value="dialog-asset-check-in-new"/>
      </cs:command>
    </xe:option>
  </xe:options>
</xe:popupmenu>

Example 2:

Creating a new image asset within an auto-completion field.

XML
<xe:auto-completion-field source="asset_feature[feature='mf:asset-ref2',value_long2='0']@value_asset_id"
  search-value-source="$temp@search" width="200">
  <xe:options label-key="@name" value-key="@id">
    <xe:generator expression="=:cs:asset()[@censhare:asset.type='picture.logo.*']"/>
    <xe:option label="Neues Logo">
      <cs:command name="create-new-asset">
        <cs:param name="asset">
          <asset type="picture.logo." name="=:$temp/*/@search"/>
        </cs:param>
        <cs:param name="dialog-key" value="dialog-asset-check-in-new"/>
      </cs:command>
    </xe:option>
  </xe:options>
</xe:auto-completion-field>


This example also shows how it is possible to use the search text entered by the user as a name suggestion for the asset to be created. Specifying the attribute "search-value source" ensures that the content of the text field is written to the specified target slot. In the prototype element of the asset this value can be accessed using an XPath expression:

XML
<asset name="=:$temp/*/@search" .../>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.