Xpages-使用SSJS更新日期字段



我正在尝试使用ssjs更新日期字段。如果未选择"使用日期/时间选择器弹出窗口"选项,则可以正常工作。但是,如果检查了此选项,则更新不起作用。谁能解释为什么这是?这是我的代码:

<xp:panel rendered="true">  
<xp:button value="Set Date Value" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="partial" refreshId="DateField">
        <xp:this.action><![CDATA[#{javascript:document1.setValue("DateField","01.01.1970");}]]></xp:this.action>
    </xp:eventHandler></xp:button>&#160;&#160;&#160;
<xp:inputText id="DateField" value="#{document1.DateField}">
    <xp:this.converter>
        <xp:convertDateTime type="date"></xp:convertDateTime>
    </xp:this.converter>
    <xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>
</xp:panel>

才能使用正确的日期格式设置您需要设置它的日期字段

document1.setValue("DateField","01.01.1970")

日期格式需要是java.util.date,请尝试此

document1.setValue("DateField",new Date("01.01.1970"))

,但我建议这样做,因为那样您的代码不绑定到服务器正在使用该特定语言环境设置。

var date=new Date();
date.setFullYear(1970)
date.setMonth(0) //remember months starts with 0 
date.setDate(1)
document1.setValue("DateField",date)

一件事是,我在注释客户端运行时没有工作,但这可能是一个错误。

最新更新