Example usage for org.apache.wicket.markup.html.form Form setOutputMarkupId

List of usage examples for org.apache.wicket.markup.html.form Form setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Form setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:com.norconex.jefmon.settings.update.SettingsPage.java

License:Apache License

private void initializeComponents() {
    try {/*  www.j  av  a2s  .  c o  m*/
        PropertyUtils.copyProperties(dirtyConfig, getJEFMonConfig());
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }

    AjaxLink<String> nameBack = new AjaxLink<String>("nameBack") {
        private static final long serialVersionUID = -7790485617549321158L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(InstancePage.class);
        }
    };
    nameBack.add(new Label("name", getJEFMonConfig().getInstanceName()));
    add(nameBack);

    Form<Void> form = new Form<Void>("form");
    form.setOutputMarkupId(true);
    add(form);

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    form.add(createConfigPanel("configPanel", dirtyConfig));

    final AjaxButton saveButton = new AjaxButton("save") {
        private static final long serialVersionUID = 8835758195954072646L;

        @Override
        protected void onAfterSubmit(AjaxRequestTarget target, Form<?> theform) {
            try {
                ConfigurationDAO.saveConfig(dirtyConfig);
                PropertyUtils.copyProperties(getJEFMonConfig(), dirtyConfig);
            } catch (IOException | IllegalAccessException | InvocationTargetException
                    | NoSuchMethodException e) {
                throw new WicketRuntimeException("Cannot save configuration.", e);
            }
            success(getString("success"));
            setResponsePage(InstancePage.class);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> theForm) {
            target.add(feedback);
        }
    };
    form.add(saveButton);
    form.setDefaultButton(saveButton);

    AjaxLink<String> closeButton = new AjaxLink<String>("close") {
        private static final long serialVersionUID = 6062171472516887030L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(InstancePage.class);
        }
    };
    form.add(closeButton);

}

From source file:com.przemo.busessearch.panels.SearchPanel.java

public SearchPanel(String id) {
    super(id);/*  w  w  w.  j ava 2s .  c o m*/
    Form<Void> form = new Form<>("busesSearch");
    resPanel = new WebMarkupContainer("resultsContainer");
    resPanel.add(new WebMarkupContainer(resultsComponentId));
    final SearchStationsPanel stationsPanel = new SearchStationsPanel("stations",
            new PropertyModel<Stations>(this, "stations.0"), new PropertyModel<Stations>(this, "stations.1"));
    form.add(stationsPanel);
    stationsPanel.setOutputMarkupId(true);
    form.setOutputMarkupId(true);
    resPanel.setOutputMarkupId(true);
    form.add(new AjaxButton("submit", form) {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {

        }
    }.add(new AjaxEventBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            List<Lines> res = lineService.getLinesForStations(stations[0], stations[1]);
            if (stations[0] != null && stations[1] != null && !res.isEmpty() && res.get(0) != null) {
                IModel<SearchResults> model = new Model<>(new SearchResults(res));
                if (model.getObject().getResult() != null) {
                    resPanel.addOrReplace(new SearchResultsPanel(resultsComponentId, model));
                }
            } else {
                resPanel.addOrReplace(new NoResultsAvailablePanel(resultsComponentId));
            }
            target.add(resPanel);
        }
    }));
    add(resPanel);
    add(form);

}

From source file:com.senacor.wbs.web.project.EditableTreeTablePanel.java

License:Apache License

