如何将Control-Parm中的工作流属性传递给Alfresco中的FTL文件? [英] How to Pass Workflow Propert in Control-Parm to FTL File in Alfresco?

查看:128
本文介绍了如何将Control-Parm中的工作流属性传递给Alfresco中的FTL文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,对于我的项目,我们在Alfresco存储库中通常会有一些JavaScript代码运行。因此,无论何时新文档进入某个空间,都会动态创建一个新文件夹,并将该文档移入新创建的空间。此外,无论何时创建新文件夹,都会像更新文档一样更新属性(期望caseID实际上是基于数据库中序列的动态生成值):

  //将caseID添加为文件夹的属性
var props = new Array(1);
道具[wf:caseIDNum] = caseID;
var newAspect = newNewSpaceName.addAspect(wf:caseID,props);

但是,现在我们希望能够在我们的过程中引用新创建的方面/属性工作流在我们的share-workflow-form-config-.xml文件中,以便它可以作为参数传递给我们的控制模板。也就是说,目前我们有:

 < field id =wf:submitCodelabel-id =workflow.field。结果set =actions> 
< control template =/ org / alfresco / components / form / controls / workflow / custom-activiti-transitions.ftl/>
< / field>

但是我们想要的东西如下所示:

 < field id =wf:submitCodelabel-id =workflow.field.outcomeset =actions> 
< control template =/ org / alfresco / components / form / controls / workflow / custom-activiti-transitions.ftl>
< control-param name =caseID> wf:caseIDNum< / control-param>
< / control>
< / field>

所以我的问题是,将工作流模型中的变量/属性传递给FTL文件通过控制参数?



编辑(10/25/12) -



所以基于这里给出的帮助,我试图修改我的ftl页面,就像这样...

custom-activiti-transitions.ftl

 < #assign caseID => 
< #if field.control.params.caseID ??>
< #assign caseID = field.control.params.caseID>
<#else>
< #assign caseID = null>
< /#if>

< style type =text / css>

.button {
border:1px solid#666;
背景:#DCDCDC;
padding:5px;
颜色:#333;
text-shadow:1px 1px #fff;
-moz-border-radius:5px;
-webkit-border-radius:5px
border-radius:5px;
光标:指针;
-moz-box-shadow:1px 1px 2px rgba(0,0,0,0.3);
-webkit-box-shadow:1px 1px 2px rgba(0,0,0,0.3);
box-shadow:1px 1px 2px rgba(0,0,0,0.3);
}
a.button:hover {
background:#bbb;
颜色:#000;
text-shadow:1px 1px #eee;
}

a.button:active {
position:relative;
top:1px;
left:1px;
-moz-box-shadow:none;
-webkit-box-shadow:none;
box-shadow:none;
}

< / style>

< a class =buttonhref =#onClick =MyWindow = window.open('http:// localhost:8080 / alfresco / faces / jsp / custom / CodeSelector.jsp ?caseID = $ {caseID}','My Window','toolbar = no,location = no,directories = no,status = no,menubar = no,scrollbars = no,resizable = no,width = 600,height = 300 '); return false; style =text-decoration:nonetarget =_ blank>< span>添加代码< / span>< / a>

在我的 share-workflow-form-config.xml 中,我

 < field id =wf:submitCodelabel-id =workflow.field.outcome设定= 行动 > 
< control template =/ org / alfresco / components / form / controls / workflow / custom-activiti-transitions.ftl>
< / control>
< / field>

至...

 < field id =wf:submitCodelabel-id =workflow.field.outcomeset =actions> 
< control template =/ org / alfresco / components / form / controls / workflow / custom-activiti-transitions.ftl>
< control-param name =caseID> wf:caseIDNum< / control-param>
< / control>
< / field>

我的问题是在 share-workflow-form-config.xml 我指定了 control-param ,我可以让它传入硬编码的值,比如30。但是,当我尝试获取 wf:caseIDNum 等工作流属性的值时,它将返回参数中的实际字符串,如:

http:// localhost:8080 / alfresco / faces / jsp / custom / CodeSelector.jsp?caseID = wfcaseIDNum



,而不是属性的实际值,即30。



关于我可能做错什么的想法?

解决方案

正如skuro所说,你没有做到这一点。



非常简单,你的配置是正确的,但是你的ftl缺少一些逻辑。



为什么你要首先检查< #if field.control.params



它应该是:

 < #if field.control.params.caseID ??> 
< #assign caseID = field.control.params.caseID>
<#else>
< #assign caseID = 1>
< /#if>

不需要上下文或参数或其他东西。

查看默认的 /org/alfresco/components/form/controls/textarea.ftl



----- UPDATE -----



