[Share] problème avec les fichiers ftl

cancel
Showing results for 
Search instead for 
Did you mean: 
lodacom
Member II

[Share] problème avec les fichiers ftl

Alors voici mon erreur
An error has occured in the Share component: /share/service/components/form.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 02110000 Failed to process template org/alfresco/components/form/form.get.html.ftl
Server: Alfresco Spring WebScripts - v1.0.0 (Release Candidate 2 744) schema 1 000
Time: 11 mars 2011 16:23:07
Click here to view full technical information on the error.
Exception: freemarker.core.InvalidReferenceException - Expression procins is undefined on line 17, column 63 in org/alfresco/components/form/controls/procinstal.ftl.

Je me suis inspiré du fichier mimetype.ftl pour faire ce fichier ci-dessous(procinstal.ftl):
<#if field.control.params.property??>
   <#– use the supplied property to retrieve the mimetype value –>
   <#assign procinstal="">
   <#if contentUrl?? && contentUrl != "">
      <#assign procinsBegIdx=contentUrl?index_of("procinstal=")+9>
      <#assign procinsEndIdx=contentUrl?index_of("|", procinsBegIdx)>
      <#assign procinstal=contentUrl?substring(procinsBegIdx, procinsEndIdx)>
   </#if>
<#else>
   <#assign procinstal=field.value>
</#if>

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <span class="viewmode-label">${msg("form.control.proc-instal.label")}:</span>
        [b] <span class="viewmode-value">${getProcinstalLabel("${procins}")}</span>[/b]
      </div>
   <#else>
      <label for="${fieldHtmlId}">${msg("Domaine")}:</label>
      <#– TODO: Make this control make an AJAX callback to get list of mimetypes OR use dataTypeParamters structure –>
      <select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
              <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
              <#if field.control.params.style??>style="${field.control.params.style}"</#if>>
       <@procinstalOption procins="driver" />
       <@procinstalOption procins="antivirus" />
       <@procinstalOption procins="application" />
       <@procinstalOption procins="imprimante" />
       <@procinstalOption procins="autre" />
   </select>
   </#if>
</div>

<#function getProcinstalLabel procins>
   <#if procins=="driver">
      <#return "Driver">
   <#elseif procins=="antivirus">
   <#return "Antivirus">
   <#elseif procins=="application">
   <#return "Application">
   <#elseif procins=="imprimante">
   <#return "Imprimante">
   <#elseif procins=="autre">
   <#return "Autre">
   <#else>
      <#return msg("form.control.procinstal.unknown")>
   </#if>
</#function>

<#macro procinstalOption procins>
   <option value="${procins}"<#if procinstal==procins> selected="selected"</#if>>${getProcinstalLabel("${procins}")}</option>
</#macro>

et bien sûr dans mon share-config-custom.xml j'appel mon apparence comme ceci:
<field id="doctech:domaine" label="Domaine" label-id="label.doctech_domaine">
            <control template="/org/alfresco/components/form/controls/procinstal.ftl" />
          </field>
PS mon erreur n'apparaît que quand je suis dans la page document-details?nodeRef=workspace://SpacesStore/9f5f32f0-5467-4fe2-bcd3-c3cbd4bd1fe8
Voilà y a-t-il quelqu'un qui sait d'où vient cette erreur? Merci d'avance (l'erreur est entre les balise [b/]
2 Replies
lodacom
Member II

Re: [Share] problème avec les fichiers ftl

Avec ceci:
<#if field.control.params.property??>
   <#– use the supplied property to retrieve the mimetype value –>
   <#assign procinstal="">
   <#if contentUrl?? && contentUrl != "">
      <#assign procinsBegIdx=contentUrl?index_of("procinstal=")+9>
      <#assign procinsEndIdx=contentUrl?index_of("|", cptBegIdx)>
      <#assign procinstal=contentUrl?substring(procinsBegIdx, procinsEndIdx)>
   </#if>
<#else>
   <#assign procinstal=field.value>
