建立或取代提示
用於建立或取代提示的 <method>
元素格式為:
<method methodName="prompt.creatOrReplacePrompt">
使用這個方法可建立新提示,或取代現有的提示。 <method>
元素包含一個以上 <prompt:prompt>
元素,其每一個都會定義新提示的性質。 <prompt:prompt>
元素包含選用的 <prompt:parameters>
元素,後隨選用的 <prompt:choice>
元素。 如需相關資訊,請參閱<prompt:prompt> ,如需如何使用 <prompt:prompt>
元素及其子元素的相關資訊,請參閱 使用注意事項。
<prompt:prompt>
<prompt:prompt>
元素用於定義提示,並具有下列屬性:
屬性名稱 | 必要或選用 | 說明 |
---|---|---|
name |
必要 |
提供提示的唯一名稱。 |
值:字串 |
||
預設值:無 |
||
type |
必要 |
提示類型。 |
值:下列其中一個值: |
||
預設值:無 |
<prompt:parameters>
<prompt:parameters>
元素是 <prompt:prompt>
的子項,用於定義提示的參數。 這個元素可出現一次,也可省略(如果該提示不需要任何參數)。 針對某些提示類型,這個元素會包含 <prompt:additionalParameters>
元素。 <prompt:parameters>
元素具有下列屬性:
屬性名稱 | 必要或選用 | 說明 |
---|---|---|
label |
必要 |
在提示視窗中顯示的文字。 它為使用者提供所需資訊的指引。 |
值:字串 |
||
預設值:無 |
||
order |
必要 |
在提示視窗中相對於其他提示的提示順序。 |
值:整數 |
||
預設值:無 |
||
localized |
必要 |
定義提示是否可本地化。 |
值: |
||
預設值:無 |
||
errorMessage |
選用項目。 |
使用者向提示提供不適當的資訊時顯示的文字。 |
值:字串 |
||
預設值:無 |
||
defaultValue |
選用項目。 |
使用者可以選取之提示的預設回應。 |
值:字串 |
||
預設值:無 |
<prompt:additionalParams>
<prompt:additionalParams>
是 <prompt:parameters>
的子項,用於提供下列類型的工具所需的其他參數:
- 查閱
- 動態選項
- 格式化字串
- 即時動態選項
這個元素包含任意數目的 <prompt:param>
元素(其每一個都會定義一個其他參數),並且沒有屬性。
<prompt:param>
<prompt:param>
元素是 <prompt:additionalParams>
的子項,用於定義工具之其他參數的名稱及值。 使用注意事項包含關於如何使用這個元素的其他資訊。 這個元素是空的,並具有下列屬性:
屬性名稱 | 必要或選用 | 說明 |
---|---|---|
name |
必要 |
參數的名稱。 |
值:字串 |
||
預設值:無 |
||
值 |
必要 |
參數的值。 |
值:相依於提示類型,但一般為 String |
||
預設值:無 |
<prompt:choice>
<prompt:choice>
元素是 <prompt:prompt>
的子項,用於定義固定選項提示中的功能表選項。 它沒有屬性,但包含一個以上
<prompt:item>
項目,其每一個都會定義功能表中的一個選項。
<prompt:item>
<prompt:item>
元素是 <prompt:choice>
的子項,並出現一次以上。 每一次出現都會定義固定選項提示的一個功能表選項。 這個元素具有下列屬性:
屬性名稱 | 必要或選用 | 說明 |
---|---|---|
值 |
必要 |
當使用者選取這個選項時,該提示所傳回的值。 |
值:字串 |
||
預設值:無 |
||
label |
必要 |
功能表中針對這個選項所顯示的文字。 |
值:字串 |
||
預設值:無 |
使用注意事項
下列注意事項說明針對每種類型的提示,如何使用 <prompt:prompt>
的子元素。
字串
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序、錯誤訊息、本地化指示器,以及預設值。 省略所有其他子元素。
整數
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序、錯誤訊息、本地化指示器,以及預設值。 省略所有其他子元素。
浮點
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序、錯誤訊息、本地化指示器,以及預設值。 省略所有其他子元素。
密碼
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化指示器。 省略所有其他子元素。
時間
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化指示器。 省略所有其他子元素。
查閱
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化旗標。 此外,請提供 <prompt:additionalParams>
元素,其中包含具有下列屬性值的單一 <prompt:param>
元素:
屬性 | 值 |
---|---|
name |
|
值 |
檔案的路徑,該檔案包含查閱清單中顯示的項目。 例如:
|
固定選項
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化旗標。 此外,請提供 <prompt:choice>
元素,其中針對功能表中的每個選項,包含一個對應的 <prompt:item>
元素。
動態選項
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化旗標。 此外,請提供 <prompt:additionalParams>
元素,其中包含具有下列屬性值的單一 <prompt:param>
元素:
屬性 | 值 |
---|---|
name |
|
值 |
針對表格中最多兩個直欄執行的 ObjectServer SQL 指令。 ObjectServer 所傳回的每一列,都會作為子功能表或清單中的一個項目顯示給使用者。 針對多個 ObjectServer 執行時,這個 SQL 指令只能選取所有這些 ObjectServer 所共有的直欄及直欄值。 例如:
|
多行字串
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化旗標。 此外,請提供 <prompt:additionalParams>
元素,其中包含具有下列屬性值的單一 <prompt:param>
元素:
格式化字串
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序、錯誤訊息、本地化指示器,以及預設值。 此外,提供包含單一 <prompt:param>
項目的 <prompt:additonalParams>
元素,其屬性值如下:
屬性 | 值 |
---|---|
name |
|
值 |
正規表示式,使用者所輸入的字串必須與其相符合。 例如:
|
即時動態選項
請指定單一 <prompt:parameters>
元素,其中包含要顯示的提示字串、其相對於其他提示的順序,以及本地化旗標。 此外,請提供 <prompt:additionalParams>
元素,其中包含具有下列屬性值的單一 <prompt:param>
元素:
屬性 | 值 |
---|---|
name |
|
值 |
針對表格中最多兩個直欄執行的 ObjectServer SQL 指令。 ObjectServer 所傳回的每一列,都會作為子功能表或清單中的一個項目顯示給使用者。 針對多個 ObjectServer 執行時,這個 SQL 指令只能選取所有這些 ObjectServer 所共有的直欄及直欄值。 例如:
|
即時動態選項提示會建立一個可捲動的清單,其中包含工具執行時所產生 ObjectServer 查詢的結果。 此提示主要用於經常變動的 ObjectServer 表格中的資料。 因為此提示類型是即時執行,所以請謹慎使用它來減少 Web GUI 伺服器上的負載。
範例:建立提示
下列範例會建立每一種提示類型的一個提示。
<methodCall xmlns:prompt="http://www.ibm.com/tivoli/netcool/webtop/prompts/2.2">
<!-- Create prompts. The prompts must not already exist. -->
<method methodName="prompt.createPrompt">
<!-- String prompt -->
<prompt:prompt type="String" name="testString">
<prompt:parameters label="Type in a string value" order="100"
errorMessage="String value cannot be empty" localized="false"
defaultValue="Default string"/>
</prompt:prompt>
<!-- Integer prompt -->
<prompt:prompt type="Integer" name="testInteger">
<prompt:parameters label="Type in an integer value" order="110"
errorMessage="Invalid integer value" localized="false" defaultValue="5"/>
</prompt:prompt>
<!-- Float prompt -->
<prompt:prompt type="Float" name="testFloat">
<prompt:parameters label="Type in a float value" order="120"
errorMessage="Invalid float value" localized="false" defaultValue="1.0"/>
</prompt:prompt>
<!-- Password prompt -->
<prompt:prompt type="Password" name="testPassword">
<prompt:parameters label="Type in the password" order="130"
localized="false"/>
</prompt:prompt>
<!-- Time prompt -->
<prompt:prompt type="Time" name="testTime">
<prompt:parameters label="Specify a date/time" order="140"
errorMessage="Invalid date/time value" localized="false"/>
</prompt:prompt>
<!-- Lookup prompt -->
<prompt:prompt type="Lookup" name="testLookup">
<prompt:parameters label="Select a lookup option" order="150"
localized="false">
<prompt:additionalParams>
<prompt:param name="file" value="/tmp/lookup.txt"/>
</prompt:additionalParams>
</prompt:parameters>
</prompt:prompt>
<!-- Fixed Choice prompt -->
<prompt:prompt type="FixedChoice" name="testFixedChoice">
<prompt:parameters label="Select a fixed option" order="160"
localized="false"
defaultValue="fixed2"/>
<prompt:choice>
<prompt:item value="fixed1" label="Fixed One"/>
<prompt:item value="fixed2" label="Fixed Two"/>
<prompt:item value="fixed3" label="Fixed Three"/>
</prompt:choice>
</prompt:prompt>
<!-- Dynamic Choice prompt -->
<prompt:prompt type="DynamicChoice" name="testDynamicChoice">
<prompt:parameters label="Select a dynamic option" order="170"
localized="false">
<prompt:additionalParams>
<prompt:param name="sqlCommand"
value="select Conversion, Value from alerts.conversions
where Colname='Severity' order by Value desc;"/>
</prompt:additionalParams>
</prompt:parameters>
</prompt:prompt>
<!-- Multiline String prompt - useful for forced Journal entry -->
<prompt:prompt type="MultilineString" name="testMultilineString">
<prompt:parameters label="Type in a journal entry" order="0"
errorMessage="Journal entry cannot be empty" localized="false"
defaultValue="Journal entry"/>
</prompt:prompt>
<!-- Formatted String prompt -->
<prompt:prompt type="FormattedString" name="testFormattedString">
<prompt:parameters label="Type in the ticket ID (3 letters, 3 digits)"
order="180" errorMessage="Invalid ticket ID format" localized="false"
defaultValue="ABC123">
<prompt:additionalParams>
<prompt:param name="format" value="^[a-zA-Z]{3}\d{3}$"/>
</prompt:additionalParams>
</prompt:parameters>
</prompt:prompt>
<!-- Real-Time Dynamic Choice prompt - can impact server performance,
therefore use sparingly
-->
<prompt:prompt type="RealTimeDynamicChoice" name="testRealTimeDynamicChoice">
<prompt:parameters label="Select a real-time dynamic option" order="190"
localized="false">
<prompt:additionalParams>
<prompt:param name="sqlCommand" value="select Conversion, Value from
alerts.conversions where Colname='Type' order by Value desc;"/>
</prompt:additionalParams>
</prompt:parameters>
</prompt:prompt>
</method>
</methodCall>
範例:取代提示
這個範例會取代名稱為 testFormattedString
之現有提示的定義。
<methodCall xmlns:prompt="http://www.ibm.com/tivoli/netcool/webtop/prompts/2.2">
<method methodName="prompt.createOrReplacePrompt">
<!-- testFormattedString exists, so it is replaced with new settings. -->
<prompt:prompt type="FormattedString" name="testFormattedString">
<prompt:parameters label="Type in the ticket ID (3 letters, 3 digits)"
order="180" errorMessage="Invalid ticket ID format" localized="false"
defaultValue="Bbc123">
<prompt:additionalParams>
<prompt:param name="format" value="^[a-zA-Z]{3}\d{3}$"/>
</prompt:additionalParams>
</prompt:parameters>
</prompt:prompt>
</method>
</methodCall>