Thank Col, But I have no validation, my component code is the code of the
component is
public class CustomerAccountCode extends
FormComponentPanel<Account> {
private FormComponent<String> entity;
private FormComponent<String> office;
private FormComponent<String> dc;
private FormComponent<String> number;
public CustomerAccountCode(String id, Model<Account> model) {
super(id, model);
entity = new TextField<String>("entity", new Model<String>());
office = new TextField<String>("office", new Model<String>());
dc = new TextField<String>("dc", new Model<String>());
number = new TextField<String>("number", new Model<String>());
onModelChanged();
add(entity);
add(office);
add(dc);
add(number);
// add(CustomerAccountCodeValidator.getInstance());
}
protected void onModelChanged() {
super.onModelChanged();
CustomerAccountCodeModel ccc = getModelObject();
if (ccc != null) {
entity.setModelObject(ccc.getEntity());
office.setModelObject(ccc.getOffice());
dc.setModelObject(ccc.getDc());
number.setModelObject(ccc.getAccount());
} else {
entity.setModelObject(null);
office.setModelObject(null);
dc.setModelObject(null);
number.setModelObject(null);
}
}
@Override
protected void convertInput() {
Account account = new Account(
entity.getConvertedInput(),
office.getConvertedInput(),
dc.getConvertedInput(),
number.getConvertedInput());
if (Strings.isEmpty(account.getEntity()) &&
Strings.isEmpty(account.getDc())
&& Strings.isEmpty(account.getOffice()) &&
Strings.isEmpty(account.getNumber())) {
account = null;
}
setConvertedInput(account);
}
@Override
public void updateModel(){
System.err.println("UPDATE MODEL" +entity.getConvertedInput());
}
@Override
public Component add(final Behavior... behaviors) {
entity.add(behaviors);
office.add(behaviors);
dc.add(behaviors);
number.add(behaviors);
return this;
}
}
The model takes it perfectly when constrye the object, but loses to do
submit, I use the component on the form as follows
HTML FORM
<form id="form" name="form" wicket:id="form">
CCC:
<wicket:container
wicket:id="ccc"/>
Editar
<javascript:enableFieldccc()>
...
JAVA FORM
....
ccc = new CustomerAccountCode("ccc",
new Model<Account>(
new Account(config.getCcc())));
add(ccc);
....
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Model-is-null-after-submit-using-FormComponentPanel-tp4654441p4654462.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]