Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>PropertyModel uses reflection to look up the named property on a given target object instance. When you constructed the PropertyModel, you passed it a specific instance of Result, i.e. the <code>new Result()</code> from SearchPage's constructor. The PropertyModel will continue to hold a reference to that same Result instance from render to render of this page, serializing the Result at the end and then deserializing the Result at the start of each new request cycle (page view). The fact that you later change the page's <code>currentResult</code> variable to reference a different Result instance does not affect which Result instance the PropertyModel uses to look up its model value. Your PropertyModel does not care what <code>currentResult</code> later refers to.</p> <p>There are two possible solutions that I can think of off the top of my head.</p> <ol> <li><p>Have the PropertyModel read <code>hits</code> from the <em>actual current value</em> of the Page's <code>currentResult</code> variable:</p> <pre><code>new PropertyModel&lt;List&lt;Hit&gt;&gt;(SearchPage.this, "currentResult.hits") </code></pre></li> <li><p>Use a LoadableDetachableModel to load <code>hits</code> once per request cycle/page view:</p> <pre><code>new LoadableDetachableModel&lt;List&lt;Hit&gt;&gt;() { protected Object load() { return getResults(currentQuery); } } </code></pre></li> </ol> <p>Note that a <code>LoadableDetachableModel</code> has to be detached at the end of the request cycle or it will never again call <code>getObject()</code> to recalculate the <code>List&lt;Hit&gt;</code>. That said, since your code shows you'd be using it as the default model of the <code>SearchResults</code> component, the <code>SearchResults</code> component would detach the model for you at the end of the request cycle automatically.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload