Uploaded image for project: 'YesCart'
  1. YesCart
  2. YC-552

Refactor wicket components to properly behave on before render phase

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.0
    • Component/s: chores
    • Labels:

      Description

      Currently some components create all sub components structure in their constructors. This causes the whole component to become static. I.e. once the page loads the components will no change. This creates adverse effect on the locale changing mechanism since the components do not 'recalculate' the labels that are dynamically added. Therefore to improve this we need to move logic in constructors to onBeforeRender() thus allowing natural wicket page lifecycle that allows to refresh object models.

      Note that some components such as stateful forms need to be carefully refactored as reading the form also destroys its state which may cause unexpected behaviour where state must be preserved (e.g. address add/edit page). For forms that must be stateful we need a different approach by supplying model objects that are locale aware and therefore can render correct value when refreshed.

      E.g.
      final Label rez = new Label(NAME, "myLabel");
      can be rewritten to honour locale through locale aware model.
      final Label rez = new Label(NAME, new AbstractReadOnlyModel<String>() {
      @Override
      public String getObject()

      { final String lang = getLocale().getLanguage(); ... return localised value; }

      });

        Attachments

          Activity

            People

            • Assignee:
              denis Denis Pavlov
              Reporter:
              denis Denis Pavlov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: