| main/src/main/java/com/bloatit/web/linkable/usercontent/AttachmentField.java |
| 16 | 16 | // |
| 17 | 17 | package com.bloatit.web.linkable.usercontent; |
| 18 | 18 | |
| 19 | import com.bloatit.framework.webprocessor.components.HtmlDiv; |
| 20 | import com.bloatit.framework.webprocessor.components.HtmlParagraph; |
| 19 | 21 | import com.bloatit.framework.webprocessor.components.PlaceHolderElement; |
| 20 | 22 | import com.bloatit.framework.webprocessor.components.form.FieldData; |
| 21 | 23 | import com.bloatit.framework.webprocessor.components.form.HtmlFileInput; |
| 22 | 24 | import com.bloatit.framework.webprocessor.components.form.HtmlTextField; |
| 25 | import com.bloatit.framework.webprocessor.components.javascript.JsShowHide; |
| 23 | 26 | import com.bloatit.framework.webprocessor.context.Context; |
| 24 | 27 | import com.bloatit.web.url.UserContentActionUrl; |
| 25 | 28 | |
| ... | ... | |
| 35 | 38 | |
| 36 | 39 | /** |
| 37 | 40 | * Do not forget the: form.enableFileUpload(); |
| 38 | | * |
| 41 | * |
| 39 | 42 | * @param targetUrl |
| 40 | 43 | * @param attachmentLabel |
| 41 | 44 | * @param attachmentComment |
| ... | ... | |
| 49 | 52 | final String descriptionComment) { |
| 50 | 53 | super(); |
| 51 | 54 | // Attachment |
| 55 | HtmlParagraph addAttachementLink = new HtmlParagraph(Context.tr("+ add attachement"), "fake_link"); |
| 56 | add(addAttachementLink); |
| 57 | |
| 58 | HtmlDiv attachmentDiv = new HtmlDiv(); |
| 59 | add(attachmentDiv); |
| 60 | |
| 52 | 61 | final FieldData attachedFileData = targetUrl.getAttachmentParameter().pickFieldData(); |
| 53 | 62 | final HtmlFileInput attachedFileInput = new HtmlFileInput(attachedFileData.getName(), attachmentLabel); |
| 54 | 63 | attachedFileInput.setDefaultValue(attachedFileData.getSuggestedValue()); |
| 55 | 64 | attachedFileInput.addErrorMessages(attachedFileData.getErrorMessages()); |
| 56 | 65 | attachedFileInput.setComment(attachmentComment); |
| 57 | | add(attachedFileInput); |
| 66 | attachmentDiv.add(attachedFileInput); |
| 58 | 67 | |
| 59 | 68 | final FieldData attachmentDescriptiondData = targetUrl.getAttachmentDescriptionParameter().pickFieldData(); |
| 60 | 69 | final HtmlTextField attachmentDescriptionInput = new HtmlTextField(attachmentDescriptiondData.getName(), descriptionLabel); |
| 61 | 70 | attachmentDescriptionInput.setDefaultValue(attachmentDescriptiondData.getSuggestedValue()); |
| 62 | 71 | attachmentDescriptionInput.addErrorMessages(attachmentDescriptiondData.getErrorMessages()); |
| 63 | 72 | attachmentDescriptionInput.setComment(descriptionComment); |
| 64 | | add(attachmentDescriptionInput); |
| 73 | attachmentDiv.add(attachmentDescriptionInput); |
| 74 | |
| 75 | JsShowHide showHide = new JsShowHide(false); |
| 76 | showHide.setHasFallback(false); |
| 77 | |
| 78 | showHide.addActuator(addAttachementLink); |
| 79 | showHide.addListener(attachmentDiv); |
| 80 | showHide.apply(); |
| 81 | |
| 65 | 82 | } |
| 66 | 83 | |
| 67 | 84 | } |