I have read it - a few times over the last 3 years of using Wicket and
even bought the book ;)
It says
"To use a CompoundPropertyModel, simply set one as the model for a
container, such as a Form or a Page. Create the contained components with
no model of their own. Insure that the component identifier names match
the appropriate property names."
The AjaxSubmitLink is picking-up the parent forms compound property model
but only checking to see if the "mylink" property exists when onSubmit
calls getModelObject().
I would like to get the Forms model via getModelObject but because it
errors when called, I have to either set a false model on the
AjaxSubmitLink or get the model object outside of the onSubmit, assign it
to a final property and then use it in the onSubmit.
I'm happy to admit that I'm doing something wrong but I cannot see what it
is???
Thanks again,
Tim
> no, components do not randomly pick up models from their parents. i
> would suggest reading the models wiki page.
>
> -igor
>
>
> On Mon, Apr 7, 2008 at 3:11 PM, Tim <[EMAIL PROTECTED]> wrote:
>> Thanks Igor but should it not pick-up the model from the Form? There's
>> no
>> constructor that takes a model. Should the AjaxSubmitLink(id, form)
>> constructor be used with the Form that it's being added to? e..g
>>
>> MyForm extends Form {
>> public MyForm(....){
>> ....
>> add( new AjaxSubmitLink("mylink",this){
>> ....
>> });
>> }}
>>
>> If it's already bound to a Form, should it not pick-up the model used
>> by
>> the form?
>>
>> Am I looking at the problem/solution the wrong way???
>>
>> Thanks again,
>> Tim
>>
>>
>>
>> > you forgot to give ajaxsubmitlink a model, so getmodelobject() will
>> > either return null or a compound model.confirm - neither of which i
>> > think you want.
>> >
>> > -igor
>> >
>> >
>> > On Mon, Apr 7, 2008 at 1:00 PM, Tim Squires <[EMAIL PROTECTED]> wrote:
>> >> Hi,
>> >>
>> >> When adding an AjaxSubmitLink, the onSubmit method tries to access
>> a
>> >> property of the model object that does not exists:
>> >>
>> >> -------------------
>> >> final AjaxSubmitLink confirmLink = new
>> >> AjaxSubmitLink("confirm") {
>> >> @Override
>> >> public void onSubmit(final AjaxRequestTarget target,
>> >> final Form form) {
>> >> if (((Will) getModelObject()).getExecutor() !=
>> null)
>> >> {
>> >> willModalWindow.show(target);
>> >> } else {
>> >> warn("Please choose an executor.");
>> >> target.addComponent(feedback);
>> >> }
>> >> }
>> >>
>> >> @Override
>> >> public void onError(final AjaxRequestTarget target,
>> >> final Form form) {
>> >> target.addComponent(feedback);
>> >> }
>> >> };
>> >>
>> >> add(confirmLink);
>> >> -------------------
>> >>
>> >> It tries to access the "confirm" property of the Model, in this
>> case a
>> >> Will object.
>> >>
>> >> -------------------
>> >> org.apache.wicket.WicketRuntimeException: No get method defined for
>> >> class:
>> >> class crystalmark.willfinder.model.Will expression: confirm
>> >> at
>> >>
>> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:433)
>> >> at
>> >>
>> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:275)
>> >> at
>> >>
>> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:84)
>> >> at
>> >>
>> org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:113)
>> >> at
>> org.apache.wicket.Component.getModelObject(Component.java:1551)
>> >> at
>> >>
>> crystalmark.willfinder.page.components.EditWillPanel$EditWillForm$5.onSubmit(EditWillPanel.java:183)
>> >> at
>> >>
>> org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink$1.onSubmit(AjaxSubmitLink.java:94)
>> >> at
>> >>
>> org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:128)
>> >> -------------------
>> >>
>> >> It's only when using the getModelObject method. If I get the Will
>> >> object
>> >> from else-where it works fine.
>> >>
>> >> Is this a problem with the way I'm using the model or a bug with
>> >> AjaxSubmitLink? Should I add it to jira?
>> >>
>> >> Wicket 1.3.3 + JDK 1.6 + Tomcat 6
>> >>
>> >> Thanks,
>> >> Tim
>> >> -------------------
>> >> http://www.tnwdb.com - Wicket Wills!
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]