i think that is intended. going back is like cancelling the current
screen. if that was changed thenyou would have to have a valid current
screen before you could go back, which is not something a user would
expect imho.

-igor


On Fri, May 16, 2008 at 7:47 AM, Till Wenzinger <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
>
> In the second step of a Wizard, I am loosing selections of a CheckGroup if I
> am going back to the first step using the Previous Button and return using
> the Next Button. Consider the following code:
>
>
>
> public class CheckBug extends WebPage
>
> {
>
>  public CheckBug() {
>
>    final Wizard wizard = new CheckBugWizard("wizard", PageWithParameters.
> class);
>
>    add(wizard);
>
>    wizard.add(wizard.getForm());
>
>  }
>
> }
>
>
>
> public class CheckBugWizard extends Wizard
>
> {
>
>  private static final long serialVersionUID = 1L;
>
>
>
>  private static final String value = "value";
>
>
>
>  private final Class exitPage;
>
>  private final Collection selection = new
> ArrayList(Arrays.asList(newString[] {
> value }));
>
>
>
>  public CheckBugWizard(final String id, final Class exitPage) {
>
>    super(id);
>
>    this.exitPage = exitPage;
>
>
>
>    final WizardModel model = new WizardModel();
>
>    model.add(new Step1("step1", "summary1"));
>
>    model.add(new Step2("step2", "summary2", this.selection, value));
>
>    init(model);
>
>  }
>
>
>
>  public void onCancel() {
>
>    gotoExitPage();
>
>  }
>
>
>
>  public void onFinish() {
>
>    gotoExitPage();
>
>  }
>
>
>
>  private void gotoExitPage() {
>
>    final PageParameters p = new PageParameters();
>
>
>
>    if (this.selection.contains(value)) {
>
>      p.put("selected", "true");
>
>    }
>
>    else {
>
>      p.put("selected", "false");
>
>    }
>
>
>
>    setResponsePage(this.exitPage, p);
>
>  }
>
> }
>
>
>
> public class Step1 extends WizardStep
>
> {
>
>  private static final long serialVersionUID = 1L;
>
>
>
>  public Step1(final String title, final String summary) {
>
>    super(title, summary);
>
>  }
>
> }
>
>
>
> public class Step2 extends WizardStep
>
> {
>
>  private static final long serialVersionUID = 1L;
>
>
>
>  public Step2(final String title, final String summary, final Collection
> selection, final String value) {
>
>    super(title, summary);
>
>
>
>    final CheckGroup group = new CheckGroup("group", selection);
>
>    add(group);
>
>
>
>    final RepeatingView repeater = new RepeatingView("repeater");
>
>    group.add(repeater);
>
>
>
>    final WebMarkupContainer container =
> newWebMarkupContainer(repeater.newChildId());
>
>    repeater.add(container);
>
>
>
>    final Check check = new Check("box", new Model(value));
>
>    check.setOutputMarkupId(true);
>
>    container.add(check);
>
>
>
>    final Label label = new Label("label", value);
>
>    container.add(label);
>
>  }
>
> }
>
>
>
> public class PageWithParameters extends WebPage
>
> {
>
>  public PageWithParameters(final PageParameters parameters) {
>
>    super(parameters);
>
>
>
>    final MultiLineLabel label = new MultiLineLabel("label",
> newAbstractReadOnlyModel() {
>
>      private static final long serialVersionUID = 1L;
>
>
>
>      public Object getObject() {
>
>        PageParameters pageParameters = getPageParameters();
>
>
>
>        if (pageParameters == null) {
>
>          *return* "null";
>
>        }
>
>
>
>        *return* pageParameters.toString();
>
>      }
>
>    });
>
>
>
>    add(label);
>
>  }
>
> }
>
>
>
> If I replace
>
>
>
> public class Check extends LabeledWebMarkupContainer
>
> {
>
> ...
>
>      protected void onComponentTag(final ComponentTag tag)
>
>      {
>
>            if (group.hasRawInput())
>
>            {
>
>                  final String[] input = group.getInputAsArray();
>
>
>
>                  if (input != null)
>
>                  {
>
>                        for (int i = 0; i < input.length; i++)
>
>                        {
>
>                             if (uuid.equals(input[i]))
>
>                             {
>
>                                   tag.put("checked", "checked");
>
>                             }
>
>                        }
>
>                  }
>
>            }
>
> ...
>
>
>
> by
>
>
>
>    if (group.hasRawInput()) {
>
>      final String input = group.getRawInput();
>
>
>
>      if (input != null) {
>
>        final StringTokenizer st = new StringTokenizer(input, ";");
>
>
>
>        while (st.hasMoreElements()) {
>
>          if (value.equals(st.nextToken())) {
>
>            tag.put("checked", "checked");
>
>          }
>
>        }
>
>      }
>
>    }
>
>
>
> then the check group selection is kept as intended. Am I right to consider
> the selection loss being a bug?
>
>
>
> /Till
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to