Example usage for org.apache.wicket.markup.html.form SubmitLink SubmitLink

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

Introduction

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

Prototype

public SubmitLink(String id, IModel<?> model) 

Source Link

Document

With this constructor the SubmitLink must be inside a Form.

Usage

From source file:com.googlecode.wicketwebbeans.actions.BeanSubmitButton.java

License:Apache License

/**
 * Construct a BeanSubmitButton. The link has a class of "beanSubmitButton" if label is a 
 * regular Label, otherwise the class is "beanSubmitImageButton".
 *
 * Note that updateFeedbackPanels(target) will not work if the action
 * makes you change context. In this case, you should avoid doing
 * something after BeanSubmitButton.this.onAction()
 *
 * @param id//from   w w w. j a  v a  2 s  . c  o  m
 * @param label
 * @param form
 * @param bean
 * @param confirmMsg if non-null, a confirm message will be displayed before the action is taken.
 *  If the answer is "Yes", the action is taken, otherwise it is canceled.
 * @param ajaxFlag if a string whose value is "true", the button's action is fired with an Ajax form submit.
 *  Otherwise if null or not "true", the button is fired with a regular form submit.
 * @param isDefault if "true", the button is invoked when enter is pressed on the form.
 */
private BeanSubmitButton(String id, final Component label, Form form, final Object bean,
        final String confirmMsg, String ajaxFlag, String isDefault) {
    super(id);

    setRenderBodyOnly(true);

    WebMarkupContainer button;
    if (Boolean.valueOf(ajaxFlag)) {
        button = new AjaxSubmitLink("button", form) {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form form) {
                BeanSubmitButton.this.onAction(target, form, bean);
                updateFeedbackPanels(target); // see comments in function javadoc
            }

            @Override
            protected void onError(AjaxRequestTarget target, Form form) {
                BeanSubmitButton.this.onError(target, form, bean);
                updateFeedbackPanels(target); // see comments in function javadoc
            }

            @Override
            protected IAjaxCallDecorator getAjaxCallDecorator() {
                return decorator;
            }

            @Override
            protected void onComponentTag(ComponentTag tag) {
                super.onComponentTag(tag);
                tag.put("class", (label instanceof Label ? "beanSubmitButton" : "beanSubmitImageButton"));
                tag.put("href", "javascript:void(0)"); // don't do href="#"
            }
        };
    } else {
        button = new SubmitLink("button", form) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onSubmit() {
                BeanSubmitButton.this.onAction(null, getForm(), bean);
            }

            @Override
            protected void onComponentTag(ComponentTag tag) {
                super.onComponentTag(tag);
                tag.put("class", (label instanceof Label ? "beanSubmitButton" : "beanSubmitImageButton"));
            }
        };
    }

    if (confirmMsg != null) {
        button.add(new AttributeModifier("onclick", true, null) {
            private static final long serialVersionUID = 1L;

            @Override
            protected String newValue(String currentValue, String replacementValue) {
                return "if (!confirm('" + confirmMsg + "')) return false; else { " + currentValue + " }";
            }
        });
    }

    if (Boolean.valueOf(isDefault)) {
        button.add(new SimpleAttributeModifier("id", "bfDefaultButton"));
    }

    button.setOutputMarkupId(true);
    add(button);
    button.add(label);
}

From source file:com.romeikat.datamessie.core.base.ui.panel.DocumentsFilterPanel.java

License:Open Source License

