提交 58bcd256 编写于 作者: W wusongqing

updated formhost and formprovider

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 449ce282
# FormHost # FormHost
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host. Provides APIs related to the widget host.
...@@ -57,15 +57,15 @@ SystemCapability.Ability.Form ...@@ -57,15 +57,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Parameters** **Parameters**
...@@ -147,16 +147,16 @@ SystemCapability.Ability.Form ...@@ -147,16 +147,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- | | -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. | | formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | No | Whether to release the cache.| | isReleaseCache | boolean | No | Whether to release the cache.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -209,15 +209,15 @@ SystemCapability.Ability.Form ...@@ -209,15 +209,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -270,15 +270,15 @@ SystemCapability.Ability.Form ...@@ -270,15 +270,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -337,9 +337,9 @@ SystemCapability.Ability.Form ...@@ -337,9 +337,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -398,9 +398,9 @@ SystemCapability.Ability.Form ...@@ -398,9 +398,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -459,9 +459,9 @@ SystemCapability.Ability.Form ...@@ -459,9 +459,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -520,9 +520,9 @@ SystemCapability.Ability.Form ...@@ -520,9 +520,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -574,9 +574,9 @@ SystemCapability.Ability.Form ...@@ -574,9 +574,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -601,9 +601,9 @@ SystemCapability.Ability.Form ...@@ -601,9 +601,9 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -655,10 +655,10 @@ SystemCapability.Ability.Form ...@@ -655,10 +655,10 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -684,11 +684,11 @@ SystemCapability.Ability.Form ...@@ -684,11 +684,11 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | Yes| Module name.| | moduleName | string | Yes| Module name.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -714,10 +714,10 @@ SystemCapability.Ability.Form ...@@ -714,10 +714,10 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | No| Module name.| | moduleName | string | No| Module name.|
**Return value** **Return value**
...@@ -962,16 +962,16 @@ SystemCapability.Ability.Form ...@@ -962,16 +962,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.| | formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.| | isVisible | boolean | Yes | Whether to be visible.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -1025,16 +1025,16 @@ SystemCapability.Ability.Form ...@@ -1025,16 +1025,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.| | formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.| | isEnableUpdate | boolean | Yes | Whether to enable update.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
......
# FormProvider # FormProvider
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget provider. Provides APIs related to the widget provider.
...@@ -38,8 +38,8 @@ SystemCapability.Ability.Form ...@@ -38,8 +38,8 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) { if (error.code) {
console.log('formProvider setFormNextRefreshTime, error:' + error.code); console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
} }
}); });
``` ```
...@@ -71,7 +71,9 @@ SystemCapability.Ability.Form ...@@ -71,7 +71,9 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5).catch((error) => { formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -101,8 +103,8 @@ SystemCapability.Ability.Form ...@@ -101,8 +103,8 @@ SystemCapability.Ability.Form
var formId = "12400633174999288"; var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj, (error, data) => { formProvider.updateForm(formId, obj, (error, data) => {
if (error) { if (error.code) {
console.log('formProvider updateForm, error:' + error.code); console.log('formProvider updateForm, error:' + JSON.stringify(error));
} }
}); });
``` ```
...@@ -136,7 +138,9 @@ SystemCapability.Ability.Form ...@@ -136,7 +138,9 @@ SystemCapability.Ability.Form
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.application.formBindingData';
var formId = "12400633174999288"; var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj).catch((error) => { formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error) => {
console.log('formProvider updateForm, error:' + JSON.stringify(error)); console.log('formProvider updateForm, error:' + JSON.stringify(error));
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册