cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker: Problem accessing to HTML input values

santigt
Champ in-the-making
Champ in-the-making
Hi all!

In Freemarker, how can I access to HTML input values? I put an example: I have this HTML code:

<input type='text' maxlength='1024' size='32' name='searchinst' id='searchinst'/>
<span class="taskAction" onClick="javascript:includeContent();">Búsqueda</span>
<select style='width:240px;' name='inst_derivated' id='inst_derivated' size='4' multiple>
</select></td>

The "includeContent" method execute a search (using the "searchinst" input value) and put the results as select "inst_derivated" options. So, the code is something like this:

alert($('searchinst').value);
<#assign buscar="TEXT:\"" + $('searchinst').value + "\"">
<#assign docs=companyhome.nodeByReference[home].childrenByLuceneSearch["$"]?sort_by('name')>
   var i=0;
   <#list docs as d>
      $('inst_derivated').options[i].text = "${d.name}";
      $('inst_derivated').options[i].value = "${d.nodeRef}";
      i++;
   </#list>

The alert runs correctly, but there is an syntax error in this code: Expression $ is undefined

How can I access to this value?? Thanks so much!

Regards,


Santigt
14 REPLIES 14

mikeh
Star Contributor
Star Contributor
I'm not using web script i'm using "raw" ftl (apply template on document/space details)….
Ok, but could you post the relevant parts here please? It makes it much easier to find out what the problem is…

Thanks,
Mike

mliwski
Champ in-the-making
Champ in-the-making
The name of the ftl is
testForm.ftl and its aplied to a document
<form method="post" action="">
   <input type="text" maxlength="1024" size="32" name="inst_derivated" id="inst_derivated" />
   <input type="submit" />
</form>

args["inst_derivated"] = ${args["inst_derivated"]}

im using alfresco 2.1

mikeh
Star Contributor
Star Contributor
Hi,

The args Map object is only supplied when the template is served via the TemplateContentServlet, i.e. the /alfresco/template URI stem.

For example:
http://localhost:8080/alfresco/template/workspace/SpacesStore/e3741425-35cf-11dc-9762-4b73d0280543

To cater for this, your template should look something like the following:
<#– Check existence of args Map object –>
<#if args?exists>
   <#– Check existence of our request variable –>
   <#if args["inst_derivated"]?exists>
      You submitted: ${args["inst_derivated"]}
   <#else>
      <form method="post" action="">
         <input type="text" maxlength="1024" size="32" name="inst_derivated" />
         <input type="submit" />
      </form>
   </#if>
<#else>
   Template not served by TemplateContentServlet!
</#if>

Does this help?
Mike

mliwski
Champ in-the-making
Champ in-the-making
Ok, so the template doesn't supply this servlet right?
Have you idea what files i should modify to get it work with "apply template"?

i certainly doesn't test outside templates apply (in this case, i used freemarker files, included in the jsp, to present information in the details-document)…

Thanks for your time, i hope that this can help us all…

Matías.

thaiyal
Champ in-the-making
Champ in-the-making
I too have a similar requirement, I am interested in knowing the solution too…

Thanks,
Thaiyal