All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.smartgwt.client.docs.DataSourceLocalization Maven / Gradle / Ivy

The newest version!

package com.smartgwt.client.docs;

/**
 * 

DataSource Localization

* * DataSources which are declared in XML (.ds.xml files) and are read by the Smart GWT * server, which are normally loaded * by the DataSourceLoader servlet, can instead be * loaded and interpreted as .jsp files via the technique described below. This allows JSTL * and other JSP tags to be used to internationalize the titles and validation error messages * in XML DataSources. *

* For example, given the following DataSource located in /shared/ds/supplyItem.ds.xml: *

 *  <DataSource>
 *      <fields>
 *          <field name="itemName">
 *              <title>Item Name</title>
 *              <validators>
 *                  <Validator type="lengthRange" max="40">
 *                      <errorMessage>Must be 40 characters or less.</errorMessage>
 *                  </Validator>
 *              </validators>
 *          </field>
 *      </fields>
 *  </DataSource>
 *  
* To localize the title and validator error string of the itemName field * via standard JSTL tags, first add the following to your web.xml to allow DataSource files to * be interpreted as JSPs: *
 *  <jsp-config>
 *      <jsp-property-group>
 *        <url-pattern>/shared/ds/*</url-pattern>
 *      </jsp-property-group>     
 *  </jsp-config>
 *  
* Next change the DataSource definition as follows: *
 *  <!--
 *  <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
 *  -->
 *  <DataSource xmlns:fmt="urn:jsptld:/WEB-INF/fmt.tld">
 *      <fields>
 *          <field name="itemName">
 *              <title><fmt:message key="itemTitle"></title>
 *              <validators>
 *                  <Validator type="lengthRange" max="40">
 *                      <errorMessage><fmt:message key="itemLengthRangeValidator"/></errorMessage>
 *                  </Validator>
 *              </validators>
 *          </field>
 *      </fields>
 *  </DataSource>
 *  
* Note that the XML comment around the taglib declaration is intentional. It is there to make * sure the JSP parser sees the tag library declaration, while the file remains valid XML. * If you need to use multiple JSP tag libraries to achieve your goals, simply add additional * taglib declarations inside the XML comment and be sure to register the tag namespace in the * DataSource tag via xmlns:tagName as done above for the fmt * namespace. * * * Instead of using the DataSourceLoader servlet to load this DataSource, you * should create a JSP that uses SmartGWT Server's XML conversion tag to return Javascript * DataSource definitions to the browser (exactly like DataSourceLoader does): * Using this example as a base, just add a jsp:include line for each of your * DataSources that requires i18n support: *
 *  <%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
 *  <isomorphic:XML>
 *  <jsp:include page="/shared/ds/supplyItem.ds.xml"></jsp:include>
 *  <jsp:include page="/shared/ds/supplyCategory.ds.xml"></jsp:include>
 *  </isomorphic:XML>
 *  
* You then refer to this JSP in a <script src=...> tag, in place of * the DataSourceLoader reference. For example, if you named the file * "dataSourceLoader.jsp": *

* <script src=dataSourceLoader.jsp></script> *

* * This makes it possible to internationalize field titles as well as validation error messages * for built-in validators. To internationalize custom server-side validation errors, simply * provide internationalized strings when calling DSResponse.setErrorReport() to * report validation errors (see the JavaDoc for that documentation). */ public interface DataSourceLocalization { }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy