AnsweredAssumed Answered

Dynamic changing of Web Form labels

Question asked by dynamolalit on Aug 29, 2009
Latest reply on Aug 29, 2009 by dynamolalit
Hi,

I have a requirement that states when user changes the language selection in alfresco say from English to German,the xsd using which he is generating the content ,that xsd labels should be changed from English to translated German labels automatically  when user selects to create the content.
For this,i have written a java class which will load property file as per language selection whose snippet is as

public void setLabels(String langPassed) {
      LabelPropertyReader.setLabelPropertyFile(langPassed);
      DynamicXSDGenerator generator = new DynamicXSDGenerator();
      generator.getLanguageLabel();      
      generator.getLevel1Label();
      generator.getLevel2Label();
      generator.getLevel3Label();
      generator.getLevel4Label();
      generator.getHeadingLabel();
      generator.getTaxonomyLabel();
      generator.getBodyLabel();
      generator.getRelatedInfoLabel();
      generator.getLinkNameLabel();
      generator.getLinkUrlLabel();
      generator.getLinkDescLabel();
      generator.getLinkOwnerLabel();
      generator.getLinkOwnerEmailLabel();
      generator.getLinkExpDateLabel();
      generator.getContentExpDateLabel();
   }

where LabelPropertyReader class is another class whcih loads the file actually.

Now,i have created a tld for exposing java methods to xml as :


<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
        version="2.0">

    <tlib-version>1.0</tlib-version>
    <short-name>ejustxsd</short-name>
    <uri>http://www.alfresco.org/alfresco/ejustxsd</uri>
     <function>
      <name>getLanguageLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLanguageLabel()</function-signature>
    </function>
    <function>
      <name>getLevel1Label</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLevel1Label()</function-signature>
    </function>
    <function>
      <name>getLevel2Label</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLevel2Label()</function-signature>
    </function>
    <function>
      <name>getLevel3Label</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLevel3Label()</function-signature>
    </function>
    <function>
      <name>getLevel4Label</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLevel4Label()</function-signature>
    </function>
    <function>
      <name>getHeadingLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getHeadingLabel()</function-signature>
    </function>
    <function>
      <name>getTaxonomyLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getTaxonomyLabel()</function-signature>
    </function>
    <function>
      <name>getBodyLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getBodyLabel()</function-signature>
    </function>
    <function>
      <name>getRelatedInfoLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getRelatedInfoLabel()</function-signature>
    </function>
    <function>
      <name>getLinkNameLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkNameLabel()</function-signature>
    </function>
    <function>
      <name>getLinkUrlLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkUrlLabel()</function-signature>
    </function>
    <function>
      <name>getLinkDescLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkDescLabel()</function-signature>
    </function>
    <function>
      <name>getLinkOwnerLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkOwnerLabel()</function-signature>
    </function>
    <function>
      <name>getLinkOwnerEmailLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkOwnerEmailLabel()</function-signature>
    </function>
    <function>
      <name>getLinkExpDateLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getLinkExpDateLabel()</function-signature>
    </function>
    <function>
      <name>getContentExpDateLabel</name>
      <function-class>org.alfresco.ext.DynamicXSDGenerator</function-class>
      <function-signature>java.lang.String getContentExpDateLabel()</function-signature>
    </function>   
</taglib>

Also, i have used this tld in my xsd as below:


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:eJustice_Small_Claims="http://www.alfresco.org/alfresco/eJustice_Small_Claims,http://www.alfresco.org/alfresco/ejustxsd"
   targetNamespace="http://www.alfresco.org/alfresco/eJustice_Small_Claims,http://www.alfresco.org/alfresco/ejustxsd"
   xmlns:alf="http://www.alfresco.org"   
   elementFormDefault="qualified">

<xs:element name="eJustice_Small_Claims">
      <xs:annotation>
         <xs:documentation source="ospi.label">eJustice_Small_Claims_Title</xs:documentation>
         <xs:documentation source="ospi.description">eJustice_Small_Claims_Desc</xs:documentation>
      </xs:annotation>
      <xs:complexType>
         <xs:sequence>
         <xs:element name="eJustice_language" type="eJustice_Small_Claims:LanguageSelect"
                default="English">
               <xs:annotation>
                   <xs:appinfo>
                     <alf:label>${ejustxsd:getLanguageLabel}</alf:label>
                     <alf:appearance>compact</alf:appearance>
                    </xs:appinfo>
               </xs:annotation>
         </xs:element>      
…..
</xs:schema>
      

Here i want to update the name or <alf:label> tag to show appropriate label.

Also i have placed this tld file in WEB-INF directory of alfresco war & declared entry for this in ../WEB-INF/web.xml as

 
<taglib>
    <taglib-uri>http://www.alfresco.org/alfresco/ejustxsd</taglib-uri>
    <taglib-location>/WEB-INF/ejsutxsd.tld</taglib-location>
</taglib>

But i am getting this on my Web Client

$$ejustxsd:getLanguageLabel$$

What i can understand form this is that alfresco is not able to parse the "ejustxsd:getLanguageLabel".Its taking this as static only.

Can anyone help me on this.

Outcomes