Hi, It seems that I introduced a bug a while ago, but this is because the MessageTool is created in the wrong places. Now, to explain a bit how to find more information about $msg. If you don't know what variable is, you can write $msg.class to find out what kind of object is that. In this case, you find out it is a com.xpn.xwiki.web.XWikiMessageTool instance. Next, you open your favorite IDE (let's say Eclipse) and navigate to that class. You want to know where is that object placed in the context, so you can right click the class name, or the java file in the tree browser, and select References->Project. The first result is exactly XWiki.getMessage, which I told you to try. Since it is not in the API, you can look if there is an equivalent method in the api.XWiki class, which you can call from velocity. Another search result is XWiki.prepareResources. Looking at this method, you see that this is the place where the $msg variable is placed in the context: XWikiMessageTool msg = new XWikiMessageTool(bundle, context); context.put("msg", msg); If your script does not have $msg, then it means that this method is not called, or an error occurred before putting the MessageTool in the context. So let's see where is this method called. You right click the prepareResources method and search for References->Project, and so you see that it is called either in XWiki.prepareDocuments, or in XWikiightServiceImpl#checkAccess. in XWiki.prepareDocuments it is only created for a registration request, so this leaves the checkAccess as the only place where prepareResources is called. After looking inside checkAccess, I see that all the code branches have a prepareResources call, so the problem is that checkAccess is not called in some places. Searching for the references to XWikiRightService#checkAccess (the interface method, not the implementation one), we see that the only relevant place where it is called is XWiki#checkAccess, and opening this method we see: if (action.equals("skin") && doc.getSpace().equals("skins")) return true; return getRightService().checkAccess(action, doc, context); So the problem is that for the /skin/ action, we skip the checkAccess method, thus we don't create the MessageTool. I'll fix this problem right away, so you should svn update in a few minutes. On 6/28/07, [email protected] <[email protected]> wrote:
Hello all,
What is $msg variable, and where can I read more about it? (is not in xwikivars.vm...) And how does $msg.get() works?
Please, I really need some help. I want to include support for languages in my datepicker and Sergiu told me to put the strings in ApplicationRessources.properties and now I'm trying to get them in a js file with $msg.get("core.datepicker.somethingdefinedbymehere"), but it seems that the server does not know how $msg is, but it knows who $xwiki, $context and all other are....
So please, please, I would like to know more about this variable or how to get the strings from ApplicatonRessources.
I'd really appreciate some help because I'm stuck on this....
Thank you very much,
Evelina
Sergiu -- http://purl.org/net/sergiu