use of org.apache.wicket.markup.html.form.upload.FileUploadField in project projectforge by micromata.
the class EmployeeBillingImportForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newGridPanel();
// Date DropDowns
final FieldsetPanel fsMonthYear = gridBuilder.newFieldset(I18nHelper.getLocalizedMessage("plugins.eed.listcare.yearmonth"));
dropDownMonth = new DropDownChoicePanel<>(fsMonthYear.newChildId(), new DropDownChoice<>(DropDownChoicePanel.WICKET_ID, new PropertyModel<>(this, "selectedMonth"), EEDHelper.MONTH_INTEGERS));
fsMonthYear.add(dropDownMonth);
dropDownYear = new DropDownChoicePanel<>(fsMonthYear.newChildId(), new DropDownChoice<>(DropDownChoicePanel.WICKET_ID, new PropertyModel<>(this, "selectedYear"), eedHelper.getDropDownYears()));
fsMonthYear.add(dropDownYear);
// upload buttons
{
final FieldsetPanel fs = gridBuilder.newFieldset(getString("file"), "*.xls");
fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID);
fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID) {
@Override
public final void onSubmit() {
final Date dateToSelectAttrRow = new GregorianCalendar(selectedYear, selectedMonth - 1, 1, 0, 0).getTime();
storagePanel.setDateToSelectAttrRow(dateToSelectAttrRow);
final boolean success = parentPage.doImport(dateToSelectAttrRow);
if (success) {
setDateDropDownsEnabled(false);
}
}
}, getString("upload"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
addClearButton(fs);
}
addImportFilterRadio(gridBuilder);
// preview of the imported data
gridBuilder.newGridPanel();
final DivPanel panel = gridBuilder.getPanel();
storagePanel = new EmployeeBillingImportStoragePanel(panel.newChildId(), parentPage, importFilter);
final Date dateToSelectAttrRow = new GregorianCalendar(selectedYear, selectedMonth - 1, 1, 0, 0).getTime();
storagePanel.setDateToSelectAttrRow(dateToSelectAttrRow);
panel.add(storagePanel);
}
use of org.apache.wicket.markup.html.form.upload.FileUploadField in project projectforge by micromata.
the class AddressImportForm method onInitialize.
/**
* @see org.apache.wicket.Component#onInitialize()
*/
@Override
protected void onInitialize() {
super.onInitialize();
gridBuilder.newSplitPanel(GridSize.COL50);
final FieldsetPanel newFieldset = gridBuilder.newFieldset(getString("address.book.vCardImport.fileUploadPanel"));
final FileUploadField uploadField = new FileUploadField(FileUploadPanel.WICKET_ID, new PropertyModel<List<FileUpload>>(this, "uploads"));
newFieldset.add(new FileUploadPanel(newFieldset.newChildId(), uploadField));
}
use of org.apache.wicket.markup.html.form.upload.FileUploadField in project projectforge by micromata.
the class DatevImportForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
this.setOutputMarkupId(true);
Bytes maxSize = Bytes.valueOf(configurationService.getMaxFileSizeDatev());
this.setMaxSize(maxSize);
gridBuilder.newGridPanel();
String hint = I18nHelper.getLocalizedMessage("finance.datev.upload.hint", NumberHelper.formatBytes(maxSize.bytes()));
final FieldsetPanel fs = gridBuilder.newFieldset(getString("file"), hint);
fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID);
fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("uploadAccounts")) {
@Override
public final void onSubmit() {
parentPage.importAccountList();
}
}, getString("finance.datev.uploadAccountList"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("uploadRecords")) {
@Override
public final void onSubmit() {
parentPage.importAccountRecords();
}
}, getString("finance.datev.uploadAccountingRecords"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
addClearButton(fs);
addImportFilterRadio(gridBuilder);
// Statistics
new BusinessAssessment4Fieldset(gridBuilder) {
/**
* @see org.projectforge.web.fibu.BusinessAssessment4Fieldset#getBusinessAssessment()
*/
@Override
protected BusinessAssessment getBusinessAssessment() {
return storagePanel.businessAssessment;
}
@Override
public boolean isVisible() {
return storagePanel.businessAssessment != null;
}
};
gridBuilder.newGridPanel();
final DivPanel panel = gridBuilder.getPanel();
storagePanel = new DatevImportStoragePanel(panel.newChildId(), parentPage, importFilter);
panel.add(storagePanel);
this.fileUploadField.add(new FileFieldSizeCheckBehavior() {
@Override
protected void onSubmit(final AjaxRequestTarget target, final FileList fileList) {
// return form to remove errors
target.add(DatevImportForm.this.feedbackPanel);
}
@Override
protected void addErrorMsg(AjaxRequestTarget target, FileList fileList) {
DatevImportForm.this.addError("common.uploadpanel.filetolarge", NumberHelper.formatBytes(maxSize.bytes()));
}
@Override
protected void onError(final AjaxRequestTarget target, final FileList fileList) {
// clear input field to avoid uploading the image
DatevImportForm.this.fileUploadField.clearInput();
// return form
target.add(DatevImportForm.this);
}
});
}
use of org.apache.wicket.markup.html.form.upload.FileUploadField in project invesdwin-nowicket by invesdwin.
the class Components method updateValidModelsOnValidationError.
/**
* Synchronize valid model values so that validator utilities have something to work with. This is useful in onError
* calls in submit behaviors
*/
public static boolean updateValidModelsOnValidationError(final Component component) {
final Component root = Components.findRoot(component);
final Form<?> form = Components.findForm(root);
final AtomicBoolean invalidFound = new AtomicBoolean(false);
FormComponent.visitFormComponentsPostOrder(form, new IVisitor<FormComponent<?>, Void>() {
@Override
public void component(final FormComponent<?> object, final IVisit<Void> visit) {
if (object.isEnabledInHierarchy() && object.isVisibleInHierarchy() && // fileUploadField chokes on FileNotFound if synchronized twice in a call!
!(object instanceof FileUploadField)) {
try {
/*
* fill in values regardless of valid state, since complex validation rules might require all
* inputs
*
* we need to call convertInput here because otherwise wicket will leave the value null at that
* point, which would use null in updateModel()
*/
object.convertInput();
object.updateModel();
} catch (final Throwable t) {
// ignore
}
object.validate();
if (!object.isValid()) {
invalidFound.set(true);
}
}
}
});
return invalidFound.get();
}
use of org.apache.wicket.markup.html.form.upload.FileUploadField in project midpoint by Evolveum.
the class PageNewReport method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
input.setOutputMarkupId(true);
mainForm.add(input);
final WebMarkupContainer buttonBar = new WebMarkupContainer(ID_BUTTON_BAR);
buttonBar.setOutputMarkupId(true);
mainForm.add(buttonBar);
final IModel<Integer> groupModel = new Model<Integer>(INPUT_FILE);
RadioGroup importRadioGroup = new RadioGroup(ID_IMPORT_RADIO_GROUP, groupModel);
importRadioGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(input);
target.add(buttonBar);
}
});
mainForm.add(importRadioGroup);
Radio fileRadio = new Radio(ID_FILE_RADIO, new Model(INPUT_FILE), importRadioGroup);
importRadioGroup.add(fileRadio);
Radio xmlRadio = new Radio(ID_XML_RADIO, new Model(INPUT_XML), importRadioGroup);
importRadioGroup.add(xmlRadio);
WebMarkupContainer inputAce = new WebMarkupContainer(ID_INPUT_ACE);
addVisibileForInputType(inputAce, INPUT_XML, groupModel);
input.add(inputAce);
AceEditor aceEditor = new AceEditor(ID_ACE_EDITOR, xmlEditorModel);
aceEditor.setOutputMarkupId(true);
inputAce.add(aceEditor);
WebMarkupContainer inputFileLabel = new WebMarkupContainer(ID_INPUT_FILE_LABEL);
addVisibileForInputType(inputFileLabel, INPUT_FILE, groupModel);
input.add(inputFileLabel);
WebMarkupContainer inputFile = new WebMarkupContainer(ID_INPUT_FILE);
addVisibileForInputType(inputFile, INPUT_FILE, groupModel);
input.add(inputFile);
FileUploadField fileInput = new FileUploadField(ID_FILE_INPUT);
inputFile.add(fileInput);
initButtons(buttonBar, groupModel);
}
Aggregations