To begin with... I am learning Tapestry from 1 month ago.
I am having problems with the Locale changing support in my application. To see
the thing working, I hardcoded the language changing in the application (pt-BR
and en support). Here's the code:
Page Template Code (only the necessary for the explanation)
<t:if test="localePortugueseBrazil">
<img src="${flagPortugueseBrazil}" style="margin: 3px;" />
<p:else>
<t:actionLink t:id="changeLocalePtBr" value="pt-BR">
<img src="${flagPortugueseBrazil}"
title="${message:txt.change_locale.pt-BR}" style="margin: 3px;" />
</t:actionLink>
</p:else>
</t:if>
<t:if test="localeEnglishUSA">
<img src="${flagEnglishUSA}" style="margin: 3px;" />
<p:else>
<t:actionLink t:id="changeLocaleEnUs" value="en-US" >
<img src="${flagEnglishUSA}"
title="${message:txt.change_locale.en-US}" style="margin: 3px;" />
</t:actionLink>
</p:else>
</t:if>
Page Class Code (there are actually the same localized methods/properties for
the other language)
@Inject
private PersistentLocale persistentLocale;
@Inject
private Locale currentLocale;
@Inject
@Property
@Path("context:/layout/images/brazil.png")
private Asset flagBrazil;
@Inject
@Property
@Path("context:/layout/images/brazil_disabled.png")
private Asset flagBrazilDisabled;
public Asset getFlagPortugueseBrazil(){
if (!currentLocale.equals(new Locale("pt","BR"))){
return flagBrazil;
}else{
return flagBrazilDisabled;
}
}
public boolean isLocalePortugueseBrazil(){
if (currentLocale.equals(new Locale("pt","BR"))){
return true;
}else{
return false;
}
}
@OnEvent(component="changeLocalePtBr")
void changeLocalePtBr()
{
persistentLocale.set(new Locale("pt","BR"));
}
-----------
OK, it works perfectly... But now I want to turn this into a dynamic/extensible
way... So, when adding a new Language Support, I only have to add it on the
AppModule class (the SymbolConstants.SUPPORTED_LOCALES info), put the 2 images
related to the language/country in the images folder (one image with colors and
the other in black-white) and the text for ToolTip when the mouse is over the
image.
So... The first thing I'm having problems with is to retrieve in Runtime the
information stored on the AppModule class (contributeApplicationDefaults
method). There is a way I can do this? If there isn't, is it good for me to
have a config.properties file in the application so I can add the Supported
Locales info there, and then retrieve it in the AppModule class to store in the
contributeApplicationDefaults method?
The second problem I'm having is to retrieve the Assets (the images) in a
Dynamic way (knowing the Locale name and if it's the enabled/disabled image)...
I've read about AssetFactory, but didn't find any good example related.
I appreciate any help. :)
Everton Agner
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com