コード例 #1
0
 @Transaction(context = INewsContext.class)
 @Override
 public JavascriptForward onSave(final ComponentParameter cp) throws Exception {
   final NewsAttachment attachment = getAttachment(cp);
   if (attachment != null) {
     attachment.setTopic(cp.getParameter("ae_topic"));
     attachment.setDescription(cp.getParameter("ae_description"));
     attachment.setAttachtype(cp.getIntParameter("ae_attachtype"));
     attachment.setVideoTime(cp.getIntParameter("ae_videotime"));
     newsContext
         .getAttachmentService()
         .update(new String[] {"topic", "attachtype", "videotime", "description"}, attachment);
   }
   final JavascriptForward js = super.onSave(cp);
   js.append("$Actions['NewsTabAttachPage_tbl']();");
   return js;
 }
コード例 #2
0
 protected String toOpeHTML(final ComponentParameter cp, final NewsAttachment attachment) {
   final Object id = attachment.getId();
   final StringBuilder sb = new StringBuilder();
   sb.append(
       ButtonElement.editBtn()
           .setOnclick("$Actions['NewsFormAttachPage_edit']('beanId=" + id + "');"));
   sb.append(SpanElement.SPACE);
   sb.append(
       ButtonElement.deleteBtn()
           .setOnclick("$Actions['NewsFormAttachPage_delete']('id=" + id + "');"));
   sb.append(AbstractTablePagerSchema.IMG_DOWNMENU);
   return sb.toString();
 }
コード例 #3
0
    @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)));
    }
コード例 #4
0
    @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;
    }