public EditableTreeTablePanel(String id, Project project) {
    super(id);/*from  ww w  .j av a  2  s  .  co  m*/
    this.project = project;
    List<Task> tasks = taskManager.findTasks(project);
    IColumn columns[] = new IColumn[] {
            new PropertyTreeColumn(new ColumnLocation(Alignment.LEFT, 10, Unit.EM), "Tree Column",
                    "userObject.id"),
            new EditableTextFieldColumn(new ColumnLocation(Alignment.LEFT, 6, Unit.EM), "Name",
                    "userObject.name"),
            new EditableTextFieldColumn(new ColumnLocation(Alignment.MIDDLE, 30, Unit.PROPORTIONAL),
                    "Beschreibung", "userObject.beschreibung"),
            new EditableDropDownChoiceColumn(new ColumnLocation(Alignment.RIGHT, 10, Unit.EM), "Status",
                    "userObject.status", Arrays.asList(TaskStatus.values())),
            new AbstractColumn(new ColumnLocation(Alignment.RIGHT, 30, Unit.PX), "") {
                public IRenderable newCell(TreeNode node, int level) {
                    return null;
                }

                public Component newCell(MarkupContainer parent, String id, final TreeNode node, int level) {
                    return new LinkPanel(id, REMOVE, node) {
                        @Override
                        protected void handle(TreeNode treeNode, AjaxRequestTarget target) {
                            // Node
                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode;
                            Task nodeTask = (Task) node.getUserObject();
                            // Parent
                            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
                            Task parentTask = (Task) parent.getUserObject();
                            // Entferne den Task aus den Subtaks
                            // parentTask.getSubtasks().remove(
                            // defaultTreeModel
                            // .getIndexOfChild(parent, node));
                            // Entfernung des Knotens und neu rendern
                            defaultTreeModel.removeNodeFromParent(node);
                            tree.modelChanged();
                            tree.updateTree(target);
                        }

                        @Override
                        protected boolean show() {
                            if (node.getParent() == null) {
                                return false;
                            }
                            return true;
                        }
                    };
                }
            }, new AbstractColumn(new ColumnLocation(Alignment.RIGHT, 30, Unit.PX), "") {
                public IRenderable newCell(TreeNode node, int level) {
                    return null;
                }

                public Component newCell(MarkupContainer parent, String id, final TreeNode node, int level) {
                    return new LinkPanel(id, ADD, node) {
                        @Override
                        protected void handle(TreeNode treeNode, AjaxRequestTarget target) {
                            // Node
                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode;
                            Task nodeTask = (Task) node.getUserObject();
                            // Fge den Task zu den Subtasks hinzu
                            Task newTask = new Task();
                            nodeTask.getSubtasks().add(newTask);
                            defaultTreeModel.insertNodeInto(new DefaultMutableTreeNode(newTask), node, 0);
                            tree.getTreeState().expandNode(node);
                            tree.getTreeState().selectNode(node, true);
                            tree.invalidateAll();
                            tree.modelChanged();
                            tree.updateTree(target);
                        }

                        @Override
                        protected boolean show() {
                            return true;
                        }
                    };
                }
            }, new AbstractColumn(new ColumnLocation(Alignment.RIGHT, 30, Unit.PX), "") {
                public IRenderable newCell(TreeNode node, int level) {
                    return null;
                }

                public Component newCell(MarkupContainer parent, String id, final TreeNode node, int level) {
                    return new LinkPanel(id, GO_UP, node) {
                        @Override
                        protected void handle(TreeNode node, AjaxRequestTarget target) {
                            DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node;
                            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node1.getParent();
                            int index = defaultTreeModel.getIndexOfChild(parent, node1);
                            defaultTreeModel.removeNodeFromParent(node1);
                            defaultTreeModel.insertNodeInto(node1, parent, index - 1);
                            tree.getTreeState().expandNode(parent);
                            tree.invalidateAll();
                            tree.modelChanged();
                            tree.updateTree(target);
                        }

                        @Override
                        protected boolean show() {
                            if (node.getParent() == null
                                    || defaultTreeModel.getIndexOfChild(node.getParent(), node) == 0) {
                                return false;
                            }
                            return true;
                        }
                    };
                }
            }, new AbstractColumn(new ColumnLocation(Alignment.RIGHT, 30, Unit.PX), "") {
                public IRenderable newCell(TreeNode node, int level) {
                    return null;
                }

                public Component newCell(MarkupContainer parent, String id, final TreeNode node, int level) {
                    return new LinkPanel(id, GO_DOWN, node) {
                        @Override
                        protected void handle(TreeNode node, AjaxRequestTarget target) {
                            DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node;
                            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node1.getParent();
                            int index = defaultTreeModel.getIndexOfChild(parent, node1);
                            defaultTreeModel.removeNodeFromParent(node1);
                            defaultTreeModel.insertNodeInto(node1, parent, index + 1);
                            tree.getTreeState().expandNode(parent);
                            tree.invalidateAll();
                            tree.modelChanged();
                            tree.updateTree(target);
                        }

                        @Override
                        protected boolean show() {
                            if (node.getParent() == null || defaultTreeModel.getIndexOfChild(node.getParent(),
                                    node) == defaultTreeModel.getChildCount(node.getParent()) - 1) {
                                return false;
                            }
                            return true;
                        }
                    };
                }
            } };
    Form form = new Form("form");
    form.setOutputMarkupId(true);
    add(form);
    //
    defaultTreeModel = createTreeModel(tasks);
    tree = new TreeTable("treeTable", defaultTreeModel, columns);
    tree.setOutputMarkupId(true);
    tree.getTreeState().collapseAll();
    form.add(tree);
    form.add(new AjaxButton("submit") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form1) {
            Task rootTask = getTaskStructure((DefaultMutableTreeNode) defaultTreeModel.getRoot());
            taskManager.saveTasks(EditableTreeTablePanel.this.project, rootTask.getSubtasks());
        }
    });
}

From source file:com.visural.wicket.util.InvokeClientSideFormSubmitHandlerDecorator.java