private void initialize() {
    final IModel<DocumentsFilterSettings> dfsModel = DataMessieSession.get().getDocumentsFilterSettingsModel();
    // Form//from w  ww  . j a v  a2  s. c o  m
    final Form<DocumentsFilterSettings> filterForm = new Form<DocumentsFilterSettings>("filterForm", dfsModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onError() {
            super.onError();
        }

        @Override
        protected void onSubmit() {
            final PageParameters pageParameters = getPage().getPageParameters();
            // Source
            final Long selectedSourceId = getSelectedSourceId();
            if (selectedSourceId == null) {
                pageParameters.remove("source");
            } else {
                pageParameters.set("source", selectedSourceId);
            }
            // Source type
            final Collection<Long> selectedSourceTypeIds = getSelectedSourceTypeIds();
            if (selectedSourceTypeIds == null || selectedSourceTypeIds.isEmpty()) {
                pageParameters.remove("sourcetypes");
            } else {
                pageParameters.set("sourcetypes", StringUtils.join(selectedSourceTypeIds, ","));
            }
            // Crawling
            final Long selectedCrawlingId = getSelectedCrawlingId();
            if (selectedCrawlingId == null) {
                pageParameters.remove("crawling");
            } else {
                pageParameters.set("crawling", selectedCrawlingId);
            }
            // From date
            final LocalDate selectedFromDate = getSelectedFromDate();
            final String fromDate = formatLocalDate(selectedFromDate);
            if (fromDate == null) {
                pageParameters.remove("from");
            } else {
                pageParameters.set("from", fromDate);
            }
            // To date
            final LocalDate selectedToDate = getSelectedToDate();
            final String toDate = formatLocalDate(selectedToDate);
            if (toDate == null) {
                pageParameters.remove("to");
            } else {
                pageParameters.set("to", toDate);
            }
            // Cleaned content is not processed as it is not included in the URL
            // Document IDs are not processed as they are not included in the URL
            // States
            final Collection<DocumentProcessingState> selectedStates = getSelectedStates();
            if (selectedStates == null || selectedStates.isEmpty()) {
                pageParameters.remove("states");
            } else {
                final List<Integer> statesOrdinals = new ArrayList<Integer>(selectedStates.size());
                for (final DocumentProcessingState selectedState : selectedStates) {
                    statesOrdinals.add(selectedState.ordinal());
                }
                Collections.sort(statesOrdinals);
                pageParameters.set("states", StringUtils.join(statesOrdinals, ","));
            }
        }
    };
    add(filterForm);

    // Submit link
    final SubmitLink submitLink = new SubmitLink("submit", filterForm);
    filterForm.add(submitLink);

    // Sources
    sourceIdFilter = new SourceIdFilter("sourceIdFilter", dfsModel);
    filterForm.add(sourceIdFilter);

    // Source types
    sourceTypeIdFilter = new SourceTypeIdFilter("sourceTypeIdFilter", dfsModel);
    filterForm.add(sourceTypeIdFilter);

    // Crawlings
    crawlingIdFilter = new CrawlingIdFilter("crawlingIdFilter", dfsModel);
    filterForm.add(crawlingIdFilter);

    // From date
    fromDateFilter = new LocalDateTextField("fromDateFilter",
            new PropertyModel<LocalDate>(dfsModel, "fromDate"), new StyleDateConverter("M-", false));
    filterForm.add(fromDateFilter);
    // From date picker
    final DatePicker fromDatePicker = new DatePicker();
    fromDatePicker.setShowOnFieldClick(true);
    fromDatePicker.setAutoHide(true);
    fromDateFilter.add(fromDatePicker);

    // To label
    toLabel = new Label("toLabel", Model.of("to"));
    filterForm.add(toLabel);

    // To date
    toDateFilter = new LocalDateTextField("toDateFilter", new PropertyModel<LocalDate>(dfsModel, "toDate"),
            new StyleDateConverter("M-", false));
    filterForm.add(toDateFilter);
    // To date picker
    final DatePicker toDatePicker = new DatePicker();
    toDatePicker.setShowOnFieldClick(true);
    toDatePicker.setAutoHide(true);
    toDateFilter.add(toDatePicker);

    // Cleaned content
    cleanedContentFilter = new CleanedContentFilter("cleanedContentFilter", dfsModel);
    filterForm.add(cleanedContentFilter);

    // Documents
    documentsFilter = new DocumentsFilter("documentsFilter", dfsModel);
    filterForm.add(documentsFilter);

    // State
    statesFilter = new DocumentProcessingStateFilter("statesFilter", dfsModel);
    filterForm.add(statesFilter);
}

From source file:com.tysanclan.site.projectewok.pages.member.justice.TruthSayerEditUserPage.java

License:Open Source License

