How to override some of ajax based picker logic? - alfresco

Alfresco Community v5.2 (other versions too) includes some of preconfigured workflows that available on the page /share/page/start-workflow
I'm interested in "Review and Approve (one or more reviewers) - Assign a review task to multiple reviewers".
Actually, to be more precise - in the logic of assigning.
For example, I want to make some customization - Customization of the user task screen
I want to display members in the table, not in the list. For this I need to understand how they appear in the list.
In the file share-config-custom.xml I can find the path to the templates.
For example, for the bpm:workflowDueDate it will be:
...
<field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
...
But for bpm:assignees the template is not specified:
...
<field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee" />
...
I assume, that there are some back-end beans, that perform most of the logic.
How can I override some of ajax based picker logic?

If a form control is not provided in the share form config, Alfresco Share falls back to some defaults depending on the type of the field.
bpm:assignee is an association to a person node, so I would expect it to point by default to association.ftl !
What I suggest is to copy that file into a new one let's say src/main/amp/alfresco/site-webscripts/${project.groupId}/form/controls/custom-association.ftl
and then in your share-config-custom.xml copy over the form config for the task with one small update :
...
<field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee" >
<control template="/${project.groupId}/form/controls/custom-association.ftl" />
</field>
...
and then you can safely fiddle with custom-association.ftl because it is almost never a good idea to override alfresco defaults !
UPDATE : The value of that control is a list of nodeRefs referring to the nodes of the selected users. It is the ObjectFinder Java script object who is managing things behind the scene, calling a special endpoint to fetch all sort of data to be shown, then manipulates the DOM accordingly ! You might want to look at object-finder.js and picker.inc.ftl

Related

plone.app.multilingual: Access Translated Object's Attributes

Environment: Plone 4.3.3, plone.app.multilingual 2.0a4 (checkout from github), in my case, two languages (en and zh) are enabled, ie a bilingual site.
My custom Dexterity type has a field remoteUrl, its definition looks like this:
<field name="remoteUrl"
type="zope.schema.TextLine">
<title i18n:translate="">URL</title>
<description i18n:translate="">Link to the Resource.</description>
<default>http://</default>
<required>False</required>
</field>
My scenario is like this: When creating the item in the zh folder (zh/my_item), the remoteUrl field is filled, it will be displayed according to the template. Then, when translating the item into en language (en/my_item), I want it display the value from zh/my_item if the remoteUrl field unfilled in en/my_item. On the other hand, if filled in en/my_item, its value will be used and displayed for the remoteUrl field.
The existing Language Independent Field does not meet my needs, because the filled value will affect both zh/en items. How do I access zh/my_item remoteUrl value from en/my_item context? Any hints or sample snippets for the view class / template will be appreciated.
if you just want to display an alternative value from the other language, you can access translations from catalog index TranslationGroup. Just an idea.

how to set publish dcp for child or other publications to different location without overiding all other settings

I am trying to configure cd_storage and getting issue in setting up dynamic component presentation as they get over written by child and published to same folder from every publication.
I know we can define the publication level settings but once we define that then it expect us to define everything inside that publication tag. We do not want to define every thing 50 times in publication tag.
Could any one suggest the best practice for same.
this is for sdl tridion 2011 sp1
Thanks in advance...
Your problem is in how you defined your storage configuration for the storage which you use to store ComponentPresentations. There is a flag in the definition of a storage which sets exactly this type of behavior: defaultFilesystem. You probably have it set to false which causes all ComponentPresentations from all publications to be stored in the same location. By setting this flag to true you will get ComponentPresentations from different publications stored in different locations. I will give an example to show how this works in cd_storage_conf.xml:
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultCPs" defaultFilesystem="true">
<Root Path="c:\temp\cpRoot" />
</Storage>
....
<ItemTypes defaultStorageId="defaultFile" cached="true">
<Item typeMapping="ComponentPresentation" itemExtension=".jsp" storageId="defaultCPs"/>
....
This is really easy to maintain and will make the Broker to store ComponentPresentations to locations like: c:\temp\cpRoot\pub109\dcp\jsp\*** (here I have publicationId=109).
Hope this helps.

Alfresco FormService Fundamental WRONG

