You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mike Mander <wi...@gmx.de> on 2011/01/18 09:47:11 UTC

How can i change lang attribute in html markup tag?

Hello,

i'm new to wicket and the mailing list. I already checked the search 
machines but didn't found anything.

i have to migrate a jsp. In the jsp there is a html tag like this:
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" 
lang="${prefLang}" xml:lang="${prefLang}">

The ${prefLang} was an attribute from the session scope. I already saw that 
wicket provides a language in session to.

Now my question: What is the wicket way for accessing the session locale and 
provide it in the markup (for lang attribute)?

Thanks for helping me.
Mike 


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


Re: How can i change lang attribute in html markup tag?

Posted by Mike Mander <wi...@gmx.de>.
Great Martin. Thanks alot it works as expected.

My solution:
LocalizedHtmlTag.java
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;

public class LocalizedHtmlTag extends WebMarkupContainer {

     public LocalizedHtmlTag(String id) {
         super(id);
         String language = getSession().getLocale().getLanguage();
         add(new SimpleAttributeModifier("lang", language));
         add(new SimpleAttributeModifier("xml:lang", language));
     }

     @Override
     public boolean isTransparentResolver() {
         return true;
     }
}

MyPage.java
public class MyPage extends WebPage {

     public MyPage() {
         add(new LocalizedHtmlTag("html"));
     }
}

MyPage.html
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html wicket:id="html" xmlns="http://www.w3.org/1999/xhtml" 
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
</html>

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


Re: How can i change lang attribute in html markup tag?

Posted by Martin Grigorov <mg...@apache.org>.
Yes, sorry.
You need to override
#isTransparentResolver()

WebMarkupContainer htmlTag = new WebMarkupContainer("html") {
        public boolean isTransparentResolver()
{
return true;
}
};

On Fri, Jan 21, 2011 at 12:25 PM, Mike Mander <wi...@gmx.de> wrote:

> Am 21.01.2011 09:17, schrieb Martin Grigorov:
>
>  Try with :
>>
>> in .html:
>> <html wicket:id="html">
>> ....
>>
>> in .java:
>> WebMarkupContainer htmlTag = new WebMarkupContainer("html");
>> htmlTag.add(new SimpleAttributeModifier("lang",
>> getSession().getLocale().toString());
>> htmlTag.setTransparentResolver(true); // check the javadoc of this method
>>
>> On Fri, Jan 21, 2011 at 8:19 AM, Mike Mander<wi...@gmx.de>  wrote:
>>
>>  Thanks Martin for your reply.
>
> But i couldn't find
>
> WebMarkupContainer.setTransparentResolver
>
> There is only a Border.setTransparentResolver in wicket 1.4.15
>
>
> Thanks
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How can i change lang attribute in html markup tag?

Posted by Mike Mander <wi...@gmx.de>.
Am 21.01.2011 09:17, schrieb Martin Grigorov:
> Try with :
>
> in .html:
> <html wicket:id="html">
> ....
>
> in .java:
> WebMarkupContainer htmlTag = new WebMarkupContainer("html");
> htmlTag.add(new SimpleAttributeModifier("lang",
> getSession().getLocale().toString());
> htmlTag.setTransparentResolver(true); // check the javadoc of this method
>
> On Fri, Jan 21, 2011 at 8:19 AM, Mike Mander<wi...@gmx.de>  wrote:
>
Thanks Martin for your reply.

But i couldn't find

WebMarkupContainer.setTransparentResolver

There is only a Border.setTransparentResolver in wicket 1.4.15

Thanks
Mike

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


Re: How can i change lang attribute in html markup tag?

Posted by Martin Grigorov <mg...@apache.org>.
Try with :

in .html:
<html wicket:id="html">
....

in .java:
WebMarkupContainer htmlTag = new WebMarkupContainer("html");
htmlTag.add(new SimpleAttributeModifier("lang",
getSession().getLocale().toString());
htmlTag.setTransparentResolver(true); // check the javadoc of this method

On Fri, Jan 21, 2011 at 8:19 AM, Mike Mander <wi...@gmx.de> wrote:

> With further investigation i found a hint on using an IMarkupFilter.
>
> Is there an example with this for my problem?
>
> Thanks
>
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How can i change lang attribute in html markup tag?

Posted by Mike Mander <wi...@gmx.de>.
With further investigation i found a hint on using an IMarkupFilter.

Is there an example with this for my problem?

Thanks
Mike

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