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]