那么如何才能访问此模板中的另一个字段。
所以我们有另一个字段wf:caseIDNum,我们想访问那个字段。



你可以使用下面的hacky机制来获取它

  $ {form.fields [prop_+ caseID?replace(:,_)]。value} 

在form.fields中存储所有当前表单属性。



BTW不要忘记显示wf:caseIDNum和hidden.ftl模板,否则该属性将不会填充到字段对象中;)。


So for my project, we have some javascript code running as a rule within the Alfresco repository. So whenever a new document comes into a certain space, a new folder is dynamically created and that document is moved into that newly created space. Additionally, whenever a new folder is created, a property is updated like so for the document (expect caseID is actually a dynamically generated value based on a sequence in our database):

//Add caseID as a property of the folder
var props = new Array(1);
props["wf:caseIDNum"] = caseID;
var newAspect = newNewSpaceName.addAspect("wf:caseID",props);

However, now we want to be able to reference that newly created aspect/property during the course of our workflow in our share-workflow-form-config-.xml file so that it can be passed as a parameter to our control template. That is, currently we have:

<field id="wf:submitCode" label-id="workflow.field.outcome" set="actions">
                  <control template="/org/alfresco/components/form/controls/workflow/custom-activiti-transitions.ftl"/>
               </field>

But what we want is something like the below:

<field id="wf:submitCode" label-id="workflow.field.outcome" set="actions">
                  <control template="/org/alfresco/components/form/controls/workflow/custom-activiti-transitions.ftl">
                     <control-param name="caseID">wf:caseIDNum</control-param>
                  </control>
               </field>

So my question is, is that the proper syntax to pass a variable/property from the workflow model to the FTL file via the control param?

Edit (10/25/12) -

So based on the help given here, I tried to modify my ftl page like so...

custom-activiti-transitions.ftl:

<#assign caseID = "">
<#if field.control.params.caseID??>
    <#assign caseID = field.control.params.caseID>
<#else>
    <#assign caseID = null>
</#if>

<style type="text/css">

.button {
border: 1px solid #666;
background: #DCDCDC;
padding: 5px;
color: #333;
text-shadow: 1px 1px #fff;
-moz-border-radius: 5px;
-webkit-border-radius: 5px
border-radius: 5px;
cursor: pointer;
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}
a.button:hover {
background: #bbb;
color: #000;
text-shadow: 1px 1px #eee;
}

a.button:active {
position: relative;
top: 1px;
left: 1px;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}

</style>

<a class="button" href="#" onClick="MyWindow=window.open('http://localhost:8080/alfresco/faces/jsp/custom/CodeSelector.jsp?caseID=${caseID}','My Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300'); return false;" style="text-decoration:none" target="_blank"><span>Add Codes</span></a>

And in my share-workflow-form-config.xml, I changed any instance of:

<field id="wf:submitCode" label-id="workflow.field.outcome" set="actions">
 <control template="/org/alfresco/components/form/controls/workflow/custom-activiti-transitions.ftl">
 </control>
</field>

to...

<field id="wf:submitCode" label-id="workflow.field.outcome" set="actions">
 <control template="/org/alfresco/components/form/controls/workflow/custom-activiti-transitions.ftl">
  <control-param name="caseID">wf:caseIDNum</control-param>
 </control>
</field>

My problem is that in the share-workflow-form-config.xml where I specify the control-param, I can get it to pass in a hard coded value like "30". However, when I try to get the value of the workflow property like wf:caseIDNum, it returns the actual string in the parameter like:

http://localhost:8080/alfresco/faces/jsp/custom/CodeSelector.jsp?caseID=wfcaseIDNum

as opposed to the actual value for the property, i.e. "30".

Any ideas on what I could be doing wrong?

解决方案

It's exactly as skuro said and you're not doing this rightly.

Very simple your config is correct but your ftl lacks some logic.

Why will you first check on <#if field.control.params.caseID??> And then not assign it?

It should be:

<#if field.control.params.caseID??>
   <#assign caseID = field.control.params.caseID>
<#else>
   <#assign caseID = 1>
</#if>

There is no need of a context or args or something.

Take a look at the default ones like /org/alfresco/components/form/controls/textarea.ftl

----- UPDATE -----

So how can one access another field in this template. So we've got another field "wf:caseIDNum" and we want to access that one.

You could use the following hacky mechanism to get it

${form.fields["prop_" + caseID?replace(":","_")].value}

in the form.fields all the current form properties are stored.

BTW don't forget to show the "wf:caseIDNum" and the hidden.ftl template or else the property won't be populated in the fields object ;).

这篇关于如何将Control-Parm中的工作流属性传递给Alfresco中的FTL文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