public class RolesAppointment extends MyPage {

    private final IModel<MyClass> personnelModel = new
CompoundPropertyModel<MyClass>(new MyClass()) ;


    final List<String> rolesList = new ArrayList<String>();

    public RolesAppointment() {

        createComponents();

    }

    private void createComponents() {

        final Form<MyClass> form= new Form<MyClass>(
                "form", personnelModel);

        form.add(new DropDownChoice<Roles>("roles",
                new Model<Roles>(), Arrays.asList(Roles.values()),
                new ChoiceRenderer<Roles>("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 ListModel<MyClass> personnelList = new ListModel<MyClass>();

    final AbstractAutoCompleteTextRenderer<MyClass> renderer = new
AbstractAutoCompleteTextRenderer<MyClass>() {
        @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 AutoCompleteTextField<MyClass> personnelAutoComplete;


     private MyClass personnelModel;

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

        personnelAutoComplete = new
AutoCompleteTextField<MyClass>("personnelAutoComplete",
                new PropertyModel<MyClass>(personnelModel == null  ? new
MyClass() : personnelModel, "personnelId"), MyClass.class,
                renderer, new AutoCompleteSettings()) {

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

                List<MyClass> choices = new ArrayList<MyClass>();

                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.IConverter<C> getConverter(
                    java.lang.Class<C> type) {
                return (IConverter<C>) new IConverter<MyClass>() {

                        @Override
                    public MyClass convertToObject(String value,
                            java.util.Locale locale) {
                        List<MyClass> 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] <
[email protected]> wrote:

> On Fri, 22 Feb 2013 13:23:20 -0800 (PST)
> grazia <[hidden email]<http://user/SendEmail.jtp?type=node&node=4656703&i=0>>
> wrote:
>
> > If the form contains a panel, and that panels contains a textfield,
> > and all share the same IModel<MyClass>, 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 IModel<String> - 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: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4656703&i=1>
> For additional commands, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4656703&i=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-tp4656700p4656703.html
>  To unsubscribe from shared models - rules, click 
> here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4656700&code=R3JhemlhLlJ1c3NvTGFzc25lckBnbWFpbC5jb218NDY1NjcwMHwyMjY4MDg1NDM=>
> .
> 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/shared-models-rules-tp4656700p4656704.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]

Reply via email to