Skip to content

refactor: drop formobj, use PageReference for preview Back#449

Merged
tkuhn merged 1 commit intomasterfrom
remove-formobj-use-pagereference
Apr 22, 2026
Merged

refactor: drop formobj, use PageReference for preview Back#449
tkuhn merged 1 commit intomasterfrom
remove-formobj-use-pagereference

Conversation

@tkuhn
Copy link
Copy Markdown
Contributor

@tkuhn tkuhn commented Apr 22, 2026

Summary

Replaces the `formobj` query-param + session `formMap` workaround with Wicket's native `PageReference` for the "Back from preview" flow (see #373).

What changed

  • `NanodashSession.PreviewNanopub` now holds a `PageReference` to the source `PublishPage`.
  • `PublishForm`'s preview button passes `getPage().getPageReference()` when storing the preview.
  • `PreviewPage`'s Back button calls `setResponsePage(ref.getPage())` to return to the live page instance; falls back to `RestartResponseException(PublishPage.class, pageParams)` if the reference has expired from the page store.
  • `PublishPage` / `GenPublishPage` drop the `formobj` redirect and session-cache lookup — just `new PublishForm(...)`.
  • `NanodashSession` drops `formMap`, `MAX_FORMS`, the LRU eviction + logger, and the `setForm`/`hasForm`/`getForm`/`removeForm` helpers (plus the `removeForm` call on successful publish).

Why

  • The page store (capped at 100 MB/session) already preserves stateful pages across requests. The formobj layer was a second cache in front of it, solving the same problem less reliably — it never had more guarantees than the page store, only a smaller LRU (20 entries) that caused premature evictions.
  • `PageReference` is the idiomatic Wicket API for "go back to the page I came from".
  • Net: -103 / +19 lines.

Test plan

  • Fill a template form, click "Preview", click "Back" — form values are still populated.
  • Fill a template form, click "Preview", click "Publish" — confirm page renders, no errors.
  • Fill a template form, fail validation, then preview still works once errors are fixed (sanity check that Placeholder values swapped when removing statement after form validation error #445's fix isn't disturbed).
  • Same three checks via the connector flow (`GenPublishPage` → `PreviewPage`).
  • Open the browser's network tab and confirm `/publish` URLs no longer carry `&formobj=...`.

🤖 Generated with Claude Code

The formobj query param plus session formMap was a workaround to make
the Back button on PreviewPage reach the live PublishForm instance
instead of reconstructing an empty one. Wicket already has a
first-class mechanism for this: PageReference, backed by the page
store.

- PreviewNanopub carries a PageReference to the source PublishPage.
- PreviewPage's Back button resolves it via setResponsePage(page),
  falling back to RestartResponseException(PublishPage.class, params)
  if the reference has expired from the page store.
- PublishPage and GenPublishPage drop the formobj redirect and the
  session-cache lookup; they just instantiate PublishForm directly.
- NanodashSession drops formMap, MAX_FORMS, the LRU eviction, and the
  set/has/get/remove form helpers.

Closes #373.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tkuhn tkuhn force-pushed the remove-formobj-use-pagereference branch from 3a5efea to 063c82c Compare April 22, 2026 15:12
@tkuhn tkuhn merged commit 788e65e into master Apr 22, 2026
15 of 16 checks passed
@tkuhn tkuhn deleted the remove-formobj-use-pagereference branch April 22, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant