| java.lang.Object de.danet.an.util.web.Mapping
Mapping | public class Mapping (Code) | | Base class, implementing the methods used in logic sheet(s).
The mathods in this class can be used to support an internationalization
of texts and error messages in xsp pages.
Together with the logicsheet mapping.xsl , to use the
functionality the followng steps must be fullfilled:
- Include the logicsheet
mapping.xsl in your own logicsheet
for processing the xsp page.
- In your logicsheet, include the following match-rules:
<xsl:template match="page">
<page>
<xsp:logic>
if (session == null) {
session = request.getSession (true);
}
session.setAttribute ("errorList", new ArrayList (1));
</xsp:logic>
<xsl:apply-templates/>
<xsp:logic>
xspCurrentNode.appendChild
(Mapping.createErrorList(session, document));
</xsp:logic>
</page>
</xsl:template>
<xsl:template match="xsp:page">
<xsp:page>
<xsl:apply-templates select="@*"/>
<xsp:structure>
<xsp:include>
de.danet.an.util.Mapping
</xsp:include>
</xsp:structure>
<xsl:apply-templates/>
</xsp:page>
</xsl:template>
- Define an I18n.properties file for your application.
- In your xsp page, you can now use the mapping functionality, e.g.
<mapping:generate_mappings key="staff.group.list"
basename="de.danet.an.staffmgmt.webclient.I18n"/>
- In your Java classes, where you encapsulate the logic code, you
can set error texts like this:
Mapping.mapError (session, "de.danet.an.staffmgmt.webclient.I18n",
"error.staff.addGroupOption");
|
Method Summary | |
public static void | addError(HttpSession session, String msg) Add an error message to the error list. | public static DocumentFragment | createErrorList(HttpSession session, Document doc) Convert the errors accumulated to an XML structure.
Parameters: session - the http session. Parameters: doc - document, handed over by the cocoon framework. | public static DocumentFragment | generateMappings(HttpSession session, Document doc, String baseName, String segment) Generates mapping entries for a given key . | public static void | mapError(HttpSession session, String baseName, String key) Add the error message referenced by a key to the error list. | public static String | mapText(HttpSession session, String baseName, String key) Returns the i18n text for a given key .
The text is based on the language settings
of the user. |
addError | public static void addError(HttpSession session, String msg)(Code) | | Add an error message to the error list.
Parameters: session - the http session. Parameters: msg - the error message. |
createErrorList | public static DocumentFragment createErrorList(HttpSession session, Document doc)(Code) | | Convert the errors accumulated to an XML structure.
Parameters: session - the http session. Parameters: doc - document, handed over by the cocoon framework. Document fragment with error list. |
generateMappings | public static DocumentFragment generateMappings(HttpSession session, Document doc, String baseName, String segment)(Code) | | Generates mapping entries for a given key .
The mapping entries are taken from a language specific resource file.
The given segment name is removed from the resulting keys.
Parameters: session - the http session Parameters: doc - document, handed over by the cocoon framework Parameters: baseName - file name of resource bundle Parameters: segment - prefix for selecting the resource segment Document fragment with mapping nodes |
mapError | public static void mapError(HttpSession session, String baseName, String key)(Code) | | Add the error message referenced by a key to the error list.
Parameters: session - the http session. Parameters: baseName - Family name of the resource bundle Parameters: key - the key of the error message. |
mapText | public static String mapText(HttpSession session, String baseName, String key)(Code) | | Returns the i18n text for a given key .
The text is based on the language settings
of the user.
Parameters: session - currently not used. May be used to get informationabout the user's locale. Parameters: baseName - Family name of the resource bundle Parameters: key - key for the text translated key, representing the language specific translation |
|
|