i may be wrong about this because my wicket ajax is still a bit shaky, but try adding the components you wanted updated to the links target.

- Brill

On 7-Jun-09, at 10:20 AM, Morten Steffensen wrote:

Hi,
I am having problems using nested forms and changing locale.

I have 2 links for changing the locale. It works until i press the AjaxButton in the inner form. Hereafter the txtField's getObject is not called anymore.

What am i doing wrong ? Any suggestions ?



public class ProblemPage extends WebPage {
  private Map<String, String> map = new HashMap<String, String>();

  public ProblemPage() {
      map.put("en", "Hello");
      map.put("da", "Goddag");

      getSession().setLocale(new Locale("en", "EN"));

      add(new Link("enLocale")
      {
          public void onClick() {
              getSession().setLocale(new Locale("en", "EN"));
          }
      });
      add(new Link("daLocale")
      {
          public void onClick() {
              getSession().setLocale(new Locale("da", "DK"));
          }
      });

      Form outerform = new Form("outerform") {
          protected void onSubmit() {
              super.onSubmit();
          }
      };
      add(outerform);

      TextField txtField = new TextField("txtfield",new Model() {
          public Object getObject() {
              return map.get(getSession().getLocale().getLanguage());
          }

          public void setObject(Object o) {
map.put(getSession().getLocale().getLanguage(), (String)o);
          }
      });
      outerform.add(txtField);

      Form innerform = new Form("innerform") {
          protected void onSubmit() {
              super.onSubmit();
          }
      };
      outerform.add(innerform);

      AjaxButton editButton= new AjaxButton("pressmeButton")
      {
          protected void onSubmit(AjaxRequestTarget target, Form form)
          {
              super.onSubmit();
          }
      };
      editButton.add(new SimpleAttributeModifier("value","Press me"));
//        editButton.setDefaultFormProcessing(false);
      innerform.add(editButton);


      outerform.add(new AjaxButton("submitButton") {
          protected void onSubmit(AjaxRequestTarget target, Form form)
          {
              super.onSubmit();
          }
      });
  }
}


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head></head>

<body>

<a wicket:id="enLocale">English</a>
<a wicket:id="daLocale">Danish</a>

<form wicket:id="outerform">
  <input type="text" wicket:id="txtfield"/>

  <form wicket:id="innerform">
      <input type="button" wicket:id="pressmeButton"/>
  </form>

  <input type="button" value="Save" wicket:id="submitButton"/>
</form>

</body>
</html>




--
Kinds regards,
Morten Steffensen



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to