Re: shared models - rules

2013-02-23 Thread grazia
Made it, CompoundPropertyModels, used correctly, made things work.

On Fri, Feb 22, 2013 at 6:49 PM, Grazia Russo Lassner 
grazia.russolass...@gmail.com wrote:

 THank you for the suggestion. It prints the MyClass object but nothing has
 ben set. Not even the converter of the AUtoCompleteTextFiled is being
 called ... I cannot figure out why ...


 On Fri, Feb 22, 2013 at 5:08 PM, duesenklipper [via Apache Wicket] 
 ml-node+s1842946n4656705...@n4.nabble.com wrote:

  form.add(new Button(appointButton) {
 
  public void onSubmit() {
  System.out.println(HERE =  + getModelObject() );
  -- whatever it is the choice in the autocomplete which is within
  the MyPersonnelPanel this is always null
 
  }
 

 I didn't look at the rest of the code yet since it's pretty late here,
 but this definitely won't work. You're calling the Button's
 getModelObject(), not the Form's, since at this point you're in the
 Button's onSubmit(), so this would be the Button. You don't give the
 button a model, so you're getting null. If you want to use it in there,
 you can for example call form.getModelObject().

 Carl-Eric

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656705i=0
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656705i=1



 --
  If you reply to this email, your message will be added to the
 discussion below:

 http://apache-wicket.1842946.n4.nabble.com/shared-models-rules-tp4656700p4656705.html
  To unsubscribe from shared models - rules, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4656700code=R3JhemlhLlJ1c3NvTGFzc25lckBnbWFpbC5jb218NDY1NjcwMHwyMjY4MDg1NDM=
 .
 NAMLhttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=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/shared-models-rules-tp4656700p4656713.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



Re: shared models - rules

2013-02-22 Thread Carl-Eric Menzel
On Fri, 22 Feb 2013 12:42:14 -0800 (PST)
grazia grazia.russolass...@gmail.com wrote:

 Say I have a page with several components all sharing the same model;
 what are the rules of thumb to make sure the same model gets updated
 byt the different components on the page ?

If you only ever pass these components that one model, then they only
have that one to update, so that's what they'll do. Are you seeing some
sort of unexpected effect?

Carl-Eric

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



Re: shared models - rules

2013-02-22 Thread grazia
If the form contains a panel, and that panels contains a textfield, and all
share the same IModelMyClass, this is what I see:
the textField model gets updated, but not the panel's model and not the
form's model.

It seems I am missing something with the panels ... it is as if they were
some sort of barrier ...



On Fri, Feb 22, 2013 at 3:19 PM, duesenklipper [via Apache Wicket] 
ml-node+s1842946n4656701...@n4.nabble.com wrote:

 On Fri, 22 Feb 2013 12:42:14 -0800 (PST)
 grazia [hidden email]http://user/SendEmail.jtp?type=nodenode=4656701i=0
 wrote:

  Say I have a page with several components all sharing the same model;
  what are the rules of thumb to make sure the same model gets updated
  byt the different components on the page ?

 If you only ever pass these components that one model, then they only
 have that one to update, so that's what they'll do. Are you seeing some
 sort of unexpected effect?

 Carl-Eric

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656701i=1
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656701i=2



 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://apache-wicket.1842946.n4.nabble.com/shared-models-rules-tp4656700p4656701.html
  To unsubscribe from shared models - rules, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4656700code=R3JhemlhLlJ1c3NvTGFzc25lckBnbWFpbC5jb218NDY1NjcwMHwyMjY4MDg1NDM=
 .
 NAMLhttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=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/shared-models-rules-tp4656700p4656702.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



Re: shared models - rules

2013-02-22 Thread Carl-Eric Menzel
On Fri, 22 Feb 2013 13:23:20 -0800 (PST)
grazia grazia.russolass...@gmail.com wrote:

 If the form contains a panel, and that panels contains a textfield,
 and all share the same IModelMyClass, this is what I see:
 the textField model gets updated, but not the panel's model and not
 the form's model.
 
 It seems I am missing something with the panels ... it is as if they
 were some sort of barrier ...

Can you show us some code? The textfield presumably should be working
on an IModelString - what are the other models? Try pasting your
form, panel and textfield code somewhere so we can have a look.

Carl-Eric

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



Re: shared models - rules

2013-02-22 Thread grazia
public class RolesAppointment extends MyPage {

private final IModelMyClass personnelModel = new
CompoundPropertyModelMyClass(new MyClass()) ;


final ListString rolesList = new ArrayListString();

public RolesAppointment() {

createComponents();

}

private void createComponents() {

final FormMyClass form= new FormMyClass(
form, personnelModel);

form.add(new DropDownChoiceRoles(roles,
new ModelRoles(), Arrays.asList(Roles.values()),
new ChoiceRendererRoles(roleName)).setNullValid(true));

form.add(new AjaxLazyLoadPanel(personnelPanel,
personnelModel) {

@Override
public Component getLazyLoadComponent(final String markupId) {
return new MyPersonnelPanel(markupId, form.getModelObject()
);
}



});


form.add(new Button(appointButton) {

public void onSubmit() {
System.out.println(HERE =  + getModelObject() ); --
whatever it is the choice in the autocomplete which is within the
MyPersonnelPanel this is always null

}




});

add(form);


}

}

MyPersonnelPanel 




public class MyPersonnelPanel extends Panel implements IAjaxIndicatorAware {

@Inject
private PersonnelDao personnelDao;

final ListModelMyClass personnelList = new ListModelMyClass();

final AbstractAutoCompleteTextRendererMyClass renderer = new
AbstractAutoCompleteTextRendererMyClass() {
@Override
protected String getTextValue(MyClass object) {
return object.getTitleFormat();
}

@Override
protected void renderChoice(MyClass object,
org.apache.wicket.request.Response response, String
criteria) {
response.write(getTextValue(object));
};

};

 private final AutoCompleteTextFieldMyClass personnelAutoComplete;


 private MyClass personnelModel;

public MyPersonnelPanel(final String id,
final MyClass personnelModel) {
super(id);
this.personnelModel = personnelModel;

personnelAutoComplete = new
AutoCompleteTextFieldMyClass(personnelAutoComplete,
new PropertyModelMyClass(personnelModel == null  ? new
MyClass() : personnelModel, personnelId), MyClass.class,
renderer, new AutoCompleteSettings()) {

@Override
protected final IteratorMyClass getChoices(final String
input) {
if (Strings.isEmpty(input)) {
return Collections.EMPTY_LIST.iterator();
}

ListMyClass choices = new ArrayListMyClass();

if (input.length()  1) {
personnelList.setObject(personnelDao
.findByLastName(input));
}

for (final MyClass  person : personnelList.getObject()) {
if (person.getLastName().trim()
.startsWith(input.toUpperCase())) {

choices.add(person);
}
}

return choices.iterator();
}

@Override
public C extends Object
org.apache.wicket.util.convert.IConverterC getConverter(
java.lang.ClassC type) {
return (IConverterC) new IConverterMyClass() {

@Override
public MyClass convertToObject(String value,
java.util.Locale locale) {
ListMyClass selectedChoices = personnelList
.getObject();
for (Iterator iterator =
selectedChoices.iterator(); iterator
.hasNext();) {
MyClass choice = (MyClass) iterator
.next();
if (choice.getTitleFormat().startsWith(value)) {
return choice;
}

}

return null;
}

@Override
public String convertToString(MyClass value,
java.util.Locale locale) {
// TODO Auto-generated method stub
if (value != null) {
return Long.toString(value.getPersonnelId());
}
return null;
}

};
}

};


add(personnelAutoComplete);


}





@Override
public String getAjaxIndicatorMarkupId() {

return veil;
}



}


On Fri, Feb 22, 2013 at 3:52 PM, duesenklipper [via Apache Wicket] 
ml-node+s1842946n4656703...@n4.nabble.com wrote:

 On Fri, 22 Feb 2013 13:23:20 -0800 (PST)
 grazia [hidden 

Re: shared models - rules

2013-02-22 Thread Carl-Eric Menzel
 form.add(new Button(appointButton) {
 
 public void onSubmit() {
 System.out.println(HERE =  + getModelObject() );
 -- whatever it is the choice in the autocomplete which is within
 the MyPersonnelPanel this is always null
 
 }
 

I didn't look at the rest of the code yet since it's pretty late here,
but this definitely won't work. You're calling the Button's
getModelObject(), not the Form's, since at this point you're in the
Button's onSubmit(), so this would be the Button. You don't give the
button a model, so you're getting null. If you want to use it in there,
you can for example call form.getModelObject().

Carl-Eric

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



Re: shared models - rules

2013-02-22 Thread grazia
THank you for the suggestion. It prints the MyClass object but nothing has
ben set. Not even the converter of the AUtoCompleteTextFiled is being
called ... I cannot figure out why ...

On Fri, Feb 22, 2013 at 5:08 PM, duesenklipper [via Apache Wicket] 
ml-node+s1842946n4656705...@n4.nabble.com wrote:

  form.add(new Button(appointButton) {
 
  public void onSubmit() {
  System.out.println(HERE =  + getModelObject() );
  -- whatever it is the choice in the autocomplete which is within
  the MyPersonnelPanel this is always null
 
  }
 

 I didn't look at the rest of the code yet since it's pretty late here,
 but this definitely won't work. You're calling the Button's
 getModelObject(), not the Form's, since at this point you're in the
 Button's onSubmit(), so this would be the Button. You don't give the
 button a model, so you're getting null. If you want to use it in there,
 you can for example call form.getModelObject().

 Carl-Eric

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656705i=0
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4656705i=1



 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://apache-wicket.1842946.n4.nabble.com/shared-models-rules-tp4656700p4656705.html
  To unsubscribe from shared models - rules, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4656700code=R3JhemlhLlJ1c3NvTGFzc25lckBnbWFpbC5jb218NDY1NjcwMHwyMjY4MDg1NDM=
 .
 NAMLhttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=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/shared-models-rules-tp4656700p4656708.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