Hi -
My entity looks like this
public class FileUpload extends StandardEntity{
private static final long serialVersionUID = 9133937435347475015L;
@Column(name = "TITLE", nullable = false)
protected String title;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "IN_FILE_ID")
protected com.haulmont.cuba.core.entity.FileDescriptor inFile;
}
My xml looks like this
<layout spacing="true">
<fieldGroup id="fieldGroup"
datasource="fileUploadDs">
<column width="250px">
<field property="title"/>
<field property="inFile" />
</column>
</fieldGroup>
<hbox id="hbox" spacing="true" align="MIDDLE_LEFT" >
<button id="cancelBtn"
caption="Cancel"
invoke="onCancel" icon=""/>
<button id="okBtn"
caption="Save"
invoke="onSave"/>
<button id="processBtn"
caption="Process"
invoke="onProcess"/>
</hbox>
</layout>
My Controller looks like this
public class FileUploadEdit extends AbstractEditor<FileUpload> {
@Inject
private Button processBtn;
@Inject
private Button okBtn;
@Inject
@Named("fieldGroup.inFile")
protected FileUploadField inFile;
//protected FileUploadField inFileuploadField;
@Inject
private FileProcessService fileProcessService;
@Inject
private FileUploadingAPI fileUploadingAPI;
@Inject
private DataSupplier dataSupplier;
@Override
public void init(Map<String, Object> params) {
}
@Override
protected void postInit() {
if(FileProcessStatus.Uploaded.equals(getItem().getFileProcessStatus())){
processBtn.setEnabled(true);
inFile.setEditable(true);
okBtn.setEnabled(true);
} else if(getItem().getFileProcessStatus()==null){
inFile.setEditable(true);
processBtn.setEnabled(false);
okBtn.setEnabled(true);
}else {
processBtn.setEnabled(false);
inFile.setEditable(false);
okBtn.setEnabled(false);
}
}
public void onSave(Component source) throws FileStorageException {
fileUploadingAPI.putFileIntoStorage(inFile.getFileId(), getItem().getInFile()); super.commit();
postInit();
}
public void onCancel(Component source) {
close(CLOSE_ACTION_ID);
}
public void onProcess(Component source){
System.out.println("File:"+fileUploadingAPI.getFile(getItem().getInFile().getId()));
fileProcessService.processFile(getItem(),fileUploadingAPI.getFile(getItem().getInFile().getId()));
getItem().setFileProcessStatus(FileProcessStatus.Processing);
super.commitAndClose();
}
}
I get a null file when I enquire to get the file from fileUploadApi.Let me know where I am doing wrong?