Skip to content

Commit 22bc9fb

Browse files
committed
[WICKET-7059] make easier to skip some page serialization
1 parent d8b64cf commit 22bc9fb

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

wicket-core/src/main/java/org/apache/wicket/pageStore/RequestPageStore.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.wicket.MetaDataKey;
2323
import org.apache.wicket.page.IManageablePage;
24+
import org.apache.wicket.request.IRequestCycle;
2425
import org.apache.wicket.request.cycle.RequestCycle;
2526
import org.slf4j.Logger;
2627
import org.slf4j.LoggerFactory;
@@ -107,9 +108,10 @@ public void end(IPageContext context)
107108
public void detach(IPageContext context)
108109
{
109110
RequestData requestData = getRequestData(context);
111+
IRequestCycle requestCycle = RequestCycle.get();
110112
for (IManageablePage page : requestData.pages())
111113
{
112-
if (isPageStateless(page) == false)
114+
if (isPageStateless(page) == false && shouldSerializePage(requestCycle, page))
113115
{
114116
getDelegate().addPage(context, page);
115117
}
@@ -119,6 +121,21 @@ public void detach(IPageContext context)
119121
getDelegate().detach(context);
120122
}
121123

124+
/**
125+
* Give the opportunity to skip some serializations. E.g. we have some AJAX behavior that is sending some
126+
* info from client to page but page structure didn't change at all and nothing is repainted via AJAX.
127+
* But this will trigger a serialization. Returning false here would prevent that request from doing a
128+
* page serialization. For heavy pages this can really make a difference.
129+
*
130+
* @param requestCycle The request
131+
* @param page The {@link IManageablePage}
132+
* @return <code>true</code> if page should be serialized for this request. The default is true.
133+
*/
134+
protected boolean shouldSerializePage(IRequestCycle requestCycle, IManageablePage page)
135+
{
136+
return true;
137+
}
138+
122139
private boolean isPageStateless(final IManageablePage page) {
123140
boolean isPageStateless;
124141
try

0 commit comments

Comments
 (0)