我在sqlite中有两个表:
代码由XCode Generation生成:
class Event: NSManagedObject {
@NSManaged var startDate: NSDate
@NSManaged var details: EventDetail //i think this property shoud be var details Array<EventDetail> am i correct?
}
class EventDetail: NSManagedObject {
@NSManaged var title: String
@NSManaged var location: String
@NSManaged var note: String
@NSManaged var endDate: NSDate
@NSManaged var event: NSManagedObject
}
Run Code Online (Sandbox Code Playgroud)
我想将事件放在section中,将eventDetails放在行中.
我创建了加载事件的方法:
var eventList : Array<AnyObject> = []
func loadEvents(){
let appDel : AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let moc: NSManagedObjectContext = appDel.managedObjectContext! …Run Code Online (Sandbox Code Playgroud) 我有一个带有多选选项的网格。\n通常,当我单击复选框时,会使用默认选定的颜色选择行。\n但是当我单击网格时,我需要具有相同或其他选定的颜色\xc2\xb4s 行。
\n我创建了一个CSS:
\n:host(#grdPeriodicos) td.selected{\n background-color: #BDBDBD;\n color: #242140;\n font-weight: bold;\n}\nRun Code Online (Sandbox Code Playgroud)\n将其导入到我的类视图中:
\n@CssImport(value = "./styles/grid-styles.css", themeFor = "vaadin-grid")\npublic class PeriodicoListaView extends VerticalLayout implements Serializable {\n...\n\ngrdPeriodicos.setId("grdPeriodicos");\ngrdPeriodicos.addColumn(periodico -> periodico.getId_Nota()).setHeader("Nota");\ngrdPeriodicos.addColumn(periodico -> periodico.getId_NotaItem()).setHeader("Nota item"); \ngrdPeriodicos.setSelectionMode(SelectionMode.MULTI);\n\ngrdPeriodicos.setClassNameGenerator( p -> {\n return ((periodicoDTO != null) && (periodicoDTO.getId_NotaItem().equals(p.getId_NotaItem()))) ? "selected" : null; \n});\n\n\ngrdPeriodicos.addItemClickListener(e -> {\n\n if(e.getItem() != null) {\n carregaEPreencheDetalhesPeriodico(e.getItem()); \n }\n });\n\nRun Code Online (Sandbox Code Playgroud)\n加载网格时上面的代码有效,但是单击该行时没有任何反应。\n我可以在 addItemClickListener 中放入什么来再次触发 setClassNameGenerator?
\n或者我该怎么做才能在单击该行时选择该行?
\n我正在使用 Vaadin,我需要创建一个链接来下载 PDF 文件。但是,我需要关闭 InputStream。但是如果我在用户单击下载 PDF 文件时关闭它,它就会关闭并引发异常。在哪里关闭它的正确位置?
File file = new File("f:\\10041328370.pdf");
Anchor a;
try{
InputStream is= new FileInputStream(file);
StreamResource res = new StreamResource("10041328370.pdf", () -> is );
a = new Anchor(res, "click here to download");
a.getElement().setAttribute("download", "downloaded-other-name.pdf");
add(a);
is.close(); //if close here, when the user to click in the anchor, we will get the error: Stream Closed.
} catch (IOException e) {
throw new RuntimeException(e.getMessage);
}
Run Code Online (Sandbox Code Playgroud)