LiveCycle Designer Scripting Basics

XFA调试与XML保存技巧
本文介绍如何利用XFA中的messageBox进行调试,并展示如何使用saveXML方法保存当前节点类的XML结构为字符串。此外,还提供了获取当前日期的方法。

1.Debugging Calculations and Scripts(messagebox)

用途:调试Javascript时,可以使用messagebox(消息框)提供的反馈信息。缺点之一是user必须关闭很多消息框。

Example:

   FormCalc

    xfa.host.messageBox(Concat("The value of NumericField1 is: ",        NumericField1), "Debugging", 3)

  JavaScript

    xfa.host.messageBox("The value of NumericField1 is: " +        NumericField1.rawValue, "Debugging", 3);

 

var result = xfa.host.messageBox($record.language.errorMessage.ErrorMsg_SaveEvent.value,"Confirmation",2,2);

 

2.获取当前日期

Example:

var currentDate = new Date();

app.alert(currentDate);

Result:

 var currentDate = new Date();
 var year = currentDate.getFullYear();
 var month = currentDate.getMonth() + 1;
 var day = currentDate.getDate();
 var hour = currentDate.getHours();
 var minute = currentDate.getMinutes(); 

3.app.execMenuItem();

Acrobat JavaScript    Works in LiveCycle Designer   LiveCycle Designer      equivalent LiveCycle Designer               JavaScript Description

app.execMenuItem()            Y                                               N                                       —                                             Executes the specified menu item. Can be
                                                                                                                                                                                    used in LiveCycle Designer for menu
                                                                                                                                                                                    items such as Close, Find, Save, Save As,
                                                                                                                                                                                    Open, Prin
t, etc. 

4.saveXML
Saves the XML structure of the current node class to a string.

Syntax:

Reference_Syntax.saveXML( [ "pretty" ] )

Parameters:   pretty
(Optional)    Outputs the XML string in an easier to read format.

Returns:A valid string representing the XML fragment of the current object.

Applies to: node class class

Version: XFA 2.1

Examples:

   JavaScript                                                            FormCalc

      xfa.data.saveXML();                                          xfa.data.saveXML()
      xfa.data.saveXML("pretty");                               xfa.data.saveXML("pretty")

         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值