コード例 #1
0
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
      try {
        Product product = (Product) form.getDefaultModelObject();

        if (product.getId() == 0) {
          product.setActive(true);

          productDataProvider.persist(product);
        } else {
          productDataProvider.merge(product);
        }

        ProductViewOrEditPanel.this.removeAll();
        ProductViewOrEditPanel.this.add(new ProductViewFragement().setOutputMarkupId(true));
      } catch (RuntimeException e) {
        LOGGER.warn(e.getMessage(), e);

        String[] messages = e.getMessage().split(": ");
        String message = messages[messages.length - 1];

        warn(message.substring(0, 1).toUpperCase() + message.substring(1));
      } finally {
        target.add(target.getPage());
      }
    }
コード例 #2
0
 @Override
 public void onClick(AjaxRequestTarget target) {
   ProductViewOrEditPanel.this.removeAll();
   ProductViewOrEditPanel.this.add(new ProductViewFragement()).setOutputMarkupId(true);
   target.add(target.getPage());
 }
コード例 #3
0
 @Override
 public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) {
   target.getPage().visitChildren(FormComponent.class, new AjaxRenderingVisitor(target));
 }