Hello Igor,

Thanks for your answers! I have made a jira issue: WICKET-2320

But... maybe this is not a bug, but rather a feature. I would just like to know how to deal with it then.

Kind regards,
Morten Steffensen

Igor Vaynberg wrote:
why dont you reproduce this in a quickstart and attach it to a jira
issue. on the quickstart page clearly outline what the problem is and
what are the steps necessary to reproduce it. it will be much easier
then discussing random snippets of code here and there.

-igor

On Tue, Jun 9, 2009 at 2:41 AM, msteff<mst...@emercos.com> wrote:
Hello Igor,

Thanks for your answer. I added the txtField to the target argument of the
onSubmit of the Pressme button. It didn't help. Also seems a bit strange to
me to add the fields of the outer form to the button of the inner form..
However, if i submit the outer form, then changing the locale will
indirectly call the model getObject on the txtField again. It seems that
submitting the inner form changes the state of the outer form so that
changing the locale has no effect on its elements before the outer form is
also submittet.

I really appreciate any help here..

Kind regards,
Morten



The attached example is just for illustration. In the real application, the
inner form is a component holding a list, where items can be added. Like the
outer form holds the attributes of a person, and the inner form is a list of
his favorit colours or what ever..

------- Added code with txtField added to the target ----
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"));

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

       Form outerform = new Form("outerform");
       add(outerform);

       final 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);
       txtField.setOutputMarkupId(true);

       Form innerform = new Form("innerform");
       outerform.add(innerform);

       AjaxButton editButton= new AjaxButton("pressmeButton")
       {
           protected void onSubmit(AjaxRequestTarget target, Form form)
           {
               super.onSubmit();
               target.addComponent(txtField);
           }
       };
       innerform.add(editButton);


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




msteff 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>

 English
 Danish

<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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



--
View this message in context: 
http://www.nabble.com/nested-forms-and-locale-tp23911537p23939601.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



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



--
Med venlig hilsen / kinds regards,
Morten Steffensen

Emercos ApS
www.emercos.com


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

Reply via email to