hrm, we should change that message to info rather then warn, warn is a
little too strong.

the problem is that textfield tries to resolve what type of object it
is bound to (a string, an int, etc) but cant because the model object
is null.

you can silence the warning by explicitly setting a type on the textfield, eg

 add(new TextField<String>("street", new
PropertyModel<String>(addressModel, "street"), ***String.class***));

or, since you will get an NPE if you submit the form, a better way
would be to hide the form entirely

addresspanel { isvisible() { return getmodelobject()!=null; }}

-igor


On Fri, Nov 20, 2009 at 9:31 AM, Kogel, Jonck-van-der
<jonck-van-der.ko...@bmw.nl> wrote:
> Hi,
> I'm have a question about my application design and whether I should
> pass a model to a panel or an id and create a new
> LoadableDetachableModel in the panel. Here is a basic layout of my app:
>
> I have taken out the non-relevant parts for brevity.
>
> My domain model is basically as follows:
> Base class is ARF. It has an owner, a keeper and a user. The owner,
> keeper and user all have a correspondence address and a visiting
> address.
>
> The layout of my application reflects this. The main screen has 3 tabs,
> one for owner, one for user and one for keeper. These tabs are panels. I
> also defined one addressPanel to display all the addresses.
>
> So when I am building my view, it is as follows:
>
> On my page I create a LoadableDetachableModel as follows:
>
> IModel<ARF> arfModel = new LoadableDetachableModel<ARF>() {
> �...@override
>  protected ARF load() {
>  return arfService.load(arfId);
>  }
> };
>
> I pass this model on to my tabs panel:
>
> public class ArfPageTabsPanel extends Panel {
>  public ArfPageTabsPanel(String id, IModel<ARF> arfModel) {
>  super(id);
>  add(new TabOwner("tabOwner", arfModel));
>  add(new TabKeeper("tabKeeper", arfModel));
>  add(new TabUser("tabUser", arfModel));
>  }
> }
>
> The TabOwner class is as follows:
>
> public class TabOwner extends Panel {
>  public TabOwner(String id, IModel<ARF> arfModel) {
>  super(id);
>
>  add(new AddressPanel("correspondenceAddress", "Correspondentie-adres",
> new PropertyModel<Address>(arfModel, "owner.correspondenceAddress")));
>  add(new AddressPanel("visitingAddress", "Bezoekadres", new
> PropertyModel<Address>(arfModel, "owner.visitingAddress")));
>  }
> }
>
> the TabKeeper and TabUser classes are much the same as the TabOwner
> class (probably I could do some code reuse here, I'll do that when
> everything is working and I understand it all).
>
> And then the AddressPanel is as follows:
>
> public class AddressPanel extends Panel {
>  public AddressPanel(String id, String addressHeader, IModel<Address>
> addressModel) {
>  super(id);
>  add(new Label("addressHeader", addressHeader));
>  add(new TextField<String>("street", new
> PropertyModel<String>(addressModel, "street")));
>  add(new TextField<String>("houseNr", new
> PropertyModel<String>(addressModel, "houseNr")));
>  add(new TextField<String>("houseNrExt", new
> PropertyModel<String>(addressModel, "houseNrExt")));
>  add(new TextField<String>("zipcode", new
> PropertyModel<String>(addressModel, "zipcode")));
>  add(new TextField<String>("city", new
> PropertyModel<String>(addressModel, "city")));
>  }
> }
>
>
> So I am nesting all my models here, since the underlying arfModel is a
> LoadableDetachableModel and I don't want to get my panels and the main
> view out of sync. The problem is however that sometimes there is no
> owner/keeper/user and hence also no addresses for that relation. When I
> do load an ARF that has a null keeper for example, my console is flooded
> with the following message:
>
> 2009-11-20 17:42:02,274 WARN [AbstractTextComponent] Couldn't resolve
> model type of
> Model:classname=[org.apache.wicket.model.PropertyModel]:nestedModel=[Mod
> el:classname=[org.apache.wicket.model.PropertyModel]:nestedModel=[Model:
> classname=[com.bmw.preparer2.view.ArfPage$1]:attached=true:tempModelObje
> ct=[com.bmw.preparer2.domain....@d737e3]]:expression=[user.visitingAddre
> ss]]:expression=[city] for [MarkupContainer [Component id = city]],
> please set the type yourself.
>
>
>
> I am assuming that this has to do with that I am nesting my models and
> that one of them is null. So in the AddressPanel I am creating a
> PropertyModel where the passed on model is potentially null.
>
> So my question is, how do I handle such a situation? Please advise.
>
> Thanks very much, Jonck van der Kogel
>
>

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

Reply via email to