Re: empty form input after submit

2016-08-09 Thread Iamuser
Hello,

Could you please provide more details?
What do you mean by swapping the model?

Thank you.

On Wed, Aug 3, 2016 at 8:16 PM, ganea iulia  wrote:

> Hello,
> Could you please give me an example of that?
> Thank you
>
> On Sun, Jul 31, 2016 at 3:08 PM, Sven Meier [via Apache Wicket] <
> ml-node+s1842946n4675243...@n4.nabble.com> wrote:
>
>> Hi,
>>
>> Form2 is always working on the same model object.
>>
>> You have to swap its model object once you select one from the list in
>> form1 - either by setting it into form2's model or by passing a model
>> into form2's constructor, so that you can change the contained model
>> object without having to notify form2 of it.
>>
>> Have fun
>>
>> Sven
>>
>>
>> On 31.07.2016 11:29, Iamuser wrote:
>>
>> > 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(model));
>> > listForm.setOutputMarkupId(true);
>> > add(listForm);
>> >
>> > // the Form1 and Form2 classes
>> > private class Form1 extends Form {
>> >
>> > /**
>> > *
>> > */
>> > private static final long serialVersionUID = 1L;
>> >
>> > public Form1(String id, IModel listModel) {
>> > super(id, listModel);
>> > final LoadableDetachableModel detachableMyModel = new
>> > LoadableDetachableModel() {
>> >
>> > private static final long serialVersionUID = 0L;
>> >
>> > @Override
>> > protected List load() {
>> > List 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 listOfMyModel = new
>> > ListView("forEachItem", detachableMyModel) {
>> > private static final long serialVersionUID = 1L;
>> >
>> > @Override
>> > protected void populateItem(ListItem 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 txtStatus = new TextField("amount", new
>> > PropertyModel(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 {
>> >
>> > /**
>> > *
>> > */
>> > private static final long serialVersionUID = 1L;
>> >
>> > private IModel getModelObject = new Model (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 inputNumber = new TextField("inputNumber",
>> new
>> > PropertyModel(getModelObject, "number"));
>> > inputTableContainer.add(inputNumber);
>> > TextField inputAmount = new TextField("inputAmount",
>> new
>> > PropertyModel(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] <
>> > [hidden email] >
>> 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]
>> >> > 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 

Re: empty form input after submit

2016-08-03 Thread Iamuser
Hello,
Could you please give me an example of that?
Thank you

On Sun, Jul 31, 2016 at 3:08 PM, Sven Meier [via Apache Wicket] <
ml-node+s1842946n4675243...@n4.nabble.com> wrote:

> Hi,
>
> Form2 is always working on the same model object.
>
> You have to swap its model object once you select one from the list in
> form1 - either by setting it into form2's model or by passing a model
> into form2's constructor, so that you can change the contained model
> object without having to notify form2 of it.
>
> Have fun
>
> Sven
>
>
> On 31.07.2016 11:29, Iamuser wrote:
>
> > 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(model));
> > listForm.setOutputMarkupId(true);
> > add(listForm);
> >
> > // the Form1 and Form2 classes
> > private class Form1 extends Form {
> >
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> >
> > public Form1(String id, IModel listModel) {
> > super(id, listModel);
> > final LoadableDetachableModel detachableMyModel = new
> > LoadableDetachableModel() {
> >
> > private static final long serialVersionUID = 0L;
> >
> > @Override
> > protected List load() {
> > List 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 listOfMyModel = new
> > ListView("forEachItem", detachableMyModel) {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > protected void populateItem(ListItem 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 txtStatus = new TextField("amount", new
> > PropertyModel(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 {
> >
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> >
> > private IModel getModelObject = new Model (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 inputNumber = new TextField("inputNumber", new
> > PropertyModel(getModelObject, "number"));
> > inputTableContainer.add(inputNumber);
> > TextField inputAmount = new TextField("inputAmount", new
> > PropertyModel(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] <
> > [hidden email] >
> 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]
> >> > 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 

Re: empty form input after submit

2016-07-31 Thread Sven Meier

Hi,

Form2 is always working on the same model object.

You have to swap its model object once you select one from the list in 
form1 - either by setting it into form2's model or by passing a model 
into form2's constructor, so that you can change the contained model 
object without having to notify form2 of it.


Have fun

Sven


On 31.07.2016 11:29, Iamuser wrote:

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(model));
listForm.setOutputMarkupId(true);
add(listForm);

// the Form1 and Form2 classes
private class Form1 extends Form {

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

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

private static final long serialVersionUID = 0L;

@Override
protected List load() {
List 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 listOfMyModel = new
ListView("forEachItem", detachableMyModel) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem 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 txtStatus = new TextField("amount", new
PropertyModel(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 {

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

private IModel getModelObject = new Model (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 inputNumber = new TextField("inputNumber", new
PropertyModel(getModelObject, "number"));
inputTableContainer.add(inputNumber);
TextField inputAmount = new TextField("inputAmount", new
PropertyModel(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]
> 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]



For additional commands, e-mail: [hidden email]




--
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 

Re: empty form input after submit

2016-07-31 Thread Iamuser
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(model));
listForm.setOutputMarkupId(true);
add(listForm);

// the Form1 and Form2 classes
private class Form1 extends Form {

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

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

private static final long serialVersionUID = 0L;

@Override
protected List load() {
List 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 listOfMyModel = new
ListView("forEachItem", detachableMyModel) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem 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 txtStatus = new TextField("amount", new
PropertyModel(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 {

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

private IModel getModelObject = new Model (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 inputNumber = new TextField("inputNumber", new
PropertyModel(getModelObject, "number"));
inputTableContainer.add(inputNumber);
TextField inputAmount = new TextField("inputAmount", new
PropertyModel(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]
> > 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]
> 
> >For additional commands, e-mail: [hidden email]
> 
>
>
> --
> 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
> 
> .
> NAML
> 

Re: empty form input after submit

2016-07-31 Thread Sven Meier
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  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: users-unsubscr...@wicket.apache.org
>For additional commands, e-mail: users-h...@wicket.apache.org