You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thierry Peng <pe...@glue.ch> on 2010/08/13 12:19:46 UTC

getPage() Question

Hi

I have a Singlepage Application where I swap some panels on the main 
page depending what the user does. Specifically I have a Panel for 
changing the password which looks like:


@SuppressWarnings("serial")
public class ChangePasswordPanel extends Panel
{
  @Inject
  private ChangePasswordAction action;

  @Inject
  private AmtUserHome home;

 

  @SuppressWarnings("unchecked")
  public ChangePasswordPanel(String id)
  {
    super(id);
    this.setOutputMarkupId(true);

.. some fields added here

    Button change = new Button("change", new ResourceModel("middle.changepw.change"))
    {
      @Override
      public void onSubmit()
      {
        getPage().addOrReplace(new ChangePasswordSuccessPanel("middle"));
        action.saveChanges(); 
        super.onSubmit();
      }
    };
    ..some code
    Button cancel = new Button("cancel", new ResourceModel("middle.changepw.cancel"))
    {
      @Override
      public void onSubmit()
      {
        
        getPage().addOrReplace(new ChangePasswordPanel("middle"));
        getPage().addOrReplace(new ChangePasswordInformationPanel("right"));
        super.onSubmit();
      }

      @Override
      public boolean isVisible()
      {
        PostfachModel model = session.getModel();
        return !model.isNeedsPasswordChange();
      }
    };

    cancel.setDefaultFormProcessing(false);
    
.. some more code

    add(form);
    
    container.add(oldPassword);
    form.add(cancel, change, text, password, passwordrepeat, container);

  }
}


However, I'm encountering the following exception:

java.lang.IllegalStateException: No Page found for component [MarkupContainer [Component id = cancel]]
     at org.apache.wicket.Component.getPage(Component.java:1756)
     at ch.admin.bj.ba.postfach.ui.panels.ChangePasswordPanel$5.onSubmit(ChangePasswordPanel.java:102)
     at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:882)

But only when I click the cancel button (102 points to "

getPage().addOrReplace(new ChangePasswordInformationPanel("right"));

"). The submit(change) button works fine and I'm using in both 
onsubmit() almost the identical code. Is there any explanation for this 
behaviour? The buttons in the html are identical:

	<input type="submit" class="button" wicket:id="change"/>
	<input type="submit" class="button" wicket:id="cancel"/>

Wicket version is 1.4.9 on a glassfish 3

Thanks in advance

thierry



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: getPage() Question

Posted by Thierry Peng <pe...@glue.ch>.
I figured it out.

For who is interested:

The first getPage().addOrReplace replaced the middlepanel which was also 
the current changepasswordpanel.
The second call on getParent() can only yield null because the panel in 
question was already swapped.

So there are two valid solutions:

first use the var-arg:

getPage().addOrReplace( new MiddleInfoPanel("middle"),new 
LoginPanel("right"));

second, swap first the right panel, then the middle panel

getPage().addOrReplace(new LoginPanel("right"));
getPage().addOrReplace(new MiddleInfoPanel("middle"));



both solutions works and my faith in wicket is saved

silly me

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org