Xpages InputField将数据从datepicker发送到服务器
在XPAGE上,我有一个输入端口:
<xp:inputText id="inputPassExpiryDate"
value="#{customerBean.customer.dateValidPass}"
disabled="#{!customerBean.customer.editMode}"
validator="#{customerValidators.validPassDate}">
</xp:inputText>
我启用一个datapicker插件( https://github.com/eternicode/ Bootstrap-datepicker )对于输入字段,带有以下脚本:
<xp:scriptBlock>
xp:this.value><![CDATA[$(document).ready(function(){
reloadDP();
var dateFormat = "#{javascript: application['date_only']}";
x$('#{id:inputPassExpiryDate}').datepicker({
language: getUserLanguage(),
format:(dateFormat),
weekStart: 1,
todayBtn: true,
clearBtn: true,
daysOfWeekHighlighted: "0,6",
calendarWeeks: true,
autoclose: true,
todayHighlight: true
}).on('changeDate', doSomething);
}
)
function doSomething(){
var from = x$('#{id:inputPassExpiryDate}').val().split("-")
var DateInput = new Date(from[0], from[1] - 1, from[2])
var DateNow = new Date();
if (DateInput <= DateNow) {
x$('#{id:inputPassExpiryDate}').addClass("invalid");
x$('#{id:pnlExpiredReason}').removeClass("hidden");
}else{
x$('#{id:inputPassExpiryDate}').removeClass("invalid");
x$('#{id:pnlExpiredReason}').addClass("hidden");
}
}
我注意到日期的更改仅在Web客户端中设置。
在元素的“ pnlexpiredreasear”中,我有一个文本方面的控件,只有在InputPassexpiryDate的日期比当前日期更老时,我才想到该控制。
但是我注意到,当我向服务器提交XPAGE并开始验证时,InputPassexpiryDate的更改值不会更改。它只是具有与我使用日期选择器更改值之前的值相同的值。
因此,我的问题是,当我通过date-ticker(客户端)更改值时,如何更新输入字段(服务器端)的值?
getComponent("inputPassExpiryDate").getValue()
将返回日期PCIKER加载XPAGE时所具有的值,而不是通过通过日期挑选的更新后。
On my xpages I have an inputfield:
<xp:inputText id="inputPassExpiryDate"
value="#{customerBean.customer.dateValidPass}"
disabled="#{!customerBean.customer.editMode}"
validator="#{customerValidators.validPassDate}">
</xp:inputText>
I enable a datapicker plugin (https://github.com/eternicode/bootstrap-datepicker) for the inputfield with the following script:
<xp:scriptBlock>
xp:this.value><![CDATA[$(document).ready(function(){
reloadDP();
var dateFormat = "#{javascript: application['date_only']}";
x$('#{id:inputPassExpiryDate}').datepicker({
language: getUserLanguage(),
format:(dateFormat),
weekStart: 1,
todayBtn: true,
clearBtn: true,
daysOfWeekHighlighted: "0,6",
calendarWeeks: true,
autoclose: true,
todayHighlight: true
}).on('changeDate', doSomething);
}
)
function doSomething(){
var from = x$('#{id:inputPassExpiryDate}').val().split("-")
var DateInput = new Date(from[0], from[1] - 1, from[2])
var DateNow = new Date();
if (DateInput <= DateNow) {
x$('#{id:inputPassExpiryDate}').addClass("invalid");
x$('#{id:pnlExpiredReason}').removeClass("hidden");
}else{
x$('#{id:inputPassExpiryDate}').removeClass("invalid");
x$('#{id:pnlExpiredReason}').addClass("hidden");
}
}
I notice that a change in date is only set in the web client.
In element 'pnlExpiredReason' I have an textarea control which I would like to validate when submitting to the server ONLY when inputPassExpiryDate has a date that is older than the current date.
But I notice that the changed value for inputPassExpiryDate is not changed when I submit the xpage to the server and validation starts. It simply has the same value as it has before I changed value with the date picker.
So my question is how can I update the value for the inputfield (server-side) when I have changed the value via the date-picker (client-side) ?
getComponent("inputPassExpiryDate").getValue()
will return the value that the date-pciker had when the xpage was loaded, not after update via the date-picker.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论