Miscellaneous Questions (Image upload, Default value, attribute editability)

Hi,

I am about to complete my first application using Cuba Platform. However, I am stuck at the following and need working sample code for each.

  1. Image upload - User is going to upload multiple files (images, pdfs, excel, word docs). The link for each attachment is created for downloading it.

  2. Set default value (initial value) of a dropdown - The dropdown contains value from Enumeration class

  3. Attribute (field) editability - A field should become enabled/disabled for editing depending on boolean value of some other field.

Pointers to any sample working examples would be great.

Thanks

Hi,

  1. For the multiple files uploading use FileMultiUploadField component
  2. To set a default value for any Entity attribute use initNewItem() method in the edit screen controller. So, if your enum attribute is associated with the Entity, you should write a piece of code similar to this one

@Overrideprotected void initNewItem(People item) {    item.setRole(RoleType.STANDARD);}

If you have a component which is not connected to datasource, you can use setValue() method in the screen controller


<i>@Injectprivate LookupField lookupField;@Overridepublic void init(Map<String, Object> params) {    lookupField.setValue(RoleType.DENYING);}</i>
  1. Every Filed component has ValueChangeListener which can be added by addValueChangeListener() method. To switch editable state use setEditable() method.
    For more detailed information create separate topics with a more detailed description for each question, because it will be more convenient to other users with the similar questions.