public TruthSayerEditUserPage(User user) {
    super("Edit user");

    User givenUser = null;//from  ww  w .j a v a  2s  .c  o m
    if (user != null) {
        givenUser = userDao.load(user.getId());
    }

    Form<Void> form = new Form<Void>("userSearchForm") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit() {
            UserFilter filter = new UserFilter();
            filter.setUsername(get("username").getDefaultModelObjectAsString());
            User foundUser = userDao.getUniqueByFilter(filter);
            if (foundUser == null) {
                warn("Could not find user");
                return;
            }
            setResponsePage(new TruthSayerEditUserPage(foundUser));
        }
    };
    form.add(new TextField<String>("username",
            new Model<String>(givenUser != null ? givenUser.getUsername() : "")));
    SubmitLink submit = new SubmitLink("submit", form);
    submit.add(new ContextImage("search", "images/icons/magnifier.png"));
    form.add(submit);

    ConfirmationLink<User> removeAvatarLink = new ConfirmationLink<User>("removeAvatar",
            new Model<User>(givenUser), "Are you sure you want to delete this users avatar?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserAvatar(selectedUser.getId(), null);
                notificationService.notifyUser(selectedUser, "Your avatar has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    ConfirmationLink<User> removeSignatureLink = new ConfirmationLink<User>("removeSignature",
            new Model<User>(givenUser), "Are you sure you want to delete this users signature?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserSignature(selectedUser.getId(), "");
                notificationService.notifyUser(selectedUser, "Your signature has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    ConfirmationLink<User> removeCustomTitleLink = new ConfirmationLink<User>("removeCustomTitleLink",
            new Model<User>(givenUser), "Are you sure you want to delete this users custom title?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserCustomTitle(selectedUser.getId(), "");
                notificationService.notifyUser(selectedUser,
                        "Your custom title has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    removeAvatarLink.setEnabled(
            givenUser != null && givenUser.getImageURL() != null && !givenUser.getImageURL().isEmpty());
    removeSignatureLink.setEnabled(
            givenUser != null && givenUser.getSignature() != null && !givenUser.getSignature().isEmpty());
    removeCustomTitleLink.setEnabled(
            givenUser != null && givenUser.getCustomTitle() != null && !givenUser.getCustomTitle().isEmpty());

    removeAvatarLink.add(new ContextImage("delete", "images/icons/delete.png"));
    removeSignatureLink.add(new ContextImage("delete", "images/icons/delete.png"));
    removeCustomTitleLink.add(new ContextImage("delete", "images/icons/delete.png"));

    add(new Label("username", new Model<String>(givenUser != null ? givenUser.getUsername() : "")));
    add(removeAvatarLink);
    add(removeSignatureLink);
    add(removeCustomTitleLink);
    add(form);
}

From source file:com.userweave.components.image.uploadpage.IconUploadPage.java

License:Open Source License

@Override
protected WebMarkupContainer getAcceptButton(String componentId, final ModalWindow window) {
    return submitButton = new SubmitLink(componentId, getForm()) {
        private static final long serialVersionUID = 1L;

        @Override//w w w .  j a  v a  2  s  .c o  m
        public void onSubmit() {
            try {
                IconUploadPage.this.onSubmit(((FileUploadFragment) content).getFileUploadField());

                replaceAfterUpload();
                super.onSubmit();
            } catch (Exception e) {
                warn(e.getMessage());
            }
        }

    };
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.security.RegistrationForm.java

License:Apache License

public RegistrationForm(String id, final FeedbackPanel feedback) throws IOException {
    super(id, new CompoundPropertyModel<PersonFormObject>(new PersonFormObject()));

    EmailTextField email = new EmailTextField("email");
    email.setLabel(ResourceUtils.getModel("general.email"));
    email.setRequired(true);/*from   w w w . java  2s .  co  m*/
    add(email);

    PasswordTextField password = new PasswordTextField("password");
    password.setLabel(ResourceUtils.getModel("general.password"));
    password.setRequired(true);
    password.add(StringValidator.minimumLength(6));
    add(password);

    PasswordTextField passwordVerify = new PasswordTextField("passwordVerify");
    passwordVerify.setLabel(ResourceUtils.getModel("general.password.verify"));
    passwordVerify.setRequired(true);
    passwordVerify.add(StringValidator.minimumLength(6));
    add(passwordVerify);

    add(panelPerson = new PersonFormPanel<FullPersonDTO>("panelPerson",
            new CompoundPropertyModel<FullPersonDTO>(new FullPersonDTO()), educationLevelFacade));

    //        TextField<String> name = new TextField<String>("name");
    //        name.setLabel(ResourceUtils.getModel("general.name"));
    //        name.setRequired(true);
    //        name.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    //        add(name);
    //
    //        TextField<String> surname = new TextField<String>("surname");
    //        surname.setLabel(ResourceUtils.getModel("general.surname"));
    //        surname.setRequired(true);
    //        surname.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    //        add(surname);
    //
    //        DateTimeFieldPicker date = new DateTimeFieldPicker("dateOfBirth") {
    //
    //            private static final long serialVersionUID = 1L;
    //
    //            @Override
    //            public <C> IConverter<C> getConverter(Class<C> type) {
    //                return (IConverter<C>) new TimestampConverter();
    //            }
    //        };
    //        date.setLabel(ResourceUtils.getModel("general.dateofbirth"));
    //        //date.setRequired(true);
    //        add(date);
    //
    //
    //        TextField<String> address = new TextField<String>("address");
    //        address.setLabel(ResourceUtils.getModel("label.address"));
    //        add(address);
    //
    //        TextField<String> city = new TextField<String>("city");
    //        city.setLabel(ResourceUtils.getModel("label.city"));
    //        add(city);
    //
    //        TextField<String> state = new TextField<String>("state");
    //        state.setLabel(ResourceUtils.getModel("label.state"));
    //        add(state);
    //
    //        TextField<String> zipCode = new TextField<String>("zipCode");
    //        zipCode.setLabel(ResourceUtils.getModel("label.zipCode"));
    //        add(zipCode);
    //
    //        TextField<String> url = new TextField<String>("url");
    //        url.setLabel(ResourceUtils.getModel("label.url"));
    //        add(url);
    //
    //        TextField<String> phone = new TextField<String>("phone");
    //        phone.setLabel(ResourceUtils.getModel("label.phoneNumber"));
    //        add(phone);
    //
    //        TextField<String> organization = new TextField<String>("organization");
    //        organization.setLabel(ResourceUtils.getModel("label.organization"));
    //        add(organization);
    //
    //        TextField<String> jobTitle = new TextField<String>("jobTitle");
    //        jobTitle.setLabel(ResourceUtils.getModel("label.jobTitle"));
    //        add(jobTitle);
    //
    //        TextField<String> orgAddress = new TextField<String>("orgAddress");
    //        orgAddress.setLabel(ResourceUtils.getModel("label.address"));
    //        add(orgAddress);
    //
    //        TextField<String> orgCity = new TextField<String>("orgCity");
    //        orgCity.setLabel(ResourceUtils.getModel("label.city"));
    //        add(orgCity);
    //
    //        TextField<String> orgState = new TextField<String>("orgState");
    //        orgState.setLabel(ResourceUtils.getModel("label.state"));
    //        add(orgState);
    //
    //        TextField<String> orgZipCode = new TextField<String>("orgZipCode");
    //        orgZipCode.setLabel(ResourceUtils.getModel("label.zipCode"));
    //        add(orgZipCode);
    //
    //        TextField<String> orgUrl = new TextField<String>("orgUrl");
    //        orgUrl.setLabel(ResourceUtils.getModel("label.url"));
    //        add(orgUrl);
    //
    //        TextField<String> orgPhone = new TextField<String>("orgPhone");
    //        orgPhone.setLabel(ResourceUtils.getModel("label.phoneNumber"));
    //        add(orgPhone);
    //
    //        TextField<String> VAT = new TextField<String>("VAT");
    //        VAT.setLabel(ResourceUtils.getModel("label.VAT"));
    //        add(VAT);

    generateCaptchaImageAndPrepareValidation();
    add(captchaImage);

    TextField<String> controlText = new TextField<String>("controlText");
    controlText.setLabel(ResourceUtils.getModel("general.controlText"));
    controlText.setRequired(true);
    add(controlText);

    //        RadioChoice<Gender> gender = new RadioChoice<Gender>("gender", Arrays.asList(Gender.values()), new EnumChoiceRenderer<Gender>());
    //        gender.setSuffix("\n");
    //        gender.setRequired(true);
    //        gender.setLabel(ResourceUtils.getModel("general.gender"));
    //        add(gender);

    //        List<String> listOfTitles = new ArrayList<String>();
    //        listOfTitles.add("Mr.");
    //        listOfTitles.add("Mrs.");
    //        listOfTitles.add("Ms.");
    //
    //        DropDownChoice<String> title = new DropDownChoice<String>("title", listOfTitles,
    //                new ChoiceRenderer<String>() {
    //
    //                    private static final long serialVersionUID = 1L;
    //
    //                    @Override
    //                    public Object getDisplayValue(String object) {
    //                        return object;
    //                    }
    //
    //                });
    //
    //        title.setRequired(true);
    //        title.setLabel(ResourceUtils.getModel("label.title"));
    //        add(title);
    //
    //        File file = ResourceUtils.getFile("countries.txt");
    //        List<String> countries = FileUtils.getFileLines(file);
    //
    //        DropDownChoice<String> country = new DropDownChoice<String>("country", countries,
    //                new ChoiceRenderer<String>("country") {
    //
    //                    private static final long serialVersionUID = 1L;
    //
    //                    @Override
    //                    public Object getDisplayValue(String object) {
    //                        return object;
    //                    }
    //
    //                });
    //
    //        country.setRequired(true);
    //        country.setLabel(ResourceUtils.getModel("label.country"));
    //        add(country);
    //
    //        DropDownChoice<String> orgCountry = new DropDownChoice<String>("orgCountry", countries,
    //                new ChoiceRenderer<String>("orgCountry") {
    //
    //                    private static final long serialVersionUID = 1L;
    //
    //                    @Override
    //                    public Object getDisplayValue(String object) {
    //                        return object;
    //                    }
    //
    //                });
    //
    //        //orgCountry.setRequired(true);
    //        orgCountry.setLabel(ResourceUtils.getModel("label.country"));
    //        add(orgCountry);
    //
    //        DropDownChoice<EducationLevel> educationLevel = new DropDownChoice<EducationLevel>("educationLevel", educationLevelFacade.getAllRecords(),
    //                new ChoiceRenderer<EducationLevel>("title", "educationLevelId") {
    //
    //                    private static final long serialVersionUID = 1L;
    //
    //                    @Override
    //                    public Object getDisplayValue(EducationLevel object) {
    //                        return object.getEducationLevelId() + " " + super.getDisplayValue(object);
    //                    }
    //
    //                });
    //
    //        educationLevel.setLabel(ResourceUtils.getModel("general.educationlevel"));
    //        add(educationLevel);
    //
    //        List<String> listOfOrgTypes = new ArrayList<String>();
    //        listOfOrgTypes.add("Commercial");
    //        listOfOrgTypes.add("Non-Commercial");
    //
    //        DropDownChoice<String> organizationType = new DropDownChoice<String>("organizationType", listOfOrgTypes,
    //                new ChoiceRenderer<String>("organizationType") {
    //
    //                    private static final long serialVersionUID = 1L;
    //
    //                    @Override
    //                    public Object getDisplayValue(String object) {
    //                        return object;
    //                    }
    //
    //                });
    //
    //        organizationType.setRequired(true);
    //        organizationType.setLabel(ResourceUtils.getModel("label.organizationType"));
    //        add(organizationType);

    SubmitLink submit = new SubmitLink("submit", ResourceUtils.getModel("action.create.account")) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public void onSubmit() {

            PersonFormObject user = RegistrationForm.this.getModelObject();
            user.setPanelPerson(panelPerson.getModelObject());
            // validate captcha via service
            if (captchaService.validateResponseForID(user.getCaptcha(), user.getControlText())) {

                user.getPanelPerson().setRegistrationDate(new DateTime());
                if (validation(user)) {
                    personFacade.create(new PersonMapper().convertToEntity(user, new Person()));
                    setResponsePage(ConfirmPage.class,
                            PageParametersUtils.getPageParameters(ConfirmPage.EMAIL, user.getEmail()));
                }
                // if captcha is valid but other validation fail - generate new captcha
                generateCaptchaImageAndPrepareValidation();
            } else {
                error(ResourceUtils.getString("general.error.registration.captchaInvalid"));
                generateCaptchaImageAndPrepareValidation();
            }
            //target.add(captchaImage);
            //target.add(feedback);
        }
    };
    add(submit);
}

From source file:it.av.youeat.web.page.RistoranteEditPicturePage.java

License:Apache License

/**
 * @param parameters/*from www  . ja v a2s  . com*/
 * @throws YoueatException
 */
public RistoranteEditPicturePage(PageParameters parameters) throws YoueatException {
    add(getFeedbackPanel());
    ristoranteId = parameters.get(YoueatHttpParams.RISTORANTE_ID).toString("");
    if (StringUtils.isBlank(ristoranteId)) {
        throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
    }

    pictForm = new Form<Ristorante>("ristorantePicturesForm", new LoadableDetachableModel<Ristorante>() {
        @Override
        protected Ristorante load() {
            return ristoranteService.getByID(ristoranteId);
        }
    });
    add(pictForm);
    // pictForm.setOutputMarkupId(true);
    pictForm.setMultiPart(true);
    pictForm.setMaxSize(Bytes.megabytes(1));
    FileUploadField uploadField = new FileUploadField("uploadField");
    pictForm.add(uploadField);
    pictForm.add(new UploadProgressBar("progressBar", pictForm, uploadField));
    pictForm.add(new SubmitButton("submitForm", pictForm));

    picturesList = new ListView<RistorantePicture>("picturesList", new PicturesModel()) {
        @Override
        protected void populateItem(final ListItem<RistorantePicture> item) {
            // Button disabled, because the getPicture is not yet implemented
            item.add(new SubmitLink("publish-unpublish", pictForm) {
                @Override
                public void onSubmit() {
                    item.getModelObject().setActive(!item.getModelObject().isActive());
                    try {
                        ristorantePictureService.save(item.getModelObject());
                    } catch (YoueatException e) {
                        error(getString("genericErrorMessage"));
                    }
                }

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    if (item.getModelObject().isActive()) {
                        tag.getAttributes().put("title", getString("button.unpublish"));
                        tag.getAttributes().put("class", "unpublishPictureButton");
                    } else {
                        tag.getAttributes().put("title", getString("button.publish"));
                        tag.getAttributes().put("class", "publishPictureButton");
                    }
                }
            }.setVisible(false));
            item.add(new SubmitLink("remove", pictForm) {
                @Override
                public void onSubmit() {
                    try {
                        RistorantePicture picture = item.getModelObject();
                        Ristorante risto = ((Ristorante) getForm().getModelObject());
                        risto.getPictures().remove(picture);
                        ristoranteService.updateNoRevision(risto);
                        ristorantePictureService.remove(picture);
                        picturesList.setModel(new PicturesModel());
                    } catch (YoueatException e) {
                        error(getString("genericErrorMessage"));
                    }
                }
            });
            Link<RistorantePicture> imageLink = new Link<RistorantePicture>("pictureLink", item.getModel()) {
                @Override
                public void onClick() {
                    setResponsePage(new ImageViewPage(getModelObject().getPicture()));
                }
            };
            imageLink.add(ImageRisto.getThumbnailImage("picture", item.getModelObject().getPicture(), false));
            item.add(imageLink);
        }
    };
    picturesList.setOutputMarkupId(true);
    picturesList.setReuseItems(false);
    picturesListContainer = new WebMarkupContainer("picturesListContainer");
    picturesListContainer.setOutputMarkupId(true);
    pictForm.add(picturesListContainer);
    picturesListContainer.add(picturesList);

    ButtonOpenRisto buttonOpenAddedRisto = new ButtonOpenRisto("buttonOpenAddedRisto", pictForm.getModel(),
            true);
    add(buttonOpenAddedRisto);

    ButtonOpenRisto buttonOpenAddedRistoRight = new ButtonOpenRisto("buttonOpenAddedRistoRight",
            pictForm.getModel(), true);
    add(buttonOpenAddedRistoRight);
}

From source file:jp.go.nict.langrid.management.web.view.page.language.service.composite.RegistrationOfBpelCompositeServicePage.java

License:Open Source License

/**
 * //from  www  . ja va  2  s  . co  m
 * 
 */
public RegistrationOfBpelCompositeServicePage(String gridId, final String ownerUserId,
        CompositeServiceModel newModel) {
    this.model = newModel;
    add(form = new MultipartForm("form"));

    //      multipleUploader = new MultipleFileUploaderPanel("wsdlFiles", false, "wsdl", true);
    //      form.add(multipleUploader);

    form.add(wsdlUploader = new FileMultipleUploadPanel(gridId, "wsdlFiles", true));

    bpelUploader = new FileUploaderPanel("bpelFile", false, "bpel", true);
    bpelUploader.setRenderBodyOnly(true);
    form.add(bpelUploader);

    //      form.add(new FileUploadMultipleRelatedRequireValidator(bpelUploader, multipleUploader
    //      , MessageManager.getMessage(
    //         "ProvidingServices.language.service.error.upload.file.Associate"
    //         , getLocale())));

    form.add(new SubmitLink("regist", new Model<String>(model.getServiceId())) {
        @Override
        public void onSubmit() {
            try {
                //               Map<String, byte[]> map = multipleUploader.getFileMap();
                //               map.putAll(bpelUploader.getFileMap());
                //               byte[] lbr = JarUtil.makeInstance(map);

                byte[] lbr = wsdlUploader.getJarFileInstance();
                Map<String, byte[]> map = bpelUploader.getFileMap();
                for (String name : map.keySet()) {
                    lbr = JarUtil.addEntry(name, map.get(name), lbr);
                }

                model.setInstanceType(InstanceType.BPEL);
                model.setInstance(lbr);
                model.setInstanceSize(lbr.length);

                CompositeServiceService service = ServiceFactory.getInstance()
                        .getCompositeServiceService(getSelfGridId());
                service.add(model);

                LogWriter.writeInfo(getSessionUserId(),
                        "\"" + getDefaultModelObjectAsString() + "\" of composite service has been registered.",
                        getPage().getClass());

                doResultProcess(service.get(getDefaultModelObjectAsString()));
            } catch (ServiceManagerException e) {
                if (e.getParentException().getClass().equals(ServiceLogicException.class)) {
                    ServiceLogicException sle = (ServiceLogicException) e.getParentException();
                    if (sle.getMessage().contains("SAXParseException")) {
                        form.error(MessageManager.getMessage(
                                "ProvidingServices.language.service.error.WSDLInvalid", getLocale()));
                        LogWriter.writeOutOfSystemError(getSessionUserId(), e.getParentException(),
                                getPage().getClass(), "Validate Error");
                        return;
                    } else if (sle.getMessage().contains("InvalidServiceInstanceException")) {
                        String[] ms = sle.getMessage().split("Exception: ");
                        form.error(ms[ms.length - 1].replaceAll("]$", ""));
                        return;
                    }
                } else if (e.getParentException().getClass().equals(ServiceAlreadyExistsException.class)) {
                    form.error(MessageManager
                            .getMessage("ProvidingServices.language.service.error.AlreadyExists", getLocale()));
                    LogWriter.writeOutOfSystemError(getSessionUserId(), e.getParentException(),
                            getPage().getClass(), "Validate Error");
                    return;
                } else if (e.getParentException().getClass().equals(ServiceNotActivatableException.class)) {
                    Throwable th = e.getParentException();
                    Pattern p = Pattern.compile("\\[.+?\\]\\s\\[.+?\\]");
                    String message = th.getMessage();
                    Matcher m = p.matcher(message);
                    List<String> buff = new ArrayList<String>();
                    while (m.find()) {
                        String mat = m.group();
                        if (!buff.contains(mat)) {
                            buff.add(mat);
                            mat = mat.replaceAll("\\[", "\\\\[");
                            mat = mat.replaceAll("\\]", "\\\\]");
                            message = message.replaceAll(mat, "<br/>&nbsp;" + mat + "<br/>&nbsp;&nbsp;-&nbsp;");
                        }
                    }
                    form.error(MessageManager.getMessage("ProvidingServices.language.service.error.Activation",
                            getLocale(), model.getServiceId(), message));
                    LogWriter.writeOutOfSystemError(getSessionUserId(), e.getParentException(),
                            getPage().getClass(), "Validate Error");
                    return;
                }
                doErrorProcess(e);
            } catch (ResourceStreamNotFoundException e) {
                form.error(MessageManager.getMessage(
                        "ProvidingServices.language.service.error.validate.file.notFound", getLocale()));
            } catch (IOException e) {
                doErrorProcess(new ServiceManagerException(e, getPage().getClass()));
                //            } catch(SerialException e) {
                //               doErrorProcess(new ServiceManagerException(e, getPage().getClass()));
                //            } catch(SQLException e) {
                //               doErrorProcess(new ServiceManagerException(e, getPage().getClass()));
                //            } finally {
                //               if(model.getInstance() != null) {
                //                  try {
                //                     model.getInstance().getBinaryStream().close();
                //                  } catch(IOException e) {
                //                     LogWriter.writeWarn(getSessionUserId(), e.toString(),
                //                        getClass());
                //                  } catch(SQLException e) {
                //                     LogWriter.writeWarn(getSessionUserId(), e.toString(),
                //                        getClass());
                //                  }
                //               }
            }
        }
    });
    form.add(new Link("cancel") {
        @Override
        public void onClick() {
            setResponsePage(getCancelPage(model, false));
        }
    });
}

From source file:jp.go.nict.langrid.management.web.view.page.language.service.composite.RegistrationOfJavaCompositeServicePage.java

License:Open Source License

/**
 * //from  w ww . j ava  2 s.c  o  m
 * 
 */
public RegistrationOfJavaCompositeServicePage(String gridId, final String ownerUserId,
        JavaCompositeServiceModel newModel) {
    this.model = newModel;
    Form form = new MultipartForm("form");
    add(form);
    form.add(wsdlUploader = new FileUploaderPanel("wsdlFile", false, "wsdl", true));
    wsdlUploader.setRenderBodyOnly(true);
    form.add(authInfoPanel = new EndpointAuthInfoFieldPanel("authInfoFieldPanel", form));
    form.add(sourceCodeUrl = new URLField("sourceUrl", new Model<String>("http://")));

    try {
        form.add(invocations = new ServiceInvocationListFormPanel("invocationPanel", gridId) {
            @Override
            protected String getOwnerUserId() {
                return getSessionUserId();
            }

            @Override
            protected String getOwnerGridId() {
                return getSessionUserGridId();
            }
        });
    } catch (ServiceManagerException e) {
        doErrorProcess(e);
    }
    form.add(new SubmitLink("regist", new Model<String>(model.getServiceId())) {
        @Override
        public void onSubmit() {
            ServiceEndpointModel newEndpointModel = new ServiceEndpointModel();
            try {
                String sourceCode = sourceCodeUrl.getModelObject();
                if (sourceCode != null && !sourceCode.equals("http://")) {
                    model.setSourceCodeUrl(sourceCode);
                }

                Map<String, byte[]> map = wsdlUploader.getFileMap();
                byte[] ler = JarUtil.makeInstance(map);
                model.setInstance(ler);
                model.setInstanceSize(ler.length);
                model.setInstanceType(InstanceType.Java);
                model.setInvocations(invocations.getInvocations(model.getServiceId()));

                CompositeServiceService service = ServiceFactory.getInstance()
                        .getCompositeServiceService(model.getGridId());
                service.add(model);

                if (model.isMembersOnly()) {
                    ServiceFactory.getInstance().getAccessRightControlService(model.getGridId())
                            .setDefault(model.getServiceId(), model.getGridId(), !model.isMembersOnly());
                }

                authInfoPanel.doSubmitProcess(newEndpointModel);
                if (newEndpointModel.getAuthUserName() != null
                        && !newEndpointModel.getAuthUserName().equals("")) {
                    try {
                        ServiceEndpointModel sem = service.getEndpointList(model.getServiceId()).get(0);
                        service.editEndpoint(model.getServiceId(), sem.getUrl(), "", newEndpointModel);
                    } catch (Exception e) {
                        service.deleteById(model.getServiceId());
                        throw new ServiceManagerException(e, getClass());
                    }
                }
                LogWriter.writeInfo(getSessionUserId(),
                        "\"" + model.getServiceId() + "\" of composite service has been registered.'",
                        getPage().getClass());
                doResultProcess(service.get(model.getServiceId()));

            } catch (ServiceManagerException e) {
                doErrorProcess(e);
            } catch (ResourceStreamNotFoundException e) {
                doErrorProcess(new ServiceManagerException(e, getPageClass()));
            } catch (IOException e) {
                doErrorProcess(new ServiceManagerException(e, getPageClass()));
                //            } catch(SerialException e) {
                //               doErrorProcess(new ServiceManagerException(e, getPageClass()));
                //            } catch(SQLException e) {
                //               doErrorProcess(new ServiceManagerException(e, getPageClass()));
            }
        }
    });
    form.add(new Link("cancel") {
        @Override
        public void onClick() {
            setResponsePage(getCancelPage(model, false));
        }
    });
}

From source file:net.form105.web.base.component.command.CommandPanel.java

License:Apache License

@SuppressWarnings("unchecked")
private ListView createListView() {
    ListView lView = new ListView("commandLabels", linkList) {
        private static final long serialVersionUID = 1L;

        @Override/*from w  ww  . jav a 2s.co  m*/
        protected void populateItem(ListItem item) {
            IPageAction action = (IPageAction) item.getModelObject();
            SubmitLink submitLink;
            if (action instanceof AbstractFormAction) {
                AbstractFormAction<T> formAction = (AbstractFormAction<T>) action;
                submitLink = new SubmitLink("commandLink", formAction.getForm()) {

                    private static final long serialVersionUID = 1L;

                    public void onSubmit() {
                        setResponsePage(this.getPage());
                    }
                };

                Label label = new Label("commandLabel", formAction.getName());
                submitLink.add(label);
                item.add(submitLink);

            } else if (action instanceof IAjaxLinkToPanelAction) {
                IAjaxLinkToPanelAction ajaxLinkAction = (IAjaxLinkToPanelAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_EVENT);

                    }

                };
                Label label = new Label("commandLabel", ajaxLinkAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);

            } else if (action instanceof IAjaxLinkToModalWindowAction) {
                IAjaxLinkToModalWindowAction ajaxModalAction = (IAjaxLinkToModalWindowAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_MODAL);
                    }
                };
                Label label = new Label("commandLabel", ajaxModalAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);
            }
        }
    };
    return lView;
}

From source file:net.rrm.ehour.ui.timesheet.export.TimesheetExportCriteriaPanel.java

License:Open Source License

@SuppressWarnings("serial")
private SubmitLink createSubmitButton(String id, SelectionForm form) {
    return new SubmitLink(id, form);
}