I can see the following problems:
-you have put the list of area's for the dropdown in the session, this
is fine but not required.
 What you should have done is put a model in the session that will
contain a single area.
-you are only providing the dropdown with the options it has, not with
the model it should use to store the selection.
 use something like this
DropDownChoice areas = new
DropDownChoice("areas",---->((WholSession)Session.get()).getAreaSelectionModel()<----,
(WholSession)Session.get()).getAreaModel(), new ChoiceRenderer("name",
"id"));
where getAreaSelectionModel() is the model which contains the selected
area (see point 1)

The constructor you are using expects an IComponentInheritedModel
higher up the component tree.

Maurice

On Fri, Feb 22, 2008 at 1:44 PM, steviezz <[EMAIL PROTECTED]> wrote:
>
>  Guys - thanks for your continued help with this, but I'm still having some
>  problems with:
>
>    "Attempt to set model object on null model of component."
>
>  I now have some code cut down to the simplest possible example (attempting
>  to follow the advice given already):
>
>
>  public class AreaChoiceModel extends LoadableDetachableModel {
>         protected Object load() {
>             return ((WholSession) Session.get()).getAreaList();
>         }
>  }
>
>
>  public class WholSession extends WebSession {
>
>         private IModel areaModel = new AreaChoiceModel();
>
>         public WholSession(Request request) {
>                 super(request);
>         }
>
>         protected void onDetach() {
>                 areaModel = null;
>         }
>
>         public IModel getAreaModel() {
>                 return areaModel;
>         }
>
>         public List<Area> getAreaList() {
>                 return ((WholApplication) getApplication()).getAreas();
>         }
>  }
>
>
>
>  public class PanelSearch extends FormComponentPanel {
>
>         public PanelSearch(String id) {
>                 super(id, ((WholSession) Session.get()).getAreaModel());
>                 add(new SearchForm("searchForm"));
>                 add(new FeedbackPanel("feedback"));
>         }
>
>         private class SearchForm extends Form {
>
>                 public SearchForm(String id) {
>                      super(id);
>                      DropDownChoice areas = new DropDownChoice("areas",
>  ((WholSession)
>                        Session.get()).getAreaModel(), new
>  ChoiceRenderer("name", "id"));
>                     areas.setOutputMarkupId(true);
>                     add(areas);
>                 }
>
>                 protected void onSubmit() {
>                         System.out.println("onSubmit called");
>                 };
>         }
>  }
>
>
>  Page with panel and form loads OK with selection box populated with my top
>  level Area list (I've removed everything else).
>
>  Clicking the button results in the error:
>
>  WicketMessage: Method onFormSubmitted of interface
>  org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
>  [MarkupContainer [Component id = searchForm, page =
>  sds.whol.wicket.pages.Index, path =
>  0:panelSearch:searchForm.PanelSearch$SearchForm, isVisible = true,
>  isVersioned = false]] threw an exception
>
>  Root cause:
>
>
>  java.lang.IllegalStateException: Attempt to set model object on null model
>  of component: panelSearch:searchForm:areas
>
> at org.apache.wicket.Component.setModelObject(Component.java:2850)
>
>
>  I'm obviously still missing something important here (or maybe I've cut out
>  too much code :-}).  I suspect it's something very simple, so any further
>  pointers welcome.
>
>  Note - I've now bought the Wicket In Action eBook, so may have this worked
>  out once I've had time to study it in some detail.
>
>  Thanks again.
>
>
>
>
>
>
>
>  Michael O'Cleirigh wrote:
>  >
>  > Hello,
>  >
>  > This error happens because the intermediary panel between the form and
>  > the drop down choice does not have a model.
>  >
>  > Changing the PanelSearch constructor to call super (id, new Model())
>  > should fix the problem.
>  >
>  > You might also want your form panel to extend FormComponentPanel instead
>  > to get better validation support.
>  >
>  > Mike
>  >> Or you did not set the model on the dropdown.
>  >>
>  >> Maurice
>  >>
>  >> On Thu, Feb 21, 2008 at 8:44 PM, Maurice Marrink <[EMAIL PROTECTED]>
>  >> wrote:
>  >>
>  >>> Looks like at least one of the models in the session is not properly
>  >>>  initialized.
>  >>>  You have to do something like
>  >>>  private IModel model=new WhateverModel(null);
>  >>>  in your session.
>  >>>
>  >>>  Maurice
>  >>>
>  >>>
>  >>>
>  >>>  On Thu, Feb 21, 2008 at 8:41 PM, steviezz <[EMAIL PROTECTED]>
>  >>> wrote:
>  >>>  >
>  >>>  >  Now getting
>  >>>  >
>  >>>  >  RequestCycle.logRuntimeException(1399) | Attempt to set model object
>  >>> on null
>  >>>  >  model of component: panelSearch:form:parentAreas
>  >>>  >  java.lang.IllegalStateException: Attempt to set model object on null
>  >>> model
>  >>>  >  of component: panelSearch:form:parentAreas
>  >>>  >         at
>  >>> org.apache.wicket.Component.setModelObject(Component.java:2850)
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >  Mr Mean wrote:
>  >>>  >  >
>  >>>  >  > Don't add wicket components to the session, use models.
>  >>>  >  > for example
>  >>>  >  > class MySession extends WebSession
>  >>>  >  > {
>  >>>  >  >  private IModel dropdown1=new WhateverModel(null); //etc for the
>  >>> others
>  >>>  >  >  // add getters() for models
>  >>>  >  > }
>  >>>  >  >
>  >>>  >  > class PanelSearch extends Panel
>  >>>  >  > {
>  >>>  >  >  public PanelSearch(String id)
>  >>>  >  > {
>  >>>  >  >  super(id);
>  >>>  >  >  add(new
>  >>>  >  >
>  >>> 
> DropDownChoice("dropdown1",((MySession)Session.get()).getDropdown1(),myChoices)
>  >>>  >  > }
>  >>>  >  > }
>  >>>  >  >
>  >>>  >  > class SomePage extends WebPage
>  >>>  >  > {
>  >>>  >  >  public SomePage()
>  >>>  >  > {
>  >>>  >  >  super();
>  >>>  >  >  add(new PanelSearch("search"));
>  >>>  >  > }
>  >>>  >  > }
>  >>>  >  >
>  >>>  >  > The trick is always using the shared models in your session, that
>  >>> is
>  >>>  >  > why you don't need setters for them and you have to initialize
>  >>> them
>  >>>  >  > properly with some default.
>  >>>  >  > That way the form automatically writes the new values to your
>  >>> session
>  >>>  >  > and you don't have to do that manually.
>  >>>  >  >
>  >>>  >  > How much less code can you have?
>  >>>  >  >
>  >>>  >  > Maurice
>  >>>  >  >
>  >>>  >  > On Thu, Feb 21, 2008 at 1:44 PM, steviezz
>  >>> <[EMAIL PROTECTED]>
>  >>>  >  > wrote:
>  >>>  >  >>
>  >>>  >  >>  Thanks.
>  >>>  >  >>
>  >>>  >  >>  I have already moved to using the session for storage.  I've
>  >>> tried just
>  >>>  >  >>  adding the complete search panel object to the session in the
>  >>> search
>  >>>  >  >>  onsubmit() and fetching it again to add to the results page -
>  >>> this works
>  >>>  >  >> and
>  >>>  >  >>  avoids some of my page reload and history issues (but adds a few
>  >>>  >  >> others),
>  >>>  >  >>  but I presume its not really a good idea to store large object
>  >>> graphs in
>  >>>  >  >> the
>  >>>  >  >>  session - maybe better to just store the selected values and
>  >>> rebuild the
>  >>>  >  >>  selection dropdowns as required.  Plus, this will probably help
>  >>> me iron
>  >>>  >  >> out
>  >>>  >  >>  my inconsistent dropdown state problems.
>  >>>  >  >>
>  >>>  >  >>  But I'm still searching for a magic solution that does not
>  >>> involve
>  >>>  >  >> writing
>  >>>  >  >>  too much code :-}
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >>  Mr Mean wrote:
>  >>>  >  >>  >
>  >>>  >  >>  > I would not recommend what you are doing here.
>  >>>  >  >>  > What happens is that wicket removes the panel from the
>  >>> original page
>  >>>  >  >>  > and attaches it to the new page, making it impossible to use
>  >>> the
>  >>>  >  >>  > backbutton (because wicket will complain about a missing
>  >>> component).
>  >>>  >  >>  > Also this only works if the html of the new page uses the same
>  >>>  >  >>  > component id.
>  >>>  >  >>  >
>  >>>  >  >>  > It is better to store the selection for your dropdowns in the
>  >>> session
>  >>>  >  >>  > (as suggested before).
>  >>>  >  >>  > Then in the constructor of your PanelSearch you can check if
>  >>> the
>  >>>  >  >>  > session contains a value for the dropdowns and if that is the
>  >>> case set
>  >>>  >  >>  > it as the model for the dropdown. That way you don't have to
>  >>> pass the
>  >>>  >  >>  > state to every page.
>  >>>  >  >>  >
>  >>>  >  >>  > Maurice
>  >>>  >  >>  >
>  >>>  >  >>  > On Thu, Feb 21, 2008 at 11:35 AM, steviezz
>  >>> <[EMAIL PROTECTED]>
>  >>>  >  >>  > wrote:
>  >>>  >  >>  >>
>  >>>  >  >>  >>  Answering my own questions.
>  >>>  >  >>  >>
>  >>>  >  >>  >>  I can also pass the search panel to the results page from my
>  >>> form
>  >>>  >  >>  >> onSubmit:
>  >>>  >  >>  >>
>  >>>  >  >>  >>         setResponsePage(new
>  >>>  >  >>  >> SearchResults(((PanelSearch)this.getParent()),
>  >>>  >  >>  >>  search));
>  >>>  >  >>  >>
>  >>>  >  >>  >>  Then, in the results page:
>  >>>  >  >>  >>
>  >>>  >  >>  >>        public SearchResults(PanelSearch searchPanel, Search
>  >>> search) {
>  >>>  >  >>  >>                 add(searchPanel);
>  >>>  >  >>  >>         }
>  >>>  >  >>  >>
>  >>>  >  >>  >>  Mostly seems to work OK - panel on results page retains
>  >>> state from
>  >>>  >  >>  >> search
>  >>>  >  >>  >>  page.
>  >>>  >  >>  >>
>  >>>  >  >>  >>  Still getting some weird behaviour with the Ajax dropdowns
>  >>> on page
>  >>>  >  >>  >> refreshes
>  >>>  >  >>  >>  - can get crazy state of North America, Canada, Kansas if I
>  >>> refresh
>  >>>  >  >> the
>  >>>  >  >>  >> page
>  >>>  >  >>  >>  between selection changes (old state gets mixed in with
>  >>> partial new
>  >>>  >  >>  >> state)
>  >>>  >  >>  >>
>  >>>  >  >>  >>  Other thing to sort is how to reload panel state if user
>  >>> goes back
>  >>>  >  >> to
>  >>>  >  >>  >> the
>  >>>  >  >>  >>  home page (containing search panel) via a basic external
>  >>> navigation
>  >>>  >  >> link
>  >>>  >  >>  >> -
>  >>>  >  >>  >>  panel will be in its initial blank state.  Perhaps I do need
>  >>> to look
>  >>>  >  >>  >> into
>  >>>  >  >>  >>  loading from the session for this.
>  >>>  >  >>  >>
>  >>>  >  >>  >>  But I'm starting to like Wicket - this kind of stuff takes
>  >>> much more
>  >>>  >  >>  >> code in
>  >>>  >  >>  >>  other frameworks.
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>  >>  steviezz wrote:
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  > I am now passing the search form model to the new page in
>  >>> the
>  >>>  >  >>  >> constructor,
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  >   setResponsePage(new SearchResults(search));
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  > Works OK - I assume this is better than going through the
>  >>> session.
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  > But I have no idea (yet) how to reinitialise the search
>  >>> panel Ajax
>  >>>  >  >>  >>  > widgets.
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  > wicket user-2 wrote:
>  >>>  >  >>  >>  >>
>  >>>  >  >>  >>  >> store the backing model in the session and get it from
>  >>> the
>  >>>  >  >> session,
>  >>>  >  >>  >> this
>  >>>  >  >>  >>  >> will help you retain the state in all the cases
>  >>>  >  >>  >>  >>
>  >>>  >  >>  >>  >> Cheers
>  >>>  >  >>  >>  >> Dipu
>  >>>  >  >>  >>  >>
>  >>>  >  >>  >>  >>
>  >>>  >  >>  >>  >>
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>  >
>  >>>  >  >>  >>
>  >>>  >  >>  >>  --
>  >>>  >  >>  >>  View this message in context:
>  >>>  >  >>  >>
>  >>>  >  >>
>  >>> 
> http://www.nabble.com/Combining-Ajax-and-non-Ajax-pages-tp15587166p15607263.html
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>  >> Sent from the Wicket - User mailing list archive at
>  >>> Nabble.com.
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>  >>
>  >>>  >  >>
>  >>> ---------------------------------------------------------------------
>  >>>  >  >>  >>  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]
>  >>>  >  >>  >
>  >>>  >  >>  >
>  >>>  >  >>  >
>  >>>  >  >>
>  >>>  >  >>  --
>  >>>  >  >>  View this message in context:
>  >>>  >  >>
>  >>> 
> http://www.nabble.com/Combining-Ajax-and-non-Ajax-pages-tp15587166p15610292.html
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >> Sent from the Wicket - User mailing list archive at Nabble.com.
>  >>>  >  >>
>  >>>  >  >>
>  >>>  >  >>
>  >>> ---------------------------------------------------------------------
>  >>>  >  >>  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]
>  >>>  >  >
>  >>>  >  >
>  >>>  >  >
>  >>>  >
>  >>>  >  --
>  >>>  >  View this message in context:
>  >>> 
> http://www.nabble.com/Combining-Ajax-and-non-Ajax-pages-tp15587166p15618707.html
>  >>>  >
>  >>>  >
>  >>>  > Sent from the Wicket - User mailing list archive at Nabble.com.
>  >>>  >
>  >>>  >
>  >>>  >
>  >>> ---------------------------------------------------------------------
>  >>>  >  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]
>  >
>  >
>  >
>
>  --
>  View this message in context: 
> http://www.nabble.com/Combining-Ajax-and-non-Ajax-pages-tp15587166p15632887.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  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]

Reply via email to