Message: 8
Date: Wed, 16 Apr 2008 23:27:57 +0200
From: "Guillaume Lerouge" <guillaume(a)xwiki.com>
Subject: Re: [xwiki-devs] What is $msg ?
To: "XWiki Developers" <devs(a)xwiki.org>
Message-ID:
<1c35d2320804161427n3f69229bs6d2bb425d00e13c1(a)mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi Kamna,
In the past few days, I have been looking a lot at the Velocity templates
and the Xwiki core code.
There are a few things I am not able to understand.
1) Where is $msg variable defined in the core code? I see it a lot in
the
scripts. Is it a hashtable for messages. Where is
it defined?
$msg is the code used to get translation messages. Basically when you
write
$msg.translation or $msg.get("translation"), upon parsing of the page by
the
Velovity parser the engine looks into the translations file. if it finds
something such as translation=NiceTranslation, it turns $msg.translation
into NiceTranslation when rendering the page.
2) what is referred to by "xpage","xredirect"
For eg. in the following mehtod from Utils.java
public static String getPage(XWikiRequest request, String defaultpage)
{
String page;
page = request.getParameter("xpage");
if ((page == null) || (page.equals(""))) {
page = defaultpage;
}
return page;
}
does this mean, that if a page with that name exists in the template
directory(xpage), it will be returned. But, what is defaultpage?
They are used to return specific actions when ?xpage= is appended to a
page
URL . For instance, /xwiki/bin/view/Main/WebHome?xpage=plain will render
the
content witout any style, /xwiki/bin/view/Main/WebHome?xpage=print will
render the page in print mode...
Similarly, ?xredirect takes another url as a parameter and sends the
viewer
to the given page. When you try to access a page you cannot see, it's the
action used to send you back to the page from the login page.
if xpage = "mypage" then it would pass the control (request) to a vm
template file mypage.vm and the rendering or response of the request would
be as defined in mypage.vm
Currently the login page does not show any error
if the provided
credentials
are wrong. (authentication with LDAP)
A look at the LoginErrorAction.java in the Web package revealed that it
returns the same string as the LoginAction - "login"
so, if I created anither loginerror.vm in teh templates folder and
returned
"loginerror" in the render function of this LoginErrorAction.java class,
it
would run the new script.
But, at this stage I do not know what would be the content of the
loginerror.vm....
#xwikimessageboxstart($msg.get("error") $msg.get("notallowed")) -
would
this work?
Not quite sure... Though trial & error sounds like a nice tactic ;-)
Guillaume