Hi Guys,
as the Topic say, i got the error:
2017-03-26 03:33:06,727 SEVERE [com.vaadin.server.DefaultErrorHandler]
(default task-113) : java.lang.IllegalStateException: There are no instance fields found for automatic binding
here is the class i which handles the binding.
[code]
import com.vaadin.data.Binder;
import com.vaadin.data.ValidationException;
import com.vaadin.server.Sizeable;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
import de.rhonen.ejbmodels.dto.IndustryJobDto;
import de.rhonen.ejbmodels.dto.UserDto;
import de.rhonen.ejbmodels.enums.StatusManufacturing;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class IndustryWindow implements Window.CloseListener{
private final LinkedList listeners = new LinkedList<>();
private final Window window;
private final IndustryJobDto job;
private boolean doSave = false;
private final ComboBox<StatusManufacturing> cbStatus = new ComboBox<>();
private final ComboBox<UserDto> cbManufacturer = new ComboBox<>();
private final TextArea textManufacturerComment = new TextArea();
private final TextArea textCustomerComment = new TextArea();
private final TextField property4 = new TextField ("Property 4");
private final TextField property5 = new TextField("Property 5");
private final Binder<IndustryJobDto> binder = new Binder<>(IndustryJobDto.class);
private FormLayout layout;
public IndustryWindow(IndustryJobDto job) {
this.job = job;
window = new Window();
window.setCaption("Edit Job");
window.center();
window.setWidth(400, Sizeable.Unit.PIXELS);
initLayout();
UI.getCurrent().addWindow(window);
}
private void initLayout(){
window.addCloseListener(this);
cbStatus.setCaption("Status");
cbStatus.setItemCaptionGenerator(item -> item.name());
cbStatus.setEmptySelectionAllowed(false);
cbManufacturer.setCaption("Manufacturer");
cbManufacturer.setPlaceholder("No Producer selected");
cbManufacturer.setItemCaptionGenerator(item -> item.getUsername());
textManufacturerComment.setCaption("Manufacturer Comment ");
textCustomerComment.setCaption("Manufacturer Comment ");
layout = new FormLayout();
layout.addComponent(cbManufacturer);
layout.addComponent(cbStatus);
layout.addComponent(textManufacturerComment);
layout.addComponent(textCustomerComment);
layout.addComponent(property4);
layout.addComponent(property5);
HorizontalLayout horizontal = new HorizontalLayout();
Button savebtn = new Button("Save", event ->{
try {
binder.writeBean(job);
btnEventClose(true);
} catch (ValidationException ex) {
Logger.getLogger(IndustryWindow.class.getName()).log(Level.SEVERE, null, ex);
}
});
savebtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
horizontal.addComponent(new Button("close", event ->{
btnEventClose(false);
}));
horizontal.addComponent(savebtn);
layout.addComponent(horizontal);
layout.setComponentAlignment(horizontal, Alignment.BOTTOM_RIGHT);
window.setContent(layout);
databinding();
}
public void close() {
window.close();
}
private void btnEventClose(boolean save){
this.doSave = save;
window.close();
}
public void bringToFront() {
if(!window.isAttached()){
UI.getCurrent().addWindow(window);
}
else{
window.bringToFront();
}
}
public void center() {
window.center();
}
public void addIndustryWindowListener(IndustryWindowListener listener){
if(!this.listeners.contains(listener)){
this.listeners.add(listener);
}
}
@Override
public void windowClose(Window.CloseEvent e) {
if(doSave){
listeners.forEach((listener) -> {
listener.onIndustryWindowClose(job);
});
}
}
private void databinding() {
binder.bind(property4,
(IndustryJobDto source) -> source.getGroupNameEve(),
(IndustryJobDto bean, String fieldvalue) -> { bean.setGroupNameEve(fieldvalue);});
// binder.bind(cbStatus,
// (IndustryJobDto source) → source.getStatus(),
// (IndustryJobDto bean, StatusManufacturing fieldvalue) → { bean.setStatus(fieldvalue);}
// );
// binder.bind(cbManufacturer,
// (IndustryJobDto source) → source.getManufacturer(),
// (IndustryJobDto bean, UserDto fieldvalue) → { bean.setManufacturer(fieldvalue);}
// );
// binder.bind(textManufacturerComment,
// (IndustryJobDto source) → source.getManufacturing().getProducercomment(),
// (IndustryJobDto bean, String fieldvalue) → { bean.getManufacturing().setProducercomment(fieldvalue);}
// );
// binder.bind(textCustomerComment,
// (IndustryJobDto source) → source.getManufacturing().getCustomercomment(),
// (IndustryJobDto bean, String fieldvalue) → { bean.getManufacturing().setCustomercomment(fieldvalue);}
// );
binder.bindInstanceFields(this);
binder.readBean(job);
}
public interface IndustryWindowListener {
void onIndustryWindowClose(IndustryJobDto job);
}
}
[/code]i tried to disable comboboxes and only use a textfield, but also it is not working.
thats the call from the in the view-class
IndustryWindow window = new IndustryWindow(industryjobDto);
window.addIndustryWindowListener(this);
Did i do something wrong in using the Binder, or is it a bug in the Alpha-version?
Why i use the Alpha 8.1: i use the ComponentRenderer Support for a Grid in the view-class
Also tried with @Property(“naming”).
Any suggestions are welcome.