I am working in Alfresco and I make one out of my own custom component (for a form) Want to In my case "number.ftl".
I want to set the default value, so that if the field.value
is empty then the default value will be used
Default-number.flt
& lt; # Fil.control.params.defaultValue ?? & Amp; & Amp; !? Field.value has_content & gt; & Lt; #sign field.value = area.control.params.defaultValue & gt; & Lt; / # If & gt; & Lt; #include "/org/alfresco/components/form/controls/number.ftl" /> It complains about dot (.) In field.value
:
Reason: freemarker.core ParseException: The parsing error in the template "org / alfresco / components / form / controls / year.ftl" in line 3, column 23: "", but one of the "" = "" was expected: ""> "
How do I set a variable?
UPDATE
I have suggested by Abrison (but I can not " Number.ftl "set the variable after import or old value will be used):
< In the & lt; # fil.control.params.curretYearDefaultValue ?? & Amp; & amp;!! Field.value has_content & gt; field & lt; # assigned value & gt; $ {now? String ( "Yy")} gt; & lt; / # If & gt; & lt; #include "/org/alfresco/components/form/controls/number.ftl" />
But I get:
Free marker template error: "#Sign" for namespace: A namespace was expected, but this extended_ship + string Org) .alfresco.web.scripts.forms.FormUIGet $ field is wrapped in febStringModel): ==> field [template "or G / alfresco / components / form / controls / year.ftl "at row 3, column 27]
UPDATE2 (sorted)
That ddekany has suggested a working solution
& lt; #if field control.params.useCurretYearAsDefaultValue ?? & Amp; & Amp; Field.control.params.useCurretYearAsDefaultValue = "true" & amp; Amp; !? Field.value has_content & gt; $ {Field.setValue (.now? String ("yyyy"))!} & Lt; / # If & gt; & Lt; #include "/org/alfresco/components/form/controls/number.ftl" />
Freemer templates do not support data-model modification. They are meant to read only those things that were already prepared by Java code. You can only set top-level variables because they are not part of the data-model (they are in the area in front of the top-level data model model). And so there is no syntax for the freer maker to modify a subviable. But, there may be a back door present for whatever you want. On configuration settings and what is the
field
is Java-level, works on $ {field.setValue (...)} . To do this, quite a lot to remember, you should remember to add form content to a template that smells, you should call some Java helpful methods at least.
No comments:
Post a Comment