</#if>

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <span class="viewmode-label">${msg("form.control.procinstal.label")}:</span>
         <span class="viewmode-value">${getProcinstalLabel("${domaine}")}</span>
      </div>
   <#else>
      <label for="${fieldHtmlId}">${msg("Domaine")}:</label>
      <#– TODO: Make this control make an AJAX callback to get list of mimetypes OR use dataTypeParamters structure –>
      <select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
              <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
              <#if field.control.params.style??>style="${field.control.params.style}"</#if>>
       <@procinstalOption procins="driver" />
       <@procinstalOption procins="antivirus" />
       <@procinstalOption procins="application" />
       <@procinstalOption procins="imprimante" />
       <@procinstalOption procins="autre" />
   </select>
   </#if>
</div>

<#function getProcinstalLabel procins>
   <#if procins=="driver">
      <#return "Driver">
   <#elseif procins=="antivirus">
   <#return "Antivirus">
   <#elseif procins=="application">
   <#return "Application">
   <#elseif procins=="imprimante">
   <#return "Imprimante">
   <#elseif procins=="autre">
   <#return "Autre">
   <#else>
      <#return msg("form.control.procinstal.unknown")>
   </#if>
</#function>

<#macro procinstalOption procins>
   <option value="${procins}"<#if procinstal==procins> selected="selected"</#if>>${getProcinstalLabel("${procins}")}</option>
</#macro>
J'obtiens cette erreur:

An error has occured in the Share component: /share/service/components/form.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 02110003 Failed to process template org/alfresco/components/form/form.get.html.ftl
Server: Alfresco Spring WebScripts - v1.0.0 (Release Candidate 2 744) schema 1 000
Time: 11 mars 2011 16:58:57
Click here to view full technical information on the error.
Exception: freemarker.core.InvalidReferenceException - Expression domaine is undefined on line 17, column 63 in org/alfresco/components/form/controls/procinstal.ftl.
lodacom
Member II

Re: [Share] problème avec les fichiers ftl

Alors ce matin coût de génie!! J'ai trouvé la soluce. Voici le code:
<#if field.control.params.property??>
   <#– use the supplied property to retrieve the mimetype value –>
   <#assign procinstal="">
   <#if contentUrl?? && contentUrl != "">
      <#assign procinsBegIdx=contentUrl?index_of("procinstal=")+9>
      <#assign procinsEndIdx=contentUrl?index_of("|", cptBegIdx)>
      <#assign procinstal=contentUrl?substring(procinsBegIdx, procinsEndIdx)>
   </#if>
<#else>
   <#assign procinstal=field.value>
</#if>

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <span class="viewmode-label">${msg("form.control.procinstal.label")}:</span> <!– première erreur qui était ici –>
         <span class="viewmode-value">${getProcinstalLabel("${procinstal}")}</span> <!– deuxième erreur qui était ici –>
      </div>
   <#else>
      <label for="${fieldHtmlId}">${msg("Domaine")}:</label>
      <#– TODO: Make this control make an AJAX callback to get list of mimetypes OR use dataTypeParamters structure –>
      <select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
              <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
              <#if field.control.params.style??>style="${field.control.params.style}"</#if>>
       <@procinstalOption procins="driver" />
       <@procinstalOption procins="antivirus" />
       <@procinstalOption procins="application" />
       <@procinstalOption procins="imprimante" />
       <@procinstalOption procins="autre" />
   </select>
   </#if>
</div>

<#function getProcinstalLabel procins>
   <#if procins=="driver">
      <#return "Driver">
   <#elseif procins=="antivirus">
   <#return "Antivirus">
   <#elseif procins=="application">
   <#return "Application">
   <#elseif procins=="imprimante">
   <#return "Imprimante">
   <#elseif procins=="autre">
   <#return "Autre">
   <#else>
      <#return msg("form.control.mimetype.unknown")> <!– laisser cette ligne comme cela (voir remarque en bas de post) –>
   </#if>
</#function>

<#macro procinstalOption procins>
   <option value="${procins}"<#if procinstal==procins> selected="selected"</#if>>${getProcinstalLabel("${procins}")}</option>
</#macro>

De plus votre form.control.procinstal.label il faut le référencer dans le fichier form.get_fr.properties en mettant cette ligne:
form.control.procinstal.label=Domaine
Attention si vous n'enregistrez pas la fiche des métadonnées le champ apparaîtra comme Inconnu grâce à la ligne déjà présente dans le mimetype.ftl:
 <#return msg("form.control.mimetype.unknown")>