Alfresco Forms Service does not work properly.
Looks like a fundamental Form functionality does not pass form configs (control-param name="nameHere") to webscripts.
I reproduce it step-by-step.
Create the Freemarker template and register it according to the documentation under /share project. The component renders and shows successfully. Everything works well.
Create a form according to the documentation on wiki Forms page.
Register it in <TOMCAT_INST/shared/classes/alfresco/web-
extension/myclok-form-config.xml> directory and pass it for load in such manner:
<bean id="sampleShareConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
<list>
<value>classpath:alfresco/web-extension/myclok-form-config.xml</value>
</list>
</property>
</bean>
<!-- ... share/WEB-INF/classes/org/springframework/extensions/surf/bootstrap/forms-bootstrap-context.xml -->
Form inst:
<config>
<forms>
<form id="myclok">
<view-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />
<edit-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />
<create-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />
<field-visibility>
<show id="currentPath" />
</field-visibility>
<appearance>
<field id="currentPath">
<control name="currentPath" template="/org/alfresco/components/myclok/myclok.get.html.ftl">
<control-param name="currentPath">sampleData1</control-param>
</control>
</field>
<control name="currentPath" template="/org/alfresco/components/myclok/myclok.get.html.ftl">
<control-param name="currentPath">sampleData2</control-param>
</control>
</appearance>
</form>
</forms>
</config>
In official documentation is written:
If the form element exists within a config element without an
evaluator and condition the form is always found, this is useful if
you want a certain field to appear on EVERY form in your application.
So, I specified it in myclok-form-config.xml file, but this approach does not give any result. Thus when the component with such reference to param is loaded by the following URL <http://localhost:8080/share/page/site/wcmqs/myclok> the Alfresco fails with the Exception:
Exception: freemarker.core.InvalidReferenceException - Expression field is undefined on line 6, column 6 in org/alfresco/components/myclok/myclok.get.html.ftl.
freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
In other words it's impossible to receive the value of the parameter of currentPath that is defined in FormConfigs.
So, the minimal functionality of FormsService / ConfigService does not work.
<#if field.control.params.currentPath??>
<#assign path=field.control.params.currentPath>
<#else>
<#assign path="someOtherDataValue">
</#if>
Does anyone know how to resolve it Or can demonstrate a working sample?
PS: All above described configurations of the form of FormService and the webscript component are attached.
The .AMP file for quick installation is required just to invoke the following command:
java -jar alfresco-mmt.jar install myclokStubFormComponent.amp ../tomcat/webapps/share.war
AMP file.
Config file.
I think you have mis-understood the difference betweent a form template and a field template. You are specifying the same file /org/alfresco/components/myclok/myclok.get.html.ftl to control the layout of the form as well as to render your fields.
When you use a field template to render the form you are getting an error that says the field object has not been populated. This is quite correct as the framework has not yet started to render the individual fields. You are rendering the form.
I'd suggest you try some more basic examples such as those that come with the Forms Development Kit (FDK) before you start implementing your own more complex forms, and especially before you begin to claim that the framework does not work as documented.

How to create/read a node bilingualy

I need to create nodes with bilingual properties, and use all of these nodes as (List constraints) where node property will be label and another property will be value.
So, is this doable ? & how ?
I see sys:localized, and its mean
Localization:
If you add this aspect to a node, then the server will assume that all non-multilingual
properties apply to this locale.
can this help me !
Thanks
Mohammed Amr
Senior System Developer
In order to handle Multi Lingual documents from your code you are supposed to use the MultilingualContentService to:
add a translation
retrieve the available translations
etc.
Multilingual documents have the cm:mlDocument aspect applied. This enables them to be listed as children of the special cm:mlContainer that's created under /cm:multilingualRoot to track translations of a single document. The cm:mlContainer is defined as follows:
<type name="cm:mlContainer">
<title>Multilingual Container</title>
<parent>sys:container</parent>
<associations>
<child-association name="cm:mlChild">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:mlDocument</class>
<mandatory>true</mandatory>
<many>true</many>
</target>
</child-association>
</associations>
<mandatory-aspects>
<aspect>cm:versionable</aspect>
<aspect>cm:author</aspect>
<aspect>sys:localized</aspect>
</mandatory-aspects>
</type>
There are different kinds of localization options in Alfresco:
The MultilingualContentService (with the cm:mlDocument aspect) allows you to store translated content on a single node. You can use this if you have a document that is translated into multiple languages. There is no support for this in Share but you can use it via the Alfresco Explorer or the API.
There are also multilingual text properties. You can use the datatype d:mlText in your content model and to store property values (strings only) based on the user language. The build in properties cm:title and cm:description are of type d:mlText. The usage in Share is a bit tricky though - Alfresco uses the browser language to automatically choose the locale, so users with different browser languages will see different values.
As far as I understand your question, I think what you need are the ml:properties. The Share UI only supports them indirectly, maybe that's ok for you. As for the the List constraints I have not seen any multi language support there, so you probably have to extend those yourself.

Spring WebFlow: What can i do with flow outcome?

I'm reading Spring WebFlow documentation, but I don't understand what can i do with outcome value in end-state of flow. Could You show me some practical example ? I wonder how to pass outcome variable to MVC Controller or another flow, but don't know how.
<flow>
<end-state id="test2">
<output name="id" value="123" />
</end-state>
</flow>
You can access your output variables from the parent flow (if you have called a subflow) by using currentEvent.attributes (so in your example):
currentEvent.attributes.id
See section 3.10 Calling Subflows
You can also get them programatically in a FlowHandler by implementing the handleExecutionOutcome method. There is an example in the docs under the "Example FlowHandler" section of 11.4 Implementing custom FlowHandlers.

Resources