我想知道如何将事件(p:schedule)存储到Html5本地存储?
我经历了
http://forum.primefaces.org/viewtopic.php?f=3&t=39051
JSF / PrimeFaces compatibility with HTML5 Storage methods
What JSF data can I store in a client browser
然后浏览了HTml5 Localstorage教程
http://www.w3schools.com/html/html5_webstorage.asp
但我仍然感到困惑,我应该从哪里开始?
事件生成格式之一是
{"events" : [{"id": "afe434ae-edf7-4265-8422-fe65eb7aec15","title": " Emma - 30 - Unassigned - 07 30 PM-09 30 PM","pet": {"serviceTypeTitle":"30 Min Pet Visit","statusStr":"Accepted","employee":"Unassigned","prefEmployeeModelList":[],"serviceTypeShortCode":"30","hasTrainee":"false","id":0,"serviceTypeId":5,"traineeIdList":[],"traineeList":[],"traineeModelList":[],"trainee":"None","employeeIdList":[],"employeeList":[],"serviceRuleId":1,"originalDate":1408320000,"startDate":1408359600,"endDate":1408361400,"locationId":2,"status":2,"cost":0.0,"billable":1,"payable":1,"modifiedBy":0,"modifiedTime":1408599848,"editedTime":"Aug 18, 2014 11:00:00 AM","ruleStatus":0,"petId":0,"pet":" Emma","serviceId":0,"eventDetails":" Emma - 30 - Unassigned - 07 30 PM-09 30 PM","currStatus":2,"startDateVar":"Aug 18, 2014 11:00:00 AM","endDateVar":"Aug 18, 2014 11:30:00 AM","billableBoolean":false,"payableBoolean":false,"selectedHr":0,"selectedTime":0,"amOrPm":0,"selectedHrED":0,"selectedTimeED":0,"amOrPmED":0,"commentObj":{"id":0,"serviceId":0,"userId":0,"shared":0,"createdTime":0,"modifiedTime":0},"preferredContactMode":"SMS(text)","timeSlotFrom":50400,"timeSlotTo":57600,"timeSlotFromVar":"07 30 PM","timeSlotToVar":"09 30 PM","locationAddress":"2914 N Har Street , Kochi , 666675, India","startDateForHover":"Mon, Aug 18 2014, 11:00 AM","addressUrlForHover":"https://maps.google.com/maps?q\u003d2914+N+Har+Street+,+Kochi+,+666675,+India","role":"Administrator","changeList":["employee","cost","locationName","serviceTypeTitle","startDateVar","endDateVar","statusStr","strBillable","strPayable","modifiedBy","modifiedTime"],"eventId":0,"employeeModelList":[],"allDay":false,"personId":0,"eventsInviteesPersonIdList":[],"eventCreatedById":0,"eventCreatedOnInt":0,"checkIfNotAttendee":false,"petList":[],"recurFrequency":"Single","addFlag":"no"},"start": "2014-08-18T11:00:00.000000Z","end": "2014-08-18T11:30:00.000000Z","allDay":false,"editable":true,"className":"accepted"}]}
如果有人实施了相同的,请在这里帮助我。
答案 0 :(得分:1)
localStorage只处理字符串,因此首先需要将对象转换为字符串。您可以使用JSON:
localStorage.savedValue = JSON.stringify(myEvent);
然后当你想将它转换回你使用的对象时:
newEvent = JSON.parse(localStorage.savedValue);