Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread Martin U
Iam totally confused.

Iam using the Todo-List-Example from here :
http://www.wicket-library.com/wicket-examples/ajax/todo-list.0
to play around with wicket.

This example works, but i want to display a list of Entities from the
Backend and edit one of them with my new-entity-Form.
So i want to click on edit in a row and want to use the *same* *form *as i
use to add a entity. How could i handle this?

I tried sooo much but nothing works right.


The addForm (showForm(target)) function works right. But in public void
showForm(AjaxRequestTarget _t, Functionsbereich el)
i deliver el which is my POJO and i cant figure out how to treat the Form
to use now my new Model...
I tried with modelChange() und mondelChanging() but nothing works =( allways
the empty Form is shown ;(

Thanks a lot for any help!!

private final class FormContainer extends WebMarkupContainer{

private EditForm f;

public FormContainer(String id) {
super(id);
setOutputMarkupId(true);


add(f = (EditForm) new EditForm(form).setVisible(false));
add(new AjaxFallbackLinkObject(link){

@Override
public void onClick(AjaxRequestTarget target) {
showForm(target);
}

});
}

public void showForm(AjaxRequestTarget _t){
f.setVisible(true);
_t.addComponent(this);

}

/** Shows form with entity **/
public void showForm(AjaxRequestTarget _t, Functionsbereich el){
//add(f = new EditForm(link, el));
f.modelChanging();
f.setModel(new CompoundPropertyModelFunctionsbereich(el));


f.modelChanged();
f.setVisible(true);

_t.addComponent(this);

}


}

private final class EditForm extends FormFunctionsbereich{

public EditForm(String id){
this(id, new CompoundPropertyModelFunctionsbereich(new
Functionsbereich()));
}

public EditForm(String id, Functionsbereich _el){
super(id,new CompoundPropertyModelFunctionsbereich(_el) );
}

public EditForm(String id, CompoundPropertyModelFunctionsbereich
_model) {
super(id, _model);


setOutputMarkupId(true);
add( new TextFieldObject(form_text, _model.bind(label)));

//add(new Label(vendor, _model.bind(vendor.name)));


}

}


Re: Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread MattyDE

In a nutshell:


I want to use this:
http://cwiki.apache.org/WICKET/how-to-use-the-same-form-for-editing-and-new.html
but ajax-driven... =/
-- 
View this message in context: 
http://old.nabble.com/Updating-Form-Elements-by-Ajax-with-new-POJO-Model-tp26810357p26810518.html
Sent from the Wicket - User 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



Re: Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread Eugene Malan

Try replacing the Model's object instead of the actual Model.

	private EditFormModel editFormModel = new  
CompoundPropertyModelFunctionsbereich(el);


replace
//f.setModel(new CompoundPropertyModelFunctionsbereich(el));
editFormModel.setObject(el);


On 16 Dec 2009, at 6:27 AM, Martin U wrote:


Iam totally confused.

Iam using the Todo-List-Example from here :
http://www.wicket-library.com/wicket-examples/ajax/todo-list.0
to play around with wicket.

This example works, but i want to display a list of Entities from the
Backend and edit one of them with my new-entity-Form.
So i want to click on edit in a row and want to use the *same*  
*form *as i

use to add a entity. How could i handle this?

I tried sooo much but nothing works right.


The addForm (showForm(target)) function works right. But in public  
void

showForm(AjaxRequestTarget _t, Functionsbereich el)
i deliver el which is my POJO and i cant figure out how to treat  
the Form

to use now my new Model...
I tried with modelChange() und mondelChanging() but nothing works  
=( allways

the empty Form is shown ;(

Thanks a lot for any help!!

   private final class FormContainer extends WebMarkupContainer{

   private EditForm f;

   public FormContainer(String id) {
   super(id);
   setOutputMarkupId(true);


   add(f = (EditForm) new EditForm(form).setVisible(false));
   add(new AjaxFallbackLinkObject(link){

   @Override
   public void onClick(AjaxRequestTarget target) {
   showForm(target);
   }

   });
   }

   public void showForm(AjaxRequestTarget _t){
   f.setVisible(true);
   _t.addComponent(this);

   }

   /** Shows form with entity **/
   public void showForm(AjaxRequestTarget _t, Functionsbereich  
el){

//add(f = new EditForm(link, el));
   f.modelChanging();
   f.setModel(new  
CompoundPropertyModelFunctionsbereich(el));



   f.modelChanged();
   f.setVisible(true);

   _t.addComponent(this);

   }


   }

   private final class EditForm extends FormFunctionsbereich{

   public EditForm(String id){
   this(id, new CompoundPropertyModelFunctionsbereich(new
Functionsbereich()));
   }

   public EditForm(String id, Functionsbereich _el){
   super(id,new  
CompoundPropertyModelFunctionsbereich(_el) );

   }

   public EditForm(String id,  
CompoundPropertyModelFunctionsbereich

_model) {
   super(id, _model);


   setOutputMarkupId(true);
   add( new TextFieldObject(form_text,  
_model.bind(label)));


   //add(new Label(vendor, _model.bind(vendor.name)));


   }

   }



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



Re: Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread Eugene Malan
I think you might have to use setVisibilityAllowed(true), otherwise  
the html does not make it onto the page.

Maybe this is better...

	f = new EditFormFunctionsbereich(form,new  
CompoundPropertyModelFunctionsbereich(el));

f.setVisible(false);
f.setVisibilityAllowed(true);

and then for Ajax...

f.setModelObject(e);

On 16 Dec 2009, at 7:09 AM, Eugene Malan wrote:


Try replacing the Model's object instead of the actual Model.

	private EditFormModel editFormModel = new  
CompoundPropertyModelFunctionsbereich(el);


replace
//f.setModel(new CompoundPropertyModelFunctionsbereich(el));
editFormModel.setObject(el);


On 16 Dec 2009, at 6:27 AM, Martin U wrote:


Iam totally confused.

Iam using the Todo-List-Example from here :
http://www.wicket-library.com/wicket-examples/ajax/todo-list.0
to play around with wicket.

This example works, but i want to display a list of Entities from the
Backend and edit one of them with my new-entity-Form.
So i want to click on edit in a row and want to use the *same*  
*form *as i

use to add a entity. How could i handle this?

I tried sooo much but nothing works right.


The addForm (showForm(target)) function works right. But in  
public void

showForm(AjaxRequestTarget _t, Functionsbereich el)
i deliver el which is my POJO and i cant figure out how to treat  
the Form

to use now my new Model...
I tried with modelChange() und mondelChanging() but nothing works  
=( allways

the empty Form is shown ;(

Thanks a lot for any help!!

  private final class FormContainer extends WebMarkupContainer{

  private EditForm f;

  public FormContainer(String id) {
  super(id);
  setOutputMarkupId(true);


  add(f = (EditForm) new EditForm(form).setVisible(false));
  add(new AjaxFallbackLinkObject(link){

  @Override
  public void onClick(AjaxRequestTarget target) {
  showForm(target);
  }

  });
  }

  public void showForm(AjaxRequestTarget _t){
  f.setVisible(true);
  _t.addComponent(this);

  }

  /** Shows form with entity **/
  public void showForm(AjaxRequestTarget _t, Functionsbereich  
el){

//add(f = new EditForm(link, el));
  f.modelChanging();
  f.setModel(new  
CompoundPropertyModelFunctionsbereich(el));



  f.modelChanged();
  f.setVisible(true);

  _t.addComponent(this);

  }


  }

  private final class EditForm extends FormFunctionsbereich{

  public EditForm(String id){
  this(id, new CompoundPropertyModelFunctionsbereich(new
Functionsbereich()));
  }

  public EditForm(String id, Functionsbereich _el){
  super(id,new  
CompoundPropertyModelFunctionsbereich(_el) );

  }

  public EditForm(String id,  
CompoundPropertyModelFunctionsbereich

_model) {
  super(id, _model);


  setOutputMarkupId(true);
  add( new TextFieldObject(form_text,  
_model.bind(label)));


  //add(new Label(vendor, _model.bind(vendor.name)));


  }

  }



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



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



Re: Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread MattyDE

This works!!! Thanks SO much. But is it the right and easiest way?

Any other suggestions?

Thaanks! :)



Eugene Malan wrote:
 
 Try replacing the Model's object instead of the actual Model.
 
   private EditFormModel editFormModel = new  
 CompoundPropertyModelFunctionsbereich(el);
 
   replace
   //f.setModel(new CompoundPropertyModelFunctionsbereich(el));
   editFormModel.setObject(el);
 
 
 On 16 Dec 2009, at 6:27 AM, Martin U wrote:
 
 Iam totally confused.

 Iam using the Todo-List-Example from here :
 http://www.wicket-library.com/wicket-examples/ajax/todo-list.0
 to play around with wicket.

 This example works, but i want to display a list of Entities from the
 Backend and edit one of them with my new-entity-Form.
 So i want to click on edit in a row and want to use the *same*  
 *form *as i
 use to add a entity. How could i handle this?

 I tried sooo much but nothing works right.


 The addForm (showForm(target)) function works right. But in public  
 void
 showForm(AjaxRequestTarget _t, Functionsbereich el)
 i deliver el which is my POJO and i cant figure out how to treat  
 the Form
 to use now my new Model...
 I tried with modelChange() und mondelChanging() but nothing works  
 =( allways
 the empty Form is shown ;(

 Thanks a lot for any help!!

private final class FormContainer extends WebMarkupContainer{

private EditForm f;

public FormContainer(String id) {
super(id);
setOutputMarkupId(true);


add(f = (EditForm) new EditForm(form).setVisible(false));
add(new AjaxFallbackLink(link){

@Override
public void onClick(AjaxRequestTarget target) {
showForm(target);
}

});
}

public void showForm(AjaxRequestTarget _t){
f.setVisible(true);
_t.addComponent(this);

}

/** Shows form with entity **/
public void showForm(AjaxRequestTarget _t, Functionsbereich  
 el){
 //add(f = new EditForm(link, el));
f.modelChanging();
f.setModel(new  
 CompoundPropertyModelFunctionsbereich(el));


f.modelChanged();
f.setVisible(true);

_t.addComponent(this);

}


}

private final class EditForm extends FormFunctionsbereich{

public EditForm(String id){
this(id, new CompoundPropertyModelFunctionsbereich(new
 Functionsbereich()));
}

public EditForm(String id, Functionsbereich _el){
super(id,new  
 CompoundPropertyModelFunctionsbereich(_el) );
}

public EditForm(String id,  
 CompoundPropertyModelFunctionsbereich
 _model) {
super(id, _model);


setOutputMarkupId(true);
add( new TextField(form_text,  
 _model.bind(label)));

//add(new Label(vendor, _model.bind(vendor.name)));


}

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

-- 
View this message in context: 
http://old.nabble.com/Updating-Form-Elements-by-Ajax-with-new-POJO-Model-tp26810357p26811076.html
Sent from the Wicket - User 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



Re: Updating Form Elements by Ajax with new POJO-Model

2009-12-16 Thread MattyDE

Yeah Eugene,

f.setModelObject(e) works too and its even better i thinks :)

Thanks!


Eugene Malan wrote:
 
 I think you might have to use setVisibilityAllowed(true), otherwise  
 the html does not make it onto the page.
 Maybe this is better...
 
   f = new EditFormFunctionsbereich(form,new  
 CompoundPropertyModelFunctionsbereich(el));
   f.setVisible(false);
   f.setVisibilityAllowed(true);
 
 and then for Ajax...
 
  f.setModelObject(e);
 
 On 16 Dec 2009, at 7:09 AM, Eugene Malan wrote:
 
 Try replacing the Model's object instead of the actual Model.

  private EditFormModel editFormModel = new  
 CompoundPropertyModelFunctionsbereich(el);

  replace
  //f.setModel(new CompoundPropertyModelFunctionsbereich(el));
  editFormModel.setObject(el);


 On 16 Dec 2009, at 6:27 AM, Martin U wrote:

 Iam totally confused.

 Iam using the Todo-List-Example from here :
 http://www.wicket-library.com/wicket-examples/ajax/todo-list.0
 to play around with wicket.

 This example works, but i want to display a list of Entities from the
 Backend and edit one of them with my new-entity-Form.
 So i want to click on edit in a row and want to use the *same*  
 *form *as i
 use to add a entity. How could i handle this?

 I tried sooo much but nothing works right.


 The addForm (showForm(target)) function works right. But in  
 public void
 showForm(AjaxRequestTarget _t, Functionsbereich el)
 i deliver el which is my POJO and i cant figure out how to treat  
 the Form
 to use now my new Model...
 I tried with modelChange() und mondelChanging() but nothing works  
 =( allways
 the empty Form is shown ;(

 Thanks a lot for any help!!

   private final class FormContainer extends WebMarkupContainer{

   private EditForm f;

   public FormContainer(String id) {
   super(id);
   setOutputMarkupId(true);


   add(f = (EditForm) new EditForm(form).setVisible(false));
   add(new AjaxFallbackLink(link){

   @Override
   public void onClick(AjaxRequestTarget target) {
   showForm(target);
   }

   });
   }

   public void showForm(AjaxRequestTarget _t){
   f.setVisible(true);
   _t.addComponent(this);

   }

   /** Shows form with entity **/
   public void showForm(AjaxRequestTarget _t, Functionsbereich  
 el){
 //add(f = new EditForm(link, el));
   f.modelChanging();
   f.setModel(new  
 CompoundPropertyModelFunctionsbereich(el));


   f.modelChanged();
   f.setVisible(true);

   _t.addComponent(this);

   }


   }

   private final class EditForm extends FormFunctionsbereich{

   public EditForm(String id){
   this(id, new CompoundPropertyModelFunctionsbereich(new
 Functionsbereich()));
   }

   public EditForm(String id, Functionsbereich _el){
   super(id,new  
 CompoundPropertyModelFunctionsbereich(_el) );
   }

   public EditForm(String id,  
 CompoundPropertyModelFunctionsbereich
 _model) {
   super(id, _model);


   setOutputMarkupId(true);
   add( new TextField(form_text,  
 _model.bind(label)));

   //add(new Label(vendor, _model.bind(vendor.name)));


   }

   }


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

-- 
View this message in context: 
http://old.nabble.com/Updating-Form-Elements-by-Ajax-with-new-POJO-Model-tp26810357p26811726.html
Sent from the Wicket - User 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