Collaboration Edit"
From Documentation
Line 1: | Line 1: | ||
+ | {{ZKSpreadsheetEssentials3PageHeader}} | ||
Line 5: | Line 6: | ||
{{ZSS EE}} | {{ZSS EE}} | ||
− | + | = Overview = | |
+ | Spreadsheet can support ''Collaboration Edit'' automatically as long as two or more Spreadsheet components share a common book model with proper scope. | ||
+ | |||
+ | Here we demonstrate an example application that load a book and share it in "application" scope. That means if two users open the same book and they are both actually editing on the same book model instance. One user's edit will immediately reflect on another user's Spreadsheet. | ||
+ | |||
+ | The screenshot below is what the user, Paul, sees and he can also see another user's (John) current selection (purple box). | ||
+ | [[File:essentials-feature-coedit-user1.png | center | 900px]] | ||
+ | |||
+ | [[File:essentials-feature-coedit-user2.png | center | 900px]] | ||
+ | <source lang='java'> | ||
+ | public class CoeditComposer extends SelectorComposer<Component> { | ||
+ | |||
+ | private static final long serialVersionUID = 1L; | ||
+ | |||
+ | @Wire | ||
+ | private Spreadsheet ss; | ||
+ | @Wire | ||
+ | private Textbox userName; | ||
+ | @Wire | ||
+ | private Listbox availableBookList; | ||
+ | |||
+ | private ListModelList<String> availableBookModel = new ListModelList<String>(); | ||
+ | |||
+ | @Listen("onSelect = #availableBookList") | ||
+ | public void onBookSelect(){ | ||
+ | String bookName = availableBookModel.getSelection().iterator().next(); | ||
+ | Book book = loadBookFromAvailable(bookName); | ||
+ | ss.setBook(book); | ||
+ | } | ||
+ | |||
+ | private Book loadBookFromAvailable(String bookname){ | ||
+ | Book book; | ||
+ | synchronized (sharedBook){ | ||
+ | book = sharedBook.get(bookname); | ||
+ | if(book==null){ | ||
+ | book = importBook(bookname); | ||
+ | book.setShareScope("application"); | ||
+ | sharedBook.put(bookname, book); | ||
+ | } | ||
+ | } | ||
+ | return book; | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | </source> | ||
= how to enable= | = how to enable= |
Revision as of 04:07, 6 August 2013
Available in ZK Spreadsheet EE only
Overview
Spreadsheet can support Collaboration Edit automatically as long as two or more Spreadsheet components share a common book model with proper scope.
Here we demonstrate an example application that load a book and share it in "application" scope. That means if two users open the same book and they are both actually editing on the same book model instance. One user's edit will immediately reflect on another user's Spreadsheet.
The screenshot below is what the user, Paul, sees and he can also see another user's (John) current selection (purple box).
public class CoeditComposer extends SelectorComposer<Component> {
private static final long serialVersionUID = 1L;
@Wire
private Spreadsheet ss;
@Wire
private Textbox userName;
@Wire
private Listbox availableBookList;
private ListModelList<String> availableBookModel = new ListModelList<String>();
@Listen("onSelect = #availableBookList")
public void onBookSelect(){
String bookName = availableBookModel.getSelection().iterator().next();
Book book = loadBookFromAvailable(bookName);
ss.setBook(book);
}
private Book loadBookFromAvailable(String bookname){
Book book;
synchronized (sharedBook){
book = sharedBook.get(bookname);
if(book==null){
book = importBook(bookname);
book.setShareScope("application");
sharedBook.put(bookname, book);
}
}
return book;
}
...
}