Hello Devs, 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? 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? 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? I picked this up from accessdenied.vm ... Thanks for all help Thanks
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.
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
Guillaume, You said that $msg.get("translation") would render a message. But, how do I know what are the otehr strings (like "translation") that I can use to render appropriate messages. Is there a lsit of these somewhere in the code or on xwiki.org? Thanks On Wed, Apr 16, 2008 at 1:28 PM, Kamna Jain <[email protected]> wrote:
Hello Devs,
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?
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?
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?
I picked this up from accessdenied.vm ...
Thanks for all help
Thanks
Hi Jain, (hope this is your first name :) ) $msg is a instance of xwiki messaging tool. (swiki-core\src\main\java\com\xpn\xwiki\web\XWikiMessageTool.java) it is mostly used to get translations for a certain translation key. translations are kept in bundles in specific documents like this: translationkey1=My english version of this translation_key_2=My text here You can add a document as translation document by going in xwiki administration /bin/admin/XWiki/XWikiPreferences > Preferences > Advanced section > Internationalization Document Bundles and adding the fullnames of the documents that want to act as translation pages. Like: MySpace.Translations After you add your document here, you can do wherever you want $msg.get("translation_key_2") or more simple ${msg.translation_key_2} and you text will render. To add another language just translate your translation document in the desired language (use the "Translate this document into" link).
Guillaume,
You said that $msg.get("translation") would render a message. But, how do I know what are the otehr strings (like "translation") that I can use to render appropriate messages. Is there a lsit of these somewhere in the code or on xwiki.org?
Thanks
On Wed, Apr 16, 2008 at 1:28 PM, Kamna Jain <[email protected]> wrote:
Hello Devs,
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?
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?
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?
I picked this up from accessdenied.vm ...
Thanks for all help
Thanks
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
[email protected] wrote:
Hi Jain, (hope this is your first name :) )
$msg is a instance of xwiki messaging tool. (swiki-core\src\main\java\com\xpn\xwiki\web\XWikiMessageTool.java)
it is mostly used to get translations for a certain translation key. translations are kept in bundles in specific documents like this:
translationkey1=My english version of this translation_key_2=My text here
You can add a document as translation document by going in xwiki administration /bin/admin/XWiki/XWikiPreferences > Preferences > Advanced section > Internationalization Document Bundles and adding the fullnames of the documents that want to act as translation pages. Like: MySpace.Translations
But the main resource files are located in xwiki-core/src/main/resources/ApplicationResources*.properties (in the source) and in xwiki-core-*.jar#ApplicationResources*.properties (the target jar).
After you add your document here, you can do wherever you want $msg.get("translation_key_2") or more simple ${msg.translation_key_2} and you text will render. To add another language just translate your translation document in the desired language (use the "Translate this document into" link).
Guillaume,
You said that $msg.get("translation") would render a message. But, how do I know what are the otehr strings (like "translation") that I can use to render appropriate messages. Is there a lsit of these somewhere in the code or on xwiki.org?
Thanks
Sergiu Dumitriu wrote:
But the main resource files are located in xwiki-core/src/main/resources/ApplicationResources*.properties (in the source) and in xwiki-core-*.jar#ApplicationResources*.properties (the target jar).
And here it is a, I think, logical question: how could we know and keep track of the strings included (or that must be included in the main resources files? I mean, I don't know what is first: the code, or the main resources files; and how the development of both things related. Thanks! Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
participants (5)
-
[Ricardo Rodriguez] Your EPEC Network ICT Team -
cristian.vrabie@xwiki.com -
Guillaume Lerouge -
Kamna Jain -
Sergiu Dumitriu