Hello,
Here is the code:

//MyModel is the model for the bean used in both Form1 and Form2


final Form2 inputForm = new Form2("inputForm");
      inputForm.setOutputMarkupId(true);
add(inputForm);
        MyModel model = new MyModel();
final Form1 listForm = new Form1("listForm", new Model<MyModel>(model));
listForm.setOutputMarkupId(true);
add(listForm);

// the Form1 and Form2 classes
private class Form1 extends Form<MyModel> {

/**
*
*/
private static final long serialVersionUID = 1L;

public Form1(String id, IModel<MyModel> listModel) {
super(id, listModel);
final LoadableDetachableModel<List<MyModel>> detachableMyModel = new
LoadableDetachableModel<List<MyModel>>() {

private static final long serialVersionUID = 0L;

@Override
protected List<MyModel> load() {
List<MyModel> lstMyModel = //get a list of MyModel
if (lstMyModel != null)
return lstMyModel;
else
return Collections.emptyList();
}
};

final WebMarkupContainer itemsContainer = new
WebMarkupContainer("myModelItemsContainer");
itemsContainer.setOutputMarkupId(true);
add(itemsContainer);
final ListView<MyModel> listOfMyModel = new
ListView<MyModel>("forEachItem", detachableMyModel) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<MyModel> item) {
final MyModel lineItem = item.getModelObject();

Label lblNumber = new Label("number", lineItem.getNumber());
item.add(lblNumber);

Label lblAmount = new Label("amount", lineItem.getAmount());
item.add(lblAmount);
TextField<String> txtStatus = new TextField<String>("amount", new
PropertyModel<MyModel>(lineItem, "status"));
item.add(txtStatus);
Button save = new Button("save") {
private static final long serialVersionUID = -6770575803451248943L;

@Override
public void onSubmit() {
//assign some values and do the save
}
};
item.add(save);
}
};
itemsContainer.add(listOfMyModel);
listOfMyModel.setOutputMarkupId(true);
}
}

//--------
private class Form2 extends Form<MyModel> {

/**
*
*/
private static final long serialVersionUID = 1L;

private IModel<MyModel> getModelObject = new Model<MyModel> (new MyModel());
public InputForm(String id) {
super(id);
final WebMarkupContainer inputTableContainer = new
WebMarkupContainer("tableInput") {
/**
*
*/
private static final long serialVersionUID = 1L;

@Override
       public void onConfigure() {
boolean showInputForm = //check if it shout be shown or not
               setVisible(showInputForm);
       }
};
inputTableContainer.setOutputMarkupId(true);
TextField<String> inputNumber = new TextField<String>("inputNumber", new
PropertyModel<String>(getModelObject, "number"));
inputTableContainer.add(inputNumber);
TextField<String> inputAmount = new TextField<Double>("inputAmount", new
PropertyModel<Double>(getModelObject, "amount"));
inputTableContainer.add(inputAmount);

add(inputTableContainer);
}

@Override
public void onSubmit() {
logger.info("onSubmit Input Form");

getModelObject.getObject().setDateCreated(new Date());
getModelObject.getObject().setCreatedBy(1);
getModelObject.getObject().setStatus(1);

//do the insert
}

}





On Sun, Jul 31, 2016 at 11:33 AM, Sven Meier [via Apache Wicket] <
ml-node+s1842946n467524...@n4.nabble.com> wrote:

> Seems like form2 is showing previous Raw input (which normally is cleared
> on successful submit) or it is holding to the previous Model object.
>
> Hard to tell without seeing the code.
>
> Regards
> Sven
>
>
>
> Am 31. Juli 2016, 10:55, um 10:55, Iamuser <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675241&i=0>> schrieb:
>
> >Hello,
> >I'm using wicket 6
> >I have a page with 2 forms: form1 and form2.
> >
> >Form2 is an input form. After I provide input values for the Form2 and
> >submit, in Form1 a listView is populated with a row containing those
> >values.
> >After each Form2 submit, Form2 is made invisible.
> >
> >Now one field in a line from Form1 can be editable. When changed to a
> >certain value and that value submitted, Form2 should be made visible
> >again.
> >
> >The problem is that Form2 is made visible with that edited lines values
> >already present, but it should always appear as an input form with
> >empty
> >input fields.
> >
> >Could you please indicate a solution?
> >Thank you
> >
> >
> >
> >
> >
> >
> >
> >--
> >View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/empty-form-input-after-submit-tp4675240.html
> >Sent from the Users forum mailing list archive at Nabble.com.
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675241&i=1>
> >For additional commands, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675241&i=2>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/empty-form-input-after-submit-tp4675240p4675241.html
> To unsubscribe from empty form input after submit, click here
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675240&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc1MjQwfC01MzM2MjU4NzI=>
> .
> NAML
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/empty-form-input-after-submit-tp4675240p4675242.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to