Re: Feedback Messages prevent DropDownChoice updating Textfields

2014-02-12 Thread Daniela L
Hi,
sometimes one doesn't see the obvious things,
I simply had to add a lastName.clearInput(); in the
onUpdate method and everything works as expected.
I hope that helps anybody having the same problem :-)
Best Regards
Daniela


Hi,
I am trying to implement a Feedback for every Form Component and
a catch all Feedback Panel in wicket 6.12.0. Everything works fine except
for the case
when a user causes a error which is shown in the Feedback Panel of the
Component,
e.g. the Textfield firstName is left empty. After that the select of the
DropDownChoice
does not update the Textfields anymore. Where is my mistake? Thanks a lot
in advance.
Daniela

Here is my code:

public class EditEmployeePage extends BasePage {
private FormComponentString firstName;
private DropDownChoiceEmployee employeeDDC;
private final FormEmployee employeListForm;
private ModelEmployee employeeModel;
private Employee employee;
@SpringBean(name=employeeService)
private EmployeeService employeeService;
private Button saveEmployeeButton;
private Button resetButton;

public EditEmployeePage(final PageParameters parameters) {
super();
employee = new Employee();
employeeModel = new ModelEmployee(employee);//for dropDownChoice
final CompoundPropertyModelEmployee employeeCpm = new
CompoundPropertyModelEmployee(employeeModel); //for form
employeListForm = new FormEmployee(employeListForm,
employeeCpm);
employeListForm.setOutputMarkupId(true);
add(employeListForm);
addEmployeeDropDown();
addFirstNameTextField();
//more fields
 }

private void addEmployeeDropDown() {
Label chooseEmployeeLabel = new Label(chooseEmployeeLabel,
Mitarbeiter wählen:*);
employeListForm.add(chooseEmployeeLabel);

// Employee DropdownChoice
LoadableDetachableModelListEmployee employeeValueChoices = new
LoadableDetachableModelListEmployee() {
private static final long serialVersionUID = 1L;

protected ListEmployee load() {
ListEmployee employees = Collections.emptyList();
employees = employeeService.findallEmployees(getCompany());
if (!employees.isEmpty()){
employeeModel.setObject(employees.get(0));
}
return employees;
}

};

employeeDDC = new DropDownChoiceEmployee(employee,
employeeModel,
employeeValueChoices.getObject(),
new TwoPropertiesChoiceRendererEmployee(employeeId,
lastName, firstName, ,));
employeeDDC.setLabel(new ModelString(Mitarbeiter
wählen));
employeeDDC.add(new
AjaxFormComponentUpdatingBehavior(onchange) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
   target.add(employeListForm);
}
  });

employeeDDC.setRequired(true);
employeListForm.add(employeeDDC);
}

private void addFirstNameTextField() {
// first name label and field on page
Label firstNameLabel = new Label(firstNameLabel, Vorname:*);
employeListForm.add(firstNameLabel);
firstName = new TextFieldString(firstName);
firstName.setLabel(new ModelString(Vorname));
firstName.setOutputMarkupPlaceholderTag(true);
FeedbackPanel firstNameFeedback =  (FeedbackPanel) new
FeedbackPanel(firstNameFeedback, firstName).setOutputMarkupId(true);
employeListForm.add(firstNameFeedback);
employeListForm.add(firstName);
firstName.setRequired(true);
}
...
}

public abstract class BasePage extends WebPage {
   private final FeedbackPanel pageFeedback = new
FeedbackPanel(feedback);
   public BasePage() {
  super();
  pageFeedback.setOutputMarkupId(true);
  add(pageFeedback);
   }


Fwd: Feedback Messages prevent DropDownChoice updating Textfields

2014-02-11 Thread Daniela L
Hi,
I am trying to implement a Feedback for every Form Component and
a catch all Feedback Panel in wicket 6.12.0. Everything works fine except
for the case
when a user causes a error which is shown in the Feedback Panel of the
Component,
e.g. the Textfield firstName is left empty. After that the select of the
DropDownChoice
does not update the Textfields anymore. Where is my mistake? Thanks a lot
in advance.
Daniela

Here is my code:

public class EditEmployeePage extends BasePage {
private FormComponentString firstName;
private DropDownChoiceEmployee employeeDDC;
private final FormEmployee employeListForm;
private ModelEmployee employeeModel;
private Employee employee;
@SpringBean(name=employeeService)
private EmployeeService employeeService;
private Button saveEmployeeButton;
private Button resetButton;

public EditEmployeePage(final PageParameters parameters) {
super();
employee = new Employee();
employeeModel = new ModelEmployee(employee);//for dropDownChoice
final CompoundPropertyModelEmployee employeeCpm = new
CompoundPropertyModelEmployee(employeeModel); //for form
employeListForm = new FormEmployee(employeListForm,
employeeCpm);
employeListForm.setOutputMarkupId(true);
add(employeListForm);
addEmployeeDropDown();
addFirstNameTextField();
//more fields
 }

private void addEmployeeDropDown() {
Label chooseEmployeeLabel = new Label(chooseEmployeeLabel,
Mitarbeiter wählen:*);
employeListForm.add(chooseEmployeeLabel);

// Employee DropdownChoice
LoadableDetachableModelListEmployee employeeValueChoices = new
LoadableDetachableModelListEmployee() {
private static final long serialVersionUID = 1L;

protected ListEmployee load() {
ListEmployee employees = Collections.emptyList();
employees = employeeService.findallEmployees(getCompany());
if (!employees.isEmpty()){
employeeModel.setObject(employees.get(0));
}
return employees;
}

};

employeeDDC = new DropDownChoiceEmployee(employee,
employeeModel,
employeeValueChoices.getObject(),
new TwoPropertiesChoiceRendererEmployee(employeeId,
lastName, firstName, ,));
employeeDDC.setLabel(new ModelString(Mitarbeiter
wählen));
employeeDDC.add(new
AjaxFormComponentUpdatingBehavior(onchange) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
   target.add(employeListForm);
}
  });

employeeDDC.setRequired(true);
employeListForm.add(employeeDDC);
}

private void addFirstNameTextField() {
// first name label and field on page
Label firstNameLabel = new Label(firstNameLabel, Vorname:*);
employeListForm.add(firstNameLabel);
firstName = new TextFieldString(firstName);
firstName.setLabel(new ModelString(Vorname));
firstName.setOutputMarkupPlaceholderTag(true);
FeedbackPanel firstNameFeedback =  (FeedbackPanel) new
FeedbackPanel(firstNameFeedback, firstName).setOutputMarkupId(true);
employeListForm.add(firstNameFeedback);
employeListForm.add(firstName);
firstName.setRequired(true);
}
...
}

public abstract class BasePage extends WebPage {
   private final FeedbackPanel pageFeedback = new
FeedbackPanel(feedback);
   public BasePage() {
  super();
  pageFeedback.setOutputMarkupId(true);
  add(pageFeedback);
   }