List of usage examples for org.apache.wicket.markup.html.form Form getModel
@SuppressWarnings("unchecked") default IModel<T> getModel()
From source file:au.org.theark.lims.web.component.inventory.form.AbstractInventoryDetailForm.java
License:Open Source License
/** * /*ww w .j a v a 2 s . co m*/ * @param id * @param feedbackPanel * @param detailContainer * @param containerForm * @param tree * @param node */ public AbstractInventoryDetailForm(String id, FeedbackPanel feedbackPanel, WebMarkupContainer detailContainer, Form<T> containerForm, InventoryLinkTree tree, DefaultMutableTreeNode node, Panel containerPaenl) { super(id, containerForm.getModel()); this.feedbackPanel = feedbackPanel; this.detailContainer = detailContainer; this.containerForm = containerForm; this.tree = tree; this.node = node; this.containerPanel = containerPaenl; setOutputMarkupPlaceholderTag(true); setModelObject(containerForm.getModelObject()); initialiseForm(); }
From source file:ca.travelagency.identity.SystemUserPage.java
License:Apache License
private void addSystemUserDetails(Form<SystemUser> form) { final IModel<SystemUser> model = form.getModel(); boolean persisted = DaoEntityModelFactory.isPersisted(model.getObject()); List<ITab> tabs = new ArrayList<ITab>(); final AjaxTabbedPanel<ITab> details = new AjaxTabbedPanel<ITab>(DETAILS, tabs); details.setOutputMarkupId(true);//from w w w .j a va 2 s . co m details.setVisible(persisted); add(details); if (persisted) { if (hasRole(Role.ADMIN)) { AbstractTab rolesTab = new AbstractTab(new ResourceModel("systemUser.panel.roles")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new RolesPanel(panelId, model); } }; tabs.add(rolesTab); } AbstractTab resetPasswordTab = new AbstractTab(new ResourceModel("systemUser.panel.resetPassword")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new ResetPasswordPanel(panelId, model); } }; tabs.add(resetPasswordTab); } }
From source file:ca.travelagency.invoice.destinations.DestinationFormPanel.java
License:Apache License
public DestinationFormPanel(final String id, InvoiceDestination invoiceDestination, final DestinationsPanel destinationsPanel) { super(id);/*from w w w .j ava2 s . c om*/ Validate.notNull(destinationsPanel); setOutputMarkupId(true); IModel<InvoiceDestination> model = DaoEntityModelFactory.make(invoiceDestination, InvoiceDestination.class); initialize(destinationsPanel, model.getObject()); final Form<InvoiceDestination> destinationForm = new Form<InvoiceDestination>(FORM, model); destinationForm.setOutputMarkupId(true); destinationForm.add(new ComponentFeedbackPanel(FEEDBACK, destinationForm)); destinationForm.add(new CityField(InvoiceDestination.Properties.departurePlace.name()).setRequired(true) .setLabel(new ResourceModel("invoice.departurePlace")).add(StringFieldHelper.maxLenFieldValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); destinationForm.add(new DateField(InvoiceDestination.Properties.departureDate.name()).setRequired(true) .setLabel(new ResourceModel("invoice.departureDate")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); destinationForm.add(new CityField(InvoiceDestination.Properties.arrivalPlace.name()).setRequired(true) .setLabel(new ResourceModel("invoice.arrivalPlace")).add(StringFieldHelper.maxLenFieldValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); destinationForm.add(new DateField(InvoiceDestination.Properties.arrivalDate.name()) .setLabel(new ResourceModel("invoice.arrivalDate")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); destinationForm.add(new SavePanelDetail<InvoiceDestination>(SAVE_BUTTON, destinationForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceDestination> form) { destinationsPanel.update(target, form.getModelObject()); IModel<InvoiceDestination> model = DaoEntityModelFactory.make(InvoiceDestination.class); form.setModel(model); initialize(destinationsPanel, model.getObject()); } }); destinationForm.add(new ResetPanel<InvoiceDestination>(RESET_BUTTON, destinationForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceDestination> form) { initialize(destinationsPanel, form.getModelObject()); } }.setResetModel(!DaoEntityModelFactory.isPersisted(model.getObject()))); destinationForm.add(new CancelPanel(CANCEL_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { DestinationRowPanel destinationRowPanel = new DestinationRowPanel(id, destinationForm.getModel(), destinationsPanel); DestinationFormPanel.this.replaceWith(destinationRowPanel); target.add(destinationRowPanel); } }.setVisible(invoiceDestination != null)); add(destinationForm); }
From source file:ca.travelagency.invoice.InvoicePage.java
License:Apache License
private void addInvoiceDetails(Form<Invoice> form) { final IModel<Invoice> model = form.getModel(); boolean persisted = DaoEntityModelFactory.isPersisted(model.getObject()); List<ITab> tabs = new ArrayList<ITab>(); final AjaxTabbedPanel<ITab> invoiceDetails = new AjaxTabbedPanel<ITab>(DETAILS, tabs); invoiceDetails.setOutputMarkupId(true); invoiceDetails.setVisible(persisted); add(invoiceDetails);//from ww w. j a v a2 s. c o m if (persisted) { tabs.add(new AbstractTab(new ResourceModel("invoice.destinations")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new DestinationsPanel(panelId, model); } }); tabs.add(new AbstractTab(new ResourceModel("invoice.travelers")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new TravelersPanel(panelId, model); } }); tabs.add(new AbstractTab(new ResourceModel("invoice.items")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new ItemsPanel(panelId, model, totalsPanel); } }); tabs.add(new AbstractTab(new ResourceModel("invoice.notes")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new NotesPanel(panelId, model); } }); tabs.add(new AbstractTab(new ResourceModel("invoice.payments")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(String panelId) { return new PaymentsPanel(panelId, model, totalsPanel); } }); } }
From source file:ca.travelagency.invoice.items.ItemFormPanel.java
License:Apache License
public ItemFormPanel(final String id, InvoiceItem invoiceItem, final ItemsPanel itemsPanel) { super(id);//from ww w .jav a2 s . c o m Validate.notNull(itemsPanel); setOutputMarkupId(true); IModel<InvoiceItem> model = DaoEntityModelFactory.make(invoiceItem, InvoiceItem.class); initialize(model.getObject(), itemsPanel); final Form<InvoiceItem> itemForm = new Form<InvoiceItem>(FORM, model); itemForm.setOutputMarkupId(true); itemForm.add(new ComponentFeedbackPanel(FEEDBACK, itemForm)); itemForm.add(new ProductField(InvoiceItem.Properties.description.name()).setRequired(true) .setLabel(new ResourceModel("itemProduct")).add(StringFieldHelper.maxLenFieldValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new SupplierField(InvoiceItem.Properties.supplier.name()).setRequired(true) .setLabel(new ResourceModel("itemSupplier")).add(StringFieldHelper.maxLenFieldValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<BigDecimal>(InvoiceItem.Properties.commission.name()) .setLabel(new ResourceModel("itemCommission")).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<BigDecimal>(InvoiceItem.Properties.taxOnCommission.name()) .setLabel(new ResourceModel("itemHSTOnCommission")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<BigDecimal>(InvoiceItem.Properties.price.name()).setRequired(true) .setLabel(new ResourceModel("itemPrice")).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<BigDecimal>(InvoiceItem.Properties.tax.name()) .setLabel(new ResourceModel("itemTax")).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new CancelDepartureField(InvoiceItem.Properties.cancelBeforeDeparture.name()) .setLabel(new ResourceModel("itemCancelBeforeDeparture")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new ChangeDepartureField(InvoiceItem.Properties.changeBeforeDeparture.name()) .setLabel(new ResourceModel("itemChangeBeforeDeparture")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new ChangeDepartureField(InvoiceItem.Properties.changeAfterDeparture.name()) .setLabel(new ResourceModel("itemChangeAfterDeparture")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<Integer>(InvoiceItem.Properties.qty.name()).setRequired(true) .setLabel(new ResourceModel("itemQty")).add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new TextField<String>(InvoiceItem.Properties.bookingNumber.name()) .setLabel(new ResourceModel("itemBookingNumber")).add(StringFieldHelper.maxLenFieldValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(new DateField(InvoiceItem.Properties.bookingDate.name()) .setLabel(new ResourceModel("itemBookingDate")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); itemForm.add(commissionStatusField(model)); itemForm.add(new SavePanelDetail<InvoiceItem>(SAVE_BUTTON, itemForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceItem> form) { InvoiceItem invoiceItem = form.getModelObject(); itemsPanel.update(target, invoiceItem); IModel<InvoiceItem> model = DaoEntityModelFactory.make(InvoiceItem.class); form.setModel(model); initialize(model.getObject(), itemsPanel); } }); itemForm.add(new ResetPanel<InvoiceItem>(RESET_BUTTON, itemForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceItem> form) { initialize(form.getModelObject(), itemsPanel); } }.setResetModel(!DaoEntityModelFactory.isPersisted(model.getObject()))); itemForm.add(new CancelPanel(CANCEL_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { ItemRowPanel itemRowPanel = new ItemRowPanel(id, itemForm.getModel(), itemsPanel); ItemFormPanel.this.replaceWith(itemRowPanel); target.add(itemRowPanel); } }.setVisible(invoiceItem != null)); add(itemForm); }
From source file:ca.travelagency.invoice.notes.NoteFormPanel.java
License:Apache License
public NoteFormPanel(final String id, InvoiceNote invoiceNote, final NotesPanel notesPanel) { super(id);// w w w .j a v a2s.c o m Validate.notNull(notesPanel); setOutputMarkupId(true); IModel<InvoiceNote> model = DaoEntityModelFactory.make(invoiceNote, InvoiceNote.class); final Form<InvoiceNote> noteForm = new Form<InvoiceNote>(FORM, model); noteForm.setOutputMarkupId(true); noteForm.add(new ComponentFeedbackPanel(FEEDBACK, noteForm)); noteForm.add(new TextArea<String>(InvoiceNote.Properties.text.name()).setRequired(true) .setLabel(new ResourceModel("invoiceNote.note")).add(StringFieldHelper.maxLenAreaValidator()) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); noteForm.add(new CheckBox(InvoiceNote.Properties.privateNote.name()) .setLabel(new ResourceModel("invoiceNote.private")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); noteForm.add(new SavePanelDetail<InvoiceNote>(SAVE_BUTTON, noteForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceNote> form) { notesPanel.update(target, form.getModelObject()); IModel<InvoiceNote> model = DaoEntityModelFactory.make(InvoiceNote.class); form.setModel(model); } }); noteForm.add(new ResetPanel<InvoiceNote>(RESET_BUTTON, noteForm) .setResetModel(!DaoEntityModelFactory.isPersisted(model.getObject()))); noteForm.add(new CancelPanel(CANCEL_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { NoteRowPanel noteRowPanel = new NoteRowPanel(id, noteForm.getModel(), notesPanel); NoteFormPanel.this.replaceWith(noteRowPanel); target.add(noteRowPanel); } }.setVisible(invoiceNote != null)); add(noteForm); }
From source file:ca.travelagency.invoice.payments.PaymentFormPanel.java
License:Apache License
public PaymentFormPanel(final String id, InvoicePayment invoicePayment, final PaymentsPanel paymentsPanel) { super(id);/*from www . j ava 2 s . c om*/ Validate.notNull(paymentsPanel); setOutputMarkupId(true); IModel<InvoicePayment> model = DaoEntityModelFactory.make(invoicePayment, InvoicePayment.class); final Form<InvoicePayment> paymentForm = new Form<InvoicePayment>(FORM, model); paymentForm.setOutputMarkupId(true); paymentForm.add(new ComponentFeedbackPanel(FEEDBACK, paymentForm)); paymentForm.add(new RequiredTextField<BigDecimal>(InvoicePayment.Properties.amount.name()) .setLabel(new ResourceModel("invoice.paymentAmount")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); paymentForm.add(new CheckBox(InvoicePayment.Properties.reconciled.name()) .setLabel(new ResourceModel("invoice.paymentReconciled")) .add(new FieldDecorator(), new AjaxOnBlurBehavior()).setVisible(hasRole(Role.ADMIN))); paymentForm.add(new DropDownChoice<PaymentType>(InvoicePayment.Properties.paymentType.name(), Arrays.asList(PaymentType.values())).setRequired(true) .setLabel(new ResourceModel("invoice.paymentType")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); paymentForm.add(new DateField(InvoicePayment.Properties.date.name()).setRequired(true) .setLabel(new ResourceModel("invoice.paymentDate")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); paymentForm.add(new SavePanelDetail<InvoicePayment>(SAVE_BUTTON, paymentForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoicePayment> form) { paymentsPanel.update(target, form.getModelObject()); IModel<InvoicePayment> model = DaoEntityModelFactory.make(InvoicePayment.class); form.setModel(model); } }); paymentForm.add(new ResetPanel<InvoicePayment>(RESET_BUTTON, paymentForm) .setResetModel(!DaoEntityModelFactory.isPersisted(model.getObject()))); paymentForm.add(new CancelPanel(CANCEL_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { PaymentRowPanel paymentRowPanel = new PaymentRowPanel(id, paymentForm.getModel(), paymentsPanel); PaymentFormPanel.this.replaceWith(paymentRowPanel); target.add(paymentRowPanel); } }.setVisible(invoicePayment != null)); add(paymentForm); }
From source file:ca.travelagency.invoice.travelers.TravelerFormPanel.java
License:Apache License
public TravelerFormPanel(final String id, InvoiceTraveler invoiceTraveler, final TravelersPanel travelersPanel) { super(id);/*from w ww . j a v a2s. c o m*/ Validate.notNull(travelersPanel); setOutputMarkupId(true); IModel<InvoiceTraveler> model = DaoEntityModelFactory.make(invoiceTraveler, InvoiceTraveler.class); initialize(model.getObject()); final Form<InvoiceTraveler> travelerForm = new Form<InvoiceTraveler>(FORM, model); travelerForm.setOutputMarkupId(true); travelerForm.add(new ComponentFeedbackPanel(FEEDBACK, travelerForm)); travelerForm.add(new SalutationField(InvoiceTraveler.Properties.salutation.name()) .setLabel(new ResourceModel("travelerFormPanel.salutation")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new LastNameField(InvoiceTraveler.Properties.lastName.name()) .setLabel(new ResourceModel("travelerFormPanel.lastName")).setRequired(true) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new FirstNameField(InvoiceTraveler.Properties.firstName.name()) .setLabel(new ResourceModel("travelerFormPanel.firstName")).setRequired(true) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new TravelDocumentField(InvoiceTraveler.Properties.documentType.name()) .setLabel(new ResourceModel("travelerFormPanel.document")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new TextField<String>(InvoiceTraveler.Properties.documentNumber.name()) .setLabel(new ResourceModel("travelerFormPanel.documentNumber")) .add(StringFieldHelper.maxLenFieldValidator()).add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new BirthDateField(InvoiceTraveler.Properties.dateOfBirth.name()) .setLabel(new ResourceModel("travelerFormPanel.dateOfBirth")) .add(new FieldDecorator(), new AjaxOnBlurBehavior())); travelerForm.add(new SavePanelDetail<InvoiceTraveler>(SAVE_BUTTON, travelerForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceTraveler> form) { InvoiceTraveler travelerItem = form.getModelObject(); travelersPanel.update(target, travelerItem); IModel<InvoiceTraveler> model = DaoEntityModelFactory.make(InvoiceTraveler.class); form.setModel(model); initialize(model.getObject()); } }); travelerForm.add(new ResetPanel<InvoiceTraveler>(RESET_BUTTON, travelerForm) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<InvoiceTraveler> form) { initialize(form.getModelObject()); } }.setResetModel(!DaoEntityModelFactory.isPersisted(model.getObject()))); travelerForm.add(new CancelPanel(CANCEL_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { TravelerRowPanel travelerRowPanel = new TravelerRowPanel(id, travelerForm.getModel(), travelersPanel); TravelerFormPanel.this.replaceWith(travelerRowPanel); target.add(travelerRowPanel); } }.setVisible(invoiceTraveler != null)); travelerForm.add(new TravelerLookupLink(LOOKUP_TRAVELERS, travelerForm)); add(travelerForm); }
From source file:com.asptt.plongee.resa.ui.web.wicket.page.admin.GererPlongeeAOuvrirTwo.java
public GererPlongeeAOuvrirTwo(final Plongee plongee) { setPageTitle("Ouvrir plongee"); modalPlongee = new ModalWindow("modalPlongee"); modalPlongee.setTitle("This is modal window with panel content."); modalPlongee.setCookieName("modal-plongee"); add(modalPlongee);//from w w w . j a va2 s .c o m CompoundPropertyModel<Plongee> modelPlongee = new CompoundPropertyModel<Plongee>(plongee); List<Adherent> dps; dps = getResaSession().getAdherentService().rechercherDPsNonInscrits( getResaSession().getAdherentService().rechercherAdherentsActifs(), plongee); dps.removeAll(plongee.getParticipants()); IChoiceRenderer<Adherent> rendDp = new ChoiceRenderer<Adherent>("nom", "nom"); final Palette<Adherent> palDp = new Palette<Adherent>("paletteDps", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(dps), rendDp, 10, false) { }; List<Adherent> pilotes = getResaSession().getAdherentService().rechercherPilotesNonInscrits( getResaSession().getAdherentService().rechercherAdherentsActifs(), plongee); pilotes.removeAll(plongee.getParticipants()); IChoiceRenderer<Adherent> rendPilote = new ChoiceRenderer<Adherent>("nom", "nom"); final Palette<Adherent> palPilote = new Palette<Adherent>("palettePilotes", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(pilotes), rendPilote, 10, false) { }; final Form<Plongee> form = new Form<Plongee>("form") { private static final long serialVersionUID = 4611593854191923422L; @Override protected void onSubmit() { IModel<?> modelDps = palDp.getDefaultModel(); List<Adherent> dps = (List<Adherent>) modelDps.getObject(); IModel<?> modelPilotes = palPilote.getDefaultModel(); List<Adherent> pilotes = (List<Adherent>) modelPilotes.getObject(); /* * Impossible de gerer les doublons avec un HashSet Alors on le * fait ' la main' */ List<String> idInscrits = new ArrayList<String>(); for (Adherent adherent : dps) { if (!idInscrits.contains(adherent.getNumeroLicense())) { idInscrits.add(adherent.getNumeroLicense()); } } for (Adherent adherent : pilotes) { if (!idInscrits.contains(adherent.getNumeroLicense())) { idInscrits.add(adherent.getNumeroLicense()); } } /* * Maintenant qu'on la liste des id on reconstitue une liste * d'adherent */ List<Adherent> adhInscrits = new ArrayList<Adherent>(); for (String id : idInscrits) { adhInscrits.add(getResaSession().getAdherentService().rechercherAdherentParIdentifiant(id)); } /* * Reste plus qu'a inscrire... */ for (Adherent adh : adhInscrits) { try { getResaSession().getPlongeeService().inscrireAdherent(plongee, adh, PlongeeMail.PAS_DE_MAIL); } catch (ResaException e) { e.printStackTrace(); ErrorPage ep = new ErrorPage(e); setResponsePage(ep); } } PageParameters param = new PageParameters(); param.put("plongeeAOuvrir", plongee); param.put("inscrits", adhInscrits); //setResponsePage(new GererPlongeeAOuvrirThree(plongee)); setResponsePage(new InscriptionConfirmationPlongeePage(plongee)); }//fin du onSubmit() }; form.setModel(modelPlongee); // Le nombre max. de places, pour info maxPlaces = new TextField<Integer>("nbMaxPlaces"); maxPlaces.setOutputMarkupId(true); form.add(maxPlaces.setEnabled(false)); // Le niveau mini. des plongeurs, pour info niveauMinimum = new TextField<Integer>("niveauMinimum"); niveauMinimum.setOutputMarkupId(true); form.add(niveauMinimum.setEnabled(false)); // La Date de visibilite de la plonge, pour info dateVisible = new TextField<Date>("dateVisible"); dateVisible.setOutputMarkupId(true); form.add(dateVisible.setEnabled(false)); // Ajout des palettes form.add(palDp); form.add(palPilote); add(form); form.add(new IndicatingAjaxLink("change") { @Override public void onClick(AjaxRequestTarget target) { replaceModalWindow(target, form.getModel()); modalPlongee.show(target); } }); }
From source file:com.asptt.plongee.resa.wicket.page.admin.plongee.GererPlongeeAOuvrirTwo.java
public GererPlongeeAOuvrirTwo(final Plongee plongee) { setPageTitle("Ouvrir plongee"); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true);//from w w w . j a v a 2 s . c o m add(feedback); modalPlongee = new ModalWindow("modalPlongee"); modalPlongee.setTitle("This is modal window with panel content."); modalPlongee.setCookieName("modal-plongee"); add(modalPlongee); CompoundPropertyModel<Plongee> modelPlongee = new CompoundPropertyModel<Plongee>(plongee); // Liste des DPs List<Adherent> dps; dps = ResaSession.get().getAdherentService().rechercherDPsNonInscrits( ResaSession.get().getAdherentService().rechercherAdherentsActifs(), plongee); //Suppression des adherents dj inscrits la plonge de la liste des DPs dps.removeAll(plongee.getParticipants()); // Init ChoiceRender des DPs IChoiceRenderer<Adherent> rendDp = new ChoiceRenderer<Adherent>("nom", "nom"); // Init de la palettes des DPs final Palette<Adherent> palDp = new Palette<Adherent>("paletteDps", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(dps), rendDp, 10, false) { }; //List des Pilotes List<Adherent> pilotes = ResaSession.get().getAdherentService().rechercherPilotesNonInscrits( ResaSession.get().getAdherentService().rechercherAdherentsActifs(), plongee); //Suppression des adherents dj inscrits la plonge de la liste des Pilotes pilotes.removeAll(plongee.getParticipants()); // Init ChoiceRender des Pilotes IChoiceRenderer<Adherent> rendPilote = new ChoiceRenderer<Adherent>("nom", "nom"); // Init de la palettes des Pilotes final Palette<Adherent> palPilote = new Palette<Adherent>("palettePilotes", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(pilotes), rendPilote, 10, false) { }; //Init de la Forme final Form<Plongee> form = new Form<Plongee>("form") { private static final long serialVersionUID = 4611593854191923422L; }; //Dfinition du model de la form == plongee form.setModel(modelPlongee); // Le nombre max. de places, pour info maxPlaces = new TextField<Integer>("nbMaxPlaces"); maxPlaces.setOutputMarkupId(true); form.add(maxPlaces.setEnabled(false)); // Le niveau mini. des plongeurs, pour info niveauMinimum = new TextField<Integer>("niveauMinimum"); niveauMinimum.setOutputMarkupId(true); form.add(niveauMinimum.setEnabled(false)); // La Date de visibilite de la plonge, pour info dateReservation = new TextField<Date>("dateReservation"); dateReservation.setOutputMarkupId(true); form.add(dateReservation.setEnabled(false)); //ajout du warning warning = new TextArea<String>("warning"); warning.setOutputMarkupId(true); form.add(warning.setEnabled(false)); // Ajout des palettes form.add(palDp); form.add(palPilote); // Ajout du lien pour modifier les caracteristiques de la plonge form.add(new IndicatingAjaxLink("change") { @Override public void onClick(AjaxRequestTarget target) { replaceModalWindow(target, form.getModel()); modalPlongee.show(target); } }); // Ajout du bouton submit IndicatingAjaxButton b_valider = new IndicatingAjaxButton("validDpPilote") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { IModel<?> modelDps = palDp.getDefaultModel(); List<Adherent> dps = (List<Adherent>) modelDps.getObject(); IModel<?> modelPilotes = palPilote.getDefaultModel(); List<Adherent> pilotes = (List<Adherent>) modelPilotes.getObject(); if (dps.size() != 1 || pilotes.size() != 1) { error("Un DP et un pilote doivent tre selectionns"); } else { /* * Impossible de gerer les doublons avec un HashSet Alors on le * fait ' la main' */ List<Adherent> l_dpPilote = new ArrayList<Adherent>(); l_dpPilote.add(dps.get(0)); if (!dps.get(0).getNumeroLicense().equalsIgnoreCase(pilotes.get(0).getNumeroLicense())) { l_dpPilote.add(pilotes.get(0)); } // Inscription du DP et Pilote for (Adherent adh : l_dpPilote) { try { ResaSession.get().getPlongeeService().inscrireAdherent(plongee, adh, PlongeeMail.PAS_DE_MAIL); } catch (ResaException e) { e.printStackTrace(); ErrorPage ep = new ErrorPage(e); setResponsePage(ep); } } PageParameters param = new PageParameters(); param.put("plongeeAOuvrir", plongee); param.put("inscrits", l_dpPilote); setResponsePage(new ListeInscritsPlongeePage(plongee)); } }//fin du onSubmit() @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }; form.add(new Link("cancel") { @Override public void onClick() { setResponsePage(GererPlongeeAOuvrirOne.class); } }); //add(new Button("cancel", new ResourceModel("button.cancel"))); form.add(b_valider); add(form); }