List of usage examples for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setVisible
public final Component setVisible(final boolean visible)
From source file:jp.go.nict.langrid.management.web.view.page.language.component.form.panel.RepeatingLanguagePathPanel.java
License:Open Source License
private void setLanguagePathComponents(final RepeatingView repeater, String metaKey) { AbstractLanguagePathPanel panel = makeLanguagePathPanel(pathType, metaKey); repeater.add(panel);/*from w w w .ja v a2s.c o m*/ AjaxSubmitLink link = new AjaxSubmitLink("removePathLink") { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { if (!isRemovableComponent()) { return; } repeater.remove(getParent()); Iterator ite = repeater.iterator(); while (ite.hasNext()) { AbstractLanguagePathPanel panel = (AbstractLanguagePathPanel) ite.next(); if (repeater.size() == 1) { panel.switchVisible(); } } setRewriteComponent(target); } private static final long serialVersionUID = 1L; }; link.setDefaultFormProcessing(false).setVisible(!pathType.equals(LanguagePathType.UNKNOWN)) .setOutputMarkupPlaceholderTag(true); panel.add(link); if (repeater.size() == 1) { link.setVisible(false); } panel.addVisibleComponent(link); }
From source file:org.geoserver.taskmanager.web.ConfigurationPage.java
License:Open Source License
@Override public void onInitialize() { super.onInitialize(); add(dialog = new GeoServerDialog("dialog")); add(new WebMarkupContainer("init").setVisible(initMode)); Form<Configuration> form = new Form<Configuration>("configurationForm", configurationModel); add(form);/*from ww w. ja v a2 s . co m*/ AjaxSubmitLink saveButton = saveOrApplyButton("save", true); saveButton.setOutputMarkupId(true); form.add(saveButton); AjaxSubmitLink applyButton = saveOrApplyButton("apply", false); form.add(applyButton); form.add(new TextField<String>("name", new PropertyModel<String>(configurationModel, "name")) { private static final long serialVersionUID = -3736209422699508894L; @Override public boolean isRequired() { return form.findSubmittingButton() == saveButton || form.findSubmittingButton() == applyButton; } }); List<String> workspaces = new ArrayList<String>(); for (WorkspaceInfo wi : GeoServerApplication.get().getCatalog().getWorkspaces()) { if (wi.getName().equals(configurationModel.getObject().getWorkspace()) || TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(), wi)) { workspaces.add(wi.getName()); } } boolean canBeNull = GeoServerApplication.get().getCatalog().getDefaultWorkspace() != null && TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(), GeoServerApplication.get().getCatalog().getDefaultWorkspace()); form.add(new DropDownChoice<String>("workspace", new PropertyModel<String>(configurationModel, "workspace"), workspaces).setNullValid(canBeNull).setRequired(!canBeNull)); TextField<String> name = new TextField<String>("description", new PropertyModel<String>(configurationModel, "description")); form.add(name); //the attributes panel attributesModel = new AttributesModel(configurationModel); form.add(attributesPanel = attributesPanel()); attributesPanel.setFilterVisible(false); attributesPanel.setSelectable(false); attributesPanel.setPageable(false); attributesPanel.setSortable(false); attributesPanel.setOutputMarkupId(true); form.add(addButton().setOutputMarkupId(true)); // the removal button form.add(remove = removeButton()); remove.setOutputMarkupId(true); remove.setEnabled(false); //the tasks panel tasksModel = new TasksModel(configurationModel); form.add(tasksPanel = tasksPanel()); tasksPanel.setFilterVisible(false); tasksPanel.setPageable(false); tasksPanel.setSortable(false); tasksPanel.setOutputMarkupId(true); //the batches panel form.add(batchesPanel = new BatchesPanel("batchesPanel", configurationModel)); batchesPanel.setOutputMarkupId(true); form.add(new AjaxLink<Object>("cancel") { private static final long serialVersionUID = -6892944747517089296L; @Override public void onClick(AjaxRequestTarget target) { //restore tasks configurationModel.getObject().getTasks().clear(); configurationModel.getObject().getTasks().putAll(oldTasks); //restore batches configurationModel.getObject().getBatches().clear(); configurationModel.getObject().getBatches().putAll(oldBatches); doReturn(); } }); if (initMode) { form.get("addNew").setEnabled(false); form.get("removeSelected").setEnabled(false); batchesPanel.get("addNew").setEnabled(false); batchesPanel.get("removeSelected").setEnabled(false); saveButton.setVisible(false); } if (configurationModel.getObject().getId() != null && !TaskManagerBeans.get().getSecUtil() .isAdminable(getSession().getAuthentication(), configurationModel.getObject())) { form.get("name").setEnabled(false); form.get("workspace").setEnabled(false); form.get("description").setEnabled(false); attributesPanel.setEnabled(false); form.get("addNew").setEnabled(false); form.get("removeSelected").setEnabled(false); tasksPanel.setEnabled(false); batchesPanel.get("addNew").setEnabled(false); batchesPanel.get("removeSelected").setEnabled(false); saveButton.setEnabled(false); applyButton.setEnabled(false); } }
From source file:org.sakaiproject.attendance.tool.pages.panels.AttendanceRecordFormDataPanel.java
License:Educational Community License
private void createCommentBox(final Form<AttendanceRecord> rF) { commentContainer = new WebMarkupContainer("comment-container"); commentContainer.setOutputMarkupId(true); noComment = new WebMarkupContainer("no-comment"); noComment.setOutputMarkupId(true);/*from w w w . jav a 2 s . co m*/ yesComment = new WebMarkupContainer("yes-comment"); yesComment.setOutputMarkupId(true); if (recordIModel.getObject().getComment() != null && !recordIModel.getObject().getComment().equals("")) { noComment.setVisible(false); } else { yesComment.setVisible(false); } commentContainer.add(noComment); commentContainer.add(yesComment); final TextArea<String> commentBox = new TextArea<String>("comment", new PropertyModel<String>(this.recordIModel, "comment")); final AjaxSubmitLink saveComment = new AjaxSubmitLink("save-comment") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { super.onSubmit(target, form); if (recordIModel.getObject().getComment() != null && !recordIModel.getObject().getComment().equals("")) { noComment.setVisible(false); yesComment.setVisible(true); } else { noComment.setVisible(true); yesComment.setVisible(false); } commentContainer.addOrReplace(noComment); commentContainer.addOrReplace(yesComment); for (Component c : ajaxTargets) { target.add(c); } } }; commentContainer.add(saveComment); commentContainer.add(commentBox); ajaxTargets.add(commentContainer); if (restricted) { commentContainer.setVisible(showCommentsToStudents); saveComment.setVisible(!showCommentsToStudents); commentBox.setEnabled(!showCommentsToStudents); noComment.setVisible(!showCommentsToStudents); commentContainer.add(new Label("add-header", new ResourceModel("attendance.record.form.view.comment"))); } else { commentContainer.add(new Label("add-header", new ResourceModel("attendance.record.form.add.comment"))); } rF.add(commentContainer); }