License:Apache License

public InvokeClientSideFormSubmitHandlerDecorator(Form form) {
    form.setOutputMarkupId(true);
    formMarkupId = form.getMarkupId();
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.articles.ArticlesPage.java

License:Apache License

public ArticlesPage() {

    setPageTitle(ResourceUtils.getModel("title.page.articles"));
    add(new ButtonPageMenu("leftMenu", ArticlesPageLeftMenu.values()));

    // title component
    final Label pageTitle = new Label("title", ResourceUtils.getModel("pageTitle.allArticles"));
    pageTitle.setOutputMarkupId(true);/*w w  w.j a va2  s. c  o m*/
    add(pageTitle);

    // internal articles container
    final WebMarkupContainer internalContainer = new WebMarkupContainer("internalContainer");
    internalContainer.setOutputMarkupPlaceholderTag(true);
    add(internalContainer);

    // linkedin articles container
    final WebMarkupContainer linkedInContainer = new WebMarkupContainer("linkedInContainer");
    linkedInContainer.setOutputMarkupPlaceholderTag(true);
    add(linkedInContainer);

    // show configuration form
    Form<Void> form = new Form<Void>("form");
    form.setOutputMarkupId(true);
    add(form);
    final Model<Boolean> internalModel = new Model<Boolean>(Boolean.TRUE);
    final Model<Boolean> linkedInModel = new Model<Boolean>(Boolean.TRUE);
    form.add(new AjaxCheckBox("showInternal", internalModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updatePageTitleAndView(pageTitle, internalContainer, linkedInContainer, internalModel,
                    linkedInModel, target);
        }

    });
    form.add(new AjaxCheckBox("showLinkedIn", linkedInModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updatePageTitleAndView(pageTitle, internalContainer, linkedInContainer, internalModel,
                    linkedInModel, target);
        }
    });

    // linkedin articles components
    Group groupDetails = linkedInManager.getGroupDetails();
    linkedInContainer.add(new Label("groupDetails.name", new PropertyModel<Group>(groupDetails, "name")));
    linkedInContainer
            .add(new Label("groupDetails.description", new PropertyModel<Group>(groupDetails, "description")));

    // internal articles components
    Person loggedPerson = EEGDataBaseSession.get().getLoggedUser();
    List<Article> list = articleFacade.getArticlesForUser(loggedPerson);
    // list of internal articles with page control
    PageableListView<Article> articlesListView = new PageableListView<Article>("articles", list,
            ARTICLES_PER_PAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Article> item) {
            item.add(new ArticleListItemPanel("item", item.getModel()));
        }
    };
    internalContainer.add(new AjaxPagingNavigator("topPaginator", articlesListView));
    internalContainer.add(new AjaxPagingNavigator("bottomPaginator", articlesListView));
    internalContainer.add(articlesListView);

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentOptParamValueFormPage.java

License:Apache License

public ExperimentOptParamValueFormPage(final PageParameters parameters) {

    setPageTitle(ResourceUtils.getModel("pageTitle.addExperimentOptionalParameter"));

    add(new ButtonPageMenu("leftMenu", ExperimentsPageLeftMenu.values()));
    final Experiment experiment = experimentFacade.read(parseParameters(parameters));

    boolean allowed = true;
    if ((!securityFacade.userIsOwnerOrCoexperimenter(experiment.getExperimentId()))
            && (!securityFacade.isAdmin())) {
        warn(ResourceUtils.getString("error.mustBeOwnerOfExperimentOrCoexperimenter"));
        allowed = false;//from   ww  w .ja va 2s  .com
    }

    final CompoundPropertyModel<ExperimentOptParamVal> model = new CompoundPropertyModel<ExperimentOptParamVal>(
            new ExperimentOptParamVal());
    final Form<ExperimentOptParamVal> form = new Form<ExperimentOptParamVal>("form");
    TextField<String> textField = new TextField<String>("paramValue");
    textField.setLabel(ResourceUtils.getModel("label.parameterValue"));
    textField.setRequired(true);
    form.add(textField);
    form.setOutputMarkupId(true);
    form.setModel(model);
    form.setVisibilityAllowed(allowed);

    List<ExperimentOptParamDef> paramList = facade
            .getRecordsByGroup(experiment.getResearchGroup().getResearchGroupId());
    ChoiceRenderer<ExperimentOptParamDef> renderer = new ChoiceRenderer<ExperimentOptParamDef>("paramName",
            "experimentOptParamDefId");
    final DropDownChoice<ExperimentOptParamDef> paramChoice = new DropDownChoice<ExperimentOptParamDef>(
            "paramChoice", new Model<ExperimentOptParamDef>(), paramList, renderer);

    paramChoice.setLabel(ResourceUtils.getModel("label.parameterType"));
    paramChoice.add(new AjaxFormComponentUpdatingBehavior("OnChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            int experimentOptParamDefId = paramChoice.getModelObject().getExperimentOptParamDefId();
            ExperimentOptParamValId id = new ExperimentOptParamValId(experiment.getExperimentId(),
                    experimentOptParamDefId);

            ExperimentOptParamVal entity = facade.read(id);
            form.setModelObject(entity == null ? new ExperimentOptParamVal() : entity);

            target.add(form);
        }
    });
    paramChoice.setRequired(true);
    form.add(paramChoice);

    form.add(new AjaxButton("submit", ResourceUtils.getModel("button.addExperimentOptionalParameter")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedback());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            ExperimentOptParamVal newValue = model.getObject();
            ExperimentOptParamDef experimentOptParamDef = paramChoice.getModelObject();
            ExperimentOptParamValId id = new ExperimentOptParamValId(experiment.getExperimentId(),
                    experimentOptParamDef.getExperimentOptParamDefId());
            newValue.setExperiment(experiment);

            ExperimentOptParamVal val = facade.read(id);

            if (newValue.getId() == null) {
                if (val != null) { // field already exists
                    error(ResourceUtils.getString("invalid.paramIdAlreadyInserted"));
                } else {
                    newValue.setId(id);
                    facade.create(newValue);
                }
            } else {
                facade.update(newValue);
            }

            setResponsePage(ExperimentsDetailPage.class, parameters);
        }

    });

    add(form);
}

