我在bean中有一个列表,并尝试在JSF上将其推送到客户端。我使用json数组进行此操作。但是,我在第一个警报中收到空消息,并且在第二次警告javascript文件之前,行 - var obj = JSON.parse(日期)中的“Uncaught SyntaxError:Unexpected end of input”错误消息。
我是否正确使用UIInput对象?如何通过此列表在javascript文件中使用它?
.xhtml(UI);
...
<h:inputHidden id="specDates" binding="#{planCalendarFacade.datesUIComp}"/>
<input jsfc="h:commandButton" id="slctdAction" class="hiddenBtn" action="#{planCalendarFacade.getSpecificCalendarPlans}">
<f:ajax execute="@form" render="@none" />
</input>
...
planCalendarFacade.java(bean);
private UIInput datesUIComp;
...
public PlanCalendarFacade() {
// TODO Auto-generated constructor stub
}
public void getSpecificCalendarPlansFromDB(){
List<String> temp = new ArrayList<String>();
temp.add("2014-05-09");
JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(temp.toString());
JsonArray jsonArray = jsonElement.getAsJsonArray();
for(int i = 0 ; i < jsonArray.size(); i++)
System.out.println("Item"+i+" - >"+jsonArray.get(i));
datesUIComp.setValue(jsonArray);
}
public UIInput getDatesUIComp() {
return datesUIComp;
}
public void setDatesUIComp(UIInput datesUIComp) {
this.datesUIComp = datesUIComp;
}
javascript文件;
function updateAddedDayPlns(){
$(".addedDayPlnLst").selectable({
stop : function() {
$(".ui-selected", this).each(function() {
// My form-id is "mainForm"
document.getElementById('mainForm:slctdAction').click();
var dates = document.getElementById('mainForm:specDates').value;
alert(dates);
var obj = JSON.parse(dates);
alert(obj.get[0]);
$('.clndr').datepick({
onSelect: datePickShow,
multiSelect: 999,
monthsToShow: [3,2]}).datepick('setDate', arr);
});
}
});
}
所有反馈都赞赏!