@Override protected TableRows getTableRows(final PageParameter pp) { final InputElement beanId = InputElement.hidden("beanId"); final InputElement ae_topic = new InputElement("ae_topic"); final InputElement ae_videotime = new InputElement("ae_videotime"); final InputElement ae_description = InputElement.textarea("ae_description").setRows(4); Option[] opts = null; final Class<? extends Enum<?>> eClass = getAttachmentTypeClass(); if (eClass != null) { final Enum<?>[] vals = eClass.getEnumConstants(); opts = new Option[vals.length]; for (int i = 0; i < opts.length; i++) { opts[i] = new Option(vals[i].ordinal(), vals[i]); } } final NewsAttachment attachment = getAttachment(pp); if (attachment != null) { beanId.setText(attachment.getId()); ae_topic.setText(attachment.getTopic()); ae_videotime.setText(attachment.getVideoTime()); ae_description.setText(attachment.getDescription()); if (opts != null) { opts[attachment.getAttachtype()].setSelected(true); } } final TableRows rows = TableRows.of(new TableRow(new RowField($m("AttachmentEditPage.1"), beanId, ae_topic))); if (opts != null) { rows.append( new TableRow( new RowField( $m("AttachmentEditPage.2"), InputElement.select("ae_attachtype").addElements(opts)))); } return rows.append( new TableRow(new RowField($m("NewsFormAttachPage.7"), ae_videotime)), new TableRow(new RowField($m("Description"), ae_description))); }
@Override protected Map<String, Object> getRowData(final ComponentParameter cp, final Object dataObject) { final NewsAttachment attachment = (NewsAttachment) dataObject; final KVMap kv = new KVMap(); try { final AttachmentFile af = newsContext.getAttachmentService().createAttachmentFile(attachment); kv.put( "topic", new LinkElement(attachment.getTopic()) .setOnclick(JS.loc(DownloadUtils.getDownloadHref(af), true)) .setTitle(attachment.getDescription())); } catch (final IOException e) { kv.put("topic", attachment.getTopic()); } kv.put("attachsize", FileUtils.toFileSize(attachment.getAttachsize())); final Class<? extends Enum<?>> eClass = ((NewsFormAttachPage) get(cp)).getAttachmentTypeClass(); if (eClass != null) { kv.put("attachtype", eClass.getEnumConstants()[attachment.getAttachtype()]); } if (((INewsWebContext) newsContext).getLogRef() != null) { kv.put( "downloads", LinkElement.style2(attachment.getDownloads()) .setOnclick( "$Actions['NewsTabAttachPage_logWin']('beanId=" + attachment.getId() + "');")); } else { kv.put("downloads", attachment.getDownloads()); } kv.put("userId", cp.getUser(attachment.getUserId())); kv.put("createDate", attachment.getCreateDate()); kv.add(TablePagerColumn.OPE, toOpeHTML(cp, attachment)); return kv; }