I've started a page :
http://wiki.apache.org/tapestry/ChangeLocale
Comments and changes are welcome.
cyrille
Ulrich Stärk a écrit :
If localeItem is the value of your for component, you can put all this
into your page class and thus simplify your template. The for
component will take care, that getLocaleItem() in your page class will
return the actual LocaleItem.
getComputeUrl() could be
public String getComputeUrl() {
String locale = getLocaleItem().getLanguage();
return getContextPath() + "/Public/flags/" + locale + ".gif";
}
and then simplify your expression to ognl:computeUrl. It's a question
of style but I find it more readable that way.
Uli
#Cyrille37# schrieb:
Ulrich Stärk a écrit :
Well, rename computeUrl() to getYouNameIt() and access it using
ognl:youNameIt from your template or page specification.
I compute the url in the html in a for loop.
So the stuff I miss is how to access "infrastructure:contextPath"
from ognl.
I did this
ognl:page.engine.infrastructure.contextPath+'/Public/flags/'+localeItem.language+'.gif'
and it's working ! Great.
cyrille
Uli
#Cyrille37# schrieb:
Ulrich Stärk a écrit :
Let Tapestry inject the infrastructure:contextPath object like
@InjectObject("infrastructure:contextPath")
public abstract String getContextPath();
Then write some computeUrl method similar to this one (just typed
this in,
no guarantee that this will work).
public String computeUrl() {
String locale = getLocale().getCountry().toLowerCase();
return getContextPath() + "/Public/flags/" + locale + ".gif";
}
Thank you Ulrich,
This is the Java way, what is the Ognl way ? To use in Html and/or
Jwc files.
Cyrille
Cheers,
Uli
On Mi, 22.08.2007, 01:53, #Cyrille37# sagte:
Hello,
I could not find how to compute a url ...
It is for a component which give the user the possibility to
change his
locale by clicking on a image (country flags).
Urls should be like : /theApp/Public/flags/fr.gif
There is 2 dynamics parts :
* the application context : /theApp
* the available locale code : fr
like : <context>/Public/flags/<localeCode>.gif
I thought about <asset name="xxx" path="context:xxxx" /> but it
is not
possible because path attribute started by "context:" could not
use ognl
expression.
Also thought about <img jwcid="@Any" src="ognl: page.context +
'/xxx/' +
currentLoopItem + '.gif' " /> but "page.context" does not exists.
I really could not find how to compute the <context> part of urls.
Have you got any idea please ?
Thanks
cyrille
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]