From source file:de.alpharogroup.wicket.components.examples.fragment.swapping.person.EditPersonPanel.java

License:Apache License

public EditPersonPanel(final String id, final IModel<PersonBean> model) {
    super(id, model);
    setOutputMarkupId(true);//from   w ww  .ja v  a2s  .  c  om
    setDefaultModel(model);
    final Form<PersonBean> form = new Form<PersonBean>("editPersonForm");
    form.setOutputMarkupId(true);
    add(form);
    form.add(new TextField<String>("firstName").setOutputMarkupId(true));
    form.add(new TextField<String>("lastName").setOutputMarkupId(true));
    form.add(new TextField<String>("gender").setOutputMarkupId(true));
    form.add(new TextField<String>("age").setOutputMarkupId(true));
    form.add(newSubmitButton("submit", form));
}

From source file:de.alpharogroup.wicket.components.factory.ComponentFactory.java

License:Apache License

/**
 * Factory method for create a new {@link Form}.
 *
 * @param <T>//from  w w  w  .  java2 s  .c o  m
 *            the generic type of the model
 * @param id
 *            the id
 * @param model
 *            the model
 * @return the {@link Form}.
 */
public static <T> Form<T> newForm(final String id, final IModel<T> model) {
    final Form<T> form = new Form<>(id, model);
    form.setOutputMarkupId(true);
    return form;
}

From source file:de.codepitbull.session.HomePage.java

License:Apache License

public HomePage(final PageParameters parameters) {
    Form kaffeeFormular = new Form(KAFFEE_FORMULAR);
    kaffeeFormular.setOutputMarkupId(true);
    add(kaffeeFormular);//from   ww  w . j  a  v  a  2  s.c o m

    kaffeeFormular.add(new Label(ANZAHL_KAFFEE, new PropertyModel<Integer>(this, "session.anzahlKaffee"))
            .setOutputMarkupId(true));
    kaffeeFormular.add(new TextField<String>(LIEFER_ORT, new PropertyModel<String>(this, "session.lieferOrt"))
            .setOutputMarkupId(true));
    kaffeeFormular.add(new AjaxLink<Void>("mehrKaffee") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            ((KaffeeWebSession) KaffeeWebSession.get()).mehrKaffee();
            target.add(HomePage.this.get(KAFFEE_FORMULAR));
        }
    });
    kaffeeFormular.add(new AjaxLink<Void>("wenigerKaffee") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            ((KaffeeWebSession) KaffeeWebSession.get()).wenigerKaffee();
            target.add(HomePage.this.get(KAFFEE_FORMULAR));
        }
    });
    kaffeeFormular.add(new AjaxSubmitLink("submitLink") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            ((KaffeeWebSession) KaffeeWebSession.get()).bestellungAbschicken();
            target.add(HomePage.this.get(KAFFEE_FORMULAR));
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
        }
    });
}

From source file:eu.uqasar.web.dashboard.DashboardEditPage.java

License:Apache License

/**
 * /*w ww.  j av a2 s .co m*/
 * @return
 */
private Form<Dashboard> newDashboardForm() {
    Form<Dashboard> form = new InputValidationForm<>("form");
    form.setOutputMarkupId(true);
    return form;
}