You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Morten Steffensen <ms...@emercos.com> on 2009/06/07 16:20:00 UTC

nested forms and locale

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


Re: nested forms and locale

Posted by Morten Steffensen <ms...@emercos.com>.
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<ms...@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>   

-- 
Med venlig hilsen / kinds regards,
Morten Steffensen

Emercos ApS
www.emercos.com


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


Re: nested forms and locale

Posted by Igor Vaynberg <ig...@gmail.com>.
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<ms...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: nested forms and locale

Posted by msteff <ms...@emercos.com>.
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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: nested forms and locale

Posted by Igor Vaynberg <ig...@gmail.com>.
like you were told, you have to add the textfield to the ajax target.
also, if you want to repull the value from the model,
textfield.clearinput() might do the trick.

-igor

On Mon, Jun 8, 2009 at 10:44 PM, msteff<ms...@emercos.com> wrote:
>
> Could anybody help on this - please ? Or maybe give me a hint as to where to
> start debugging this. I tried to follow the setLocale() to see what the
> behaviour of wicket is, but i guess i have to start elsewhere..
>
> Thanks for any answer!
>
>
>
> 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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/nested-forms-and-locale-tp23911537p23936648.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: nested forms and locale

Posted by msteff <ms...@emercos.com>.
Could anybody help on this - please ? Or maybe give me a hint as to where to
start debugging this. I tried to follow the setLocale() to see what the
behaviour of wicket is, but i guess i have to start elsewhere..

Thanks for any answer!



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

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


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


Re: nested forms and locale

Posted by Morten Steffensen <ms...@emercos.com>.
Well - when I click one of the links for changing the locale, after i 
hit the "Press me" button, the onClick method gets called, and the 
setLocale gets called. Then i thought that the setLocale would mark the 
session as dirty and in some magic way the models getObject gets called 
on the items of the page.. hmm.



Brill Pappin wrote:
> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

-- 
Med venlig hilsen / kinds regards,
Morten Steffensen

Emercos ApS
www.emercos.com


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


Re: nested forms and locale

Posted by Brill Pappin <br...@pappin.ca>.
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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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