Alfresco - Aikau Custom Action - alfresco

I want add custom action in alfresco aikau search page.
I have created extension module.
<extension>
<modules>
<module>
<id>Custom Action In Search Result Page</id>
<auto-deploy>true</auto-deploy>
<version>1.0</version>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.pages.faceted-search
</targetPackageRoot>
<sourcePackageRoot>com.custom.faceted-search</sourcePackageRoot>
</customization>
</customizations>
</module>
<module>
<id>Tutorial widgets</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<configurations>
<config evaluator="string-compare" condition="WebFramework"
replace="false">
<web-framework>
<dojo-pages>
<packages>
<package name="search" location="js/search" />
</packages>
</dojo-pages>
</web-framework>
</config>
</configurations>
</module>
</modules>
faceted-search.js
var searchResultPage = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_SEARCH_RESULT");
if(searchResultPage != null) {
searchResultPage.config = {
enableContextMenu : false,
mergeActions : true,
additionalDocumentAndFolderActions : ["example-action"]
}
}
model.jsonModel.widgets.push({
id: "EXAMPLE_LISTENER",
name:"search/action"
});
It is not adding action in search result page individual document.

When you want to display same action in aikau search result page then you have to provide same id which you have given in share-config-custom.xml action.
Ex.example-action
I was providing different Id so it was not displaying.

Related

Spring mvc multipart file upload

I've seen a lot of answers on stackoverflow about multipart file upload problem in Spring MVC application.
Step by step I've make sure that I don't repeat errors others did.
Here is my form
<form class="form-horizontal" data-toggle="validator"
id="track_existing_repair"
method="post"
action="/euo/testUpload.htm"
enctype="multipart/form-data">
...
<div class="form-group required">
<label class="control-label col-sm-4" for="proofOfPurchaseInput">Select File:</label>
<div class="col-sm-8">
<input name="proofOfPurchase"
id="proofOfPurchaseInput"
type="file"
required/>
</div>
</div>
...
</form>
In pom file I have dependency
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
declared multipartResolver in app-servlet.xml
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- max upload size in bytes -->
<property name="maxUploadSize" value="20971520" /> <!-- 20MB -->
<!-- max size of file in memory (in bytes) -->
<property name="maxInMemorySize" value="1048576" /> <!-- 1MB -->
</bean>
Method mapped to request in Controller class
#RequestMapping(value = {"/testUpload"},headers = "Content-Type=multipart/form-data", method = RequestMethod.POST)
public String testUpload(
#RequestPart(value = "proofOfPurchase", required = false) MultipartFile proofOfPurchaseFile
,HttpServletRequest request
) throws InvalidFormatException, IOException {
if(proofOfPurchaseFile != null){
readFile(proofOfPurchaseFile);
}
return NAV_HOME;
}
I tried #RequestParam instead #RequestPart
Without required = false I have "Required request part
'proofOfPurchase' is not present" response, so I made it not required
only to get in to examine request in debugger
So when I stop in debugger I wasn't surprised that request object shows me that file was received and even stored in jBoss temporary folder.
Could you please point out what I could miss that Spring can't see uploaded file?
The problem appears in legacy project where we also use Struts.
It's turn out that struts dispatcher somehow conflicts with spring CommonsMultipartResolver.
Once I've removed all struts servlets and filters from web.xml everything start working.

Fishpig Magento - Set a template for custom post type term view

Trying to set a template specifically for a particular term using the Fishpig Wordpres/Magento plugin.
I have a custom post type called 'Business' and have categories specific to this post type.
In /app/design/frontend/themes/default/layout/wordpress.xml I have the below that renders the template for all my category terms:
<wordpress_term_view>
<reference name="content">
<block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
<block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list.phtml" />
</block>
</reference>
</wordpress_term_view>
But what I need is a different template for a specific category 'executive interviews'.
You can see this here http://staging-ce.beanmediagroup.com.au/business/category/executive-interviews/.
What I've tried
I know you can set a unique page view using something like '' but this doesn't work with term ID.
I also know you can set a custom post list template for custom post types using something like /wordpress/post/list/renderer/business.phtml but this doesn't work for the terms.
Any help would be appreciated.
If you check this file: app/code/community/Fishpig/Wordpress/controllers/TermController.php the viewAction you can see it's adding custom layout handles:
'wordpress_' . $term->getTaxonomyType() . '_view_' . $term->getId(),
'wordpress_' . $term->getTaxonomyType() . '_' . $term->getId()
which means, in your app/design/frontend/themes/default/layout/wordpress.xml if the ID of your desired category is 2 for example, you can add new handles specific for this category:
<wordpress_category_view_2>
<reference name="content">
<block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
<block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" />
</block>
</reference>
</wordpress_category_view_2>
//OR
<wordpress_category_2>
<reference name="content">
<block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
<block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" />
</block>
</reference>
</wordpress_category_2>
//OR
<STORE_default_wordpress_category_view_2>
<reference name="content">
<block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
<block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" />
</block>
</reference>
</STORE_default_wordpress_category_view_2>
//OR
<STORE_default_wordpress_category_2>
<reference name="content">
<block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
<block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" />
</block>
</reference>
</STORE_default_wordpress_category_2>
Just change the 2 with the ID of your category.
zokibtmkd's post is pretty much correct and their method of finding the layout handles is a good one (working through the code until you find the answer), however you don't need to redfine all of the XML blocks and can just reference them instead. Also, you don't need to set post list renderer template via XML as the latest version of the extension will pick this up automatically.
First let's look at changing the post list wrapper template for terms (this defaults to wordpress/term/view.phtml).
<!--
/**
* Change the wrapper template for 'category' with an ID of 2
* Change '2' to the ID you wish to target
* Change 'category' to the taxonomy name
**/
-->
<wordpress_category_view_2>
<reference name="wp.term">
<action method="setTemplate">
<template>wordpress/term/custom-template.phtml</template>
</action>
</reference>
</wordpress_category_view_2>
Now let's look how to change the post list render template.
It is possible to do this via XML as zokibtmkd stated however the latest version of Magento WordPress Integration does not require this. Instead, the extension will take the post type (in this case I believe the post type is 'business') and then look for a template of this name in the wordpress/post/list/renderer directory. To change the post list template for this post type, create a file at wordpress/post/list/renderer/business.phtml
Finally, if you wanted to change the post view template for the 'business' post type, you would create a file at wordpress/post/view/business.phtml.

Alfresco share worflow form validation

I have been trying to validate my alfresco share workflow form for several days without success. This is what i have done.
Configured my workflow in the share-config-custom.xml located in %TOMCAT_HOME%tomcat\shared\classes\alfresco\web-extension
set my contraint handler as follows.
<constraint-handlers>
<constraint type="MANDATORY"
validation-handler="Alfresco.forms.validation.examplestaffnumber"
event="keyup" />
</constraint-handlers>
</field>
This field i have set to mandatory
< label-id="Staff Number" id="leave:staffnumber" mandatory="true">
I have created the contraint hanlder javascript and placed it at %ALFRESCO_HOME%\tomcat\webapps\share\js folder. This is both js and min.js
Finaly added the js in form.get.head.ftl located at %ALFRESCO_HOME%tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form
folder like this
<#script type="text/javascript" src="${page.url.context}/res/js/examplevalidation.js">
When I select my worflow form and key values in the staff number form nothing happens. I have checked in the firebug but there is no any call to the js.
Where could i have gone wrong?
I think you have not added dependencies for your java script. To do that add below code in your share-config-custom.xml located in %ALFRESCO_HOME%tomcat\shared\classes\alfresco\web-extension
<config>
<forms>
<dependencies>
<js src="/js/examplevalidation.js" />
</dependencies>
</forms>
</config>
And your constrains handler should be like
<field id="leave:staffnumber" label-id="Staff Number" mandatory="true">
<control template="/org/alfresco/components/form/controls/textfield.ftl" />
<constraint-handlers>
<constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.examplestaffnumber" event="blur"/>
</constraint-handlers>
</field>
And function in your js should be like this:
Alfresco.forms.validation.examplestaffnumber = function examplestaffnumber(
field, args, event, form, silent, message) {
// your code with return statement
}
Hope this helps!!!

XML Work FLow Deployment in Alfresco

Hi Guyz,
I am trying to deploy the following test workflow definition in alfresco, since from 2 dayz :(
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="helloWorld">
<start-state name="start">
<transition name="" to="hello"></transition>
</start-state>
<node name="hello">
<transition name="" to="end1">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
logger.log("Hello World!");
</script>
</action>
</transition>
</node>
<end-state name="end1"></end-state>
</process-definition>"
But when im going to deploy the above workflow definition in alfresco community 4.2 through "work-flow.jsp, it gives me following error message.
"org.alfresco.service.cmr.workflow.WorkflowException: 03200027 Workflow Component for engine id 'jbpm' is not registered"
Please Help !
JBPM is disabled by default!
Onine docs: http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/tasks/adminconsole-workflow.html
Snippet:
set the following properties in your alfresco-global.properties.
system.workflow.engine.jbpm.enabled=true
system.workflow.engine.jbpm.definitions.visible=true

Restrict upload by filetype or mimetype using Dexterity on Plone

I have a custom content type, built with dexterity. In the schema (The schema is listed below), I use 'plone.namedfile.field.NamedFile' for attachements/uploads.
I would like to restrict uploads so that only mp3 files can be attached to my content type. What is the best approach for achieving this?
Here is the full schema/model for my content type:
<model xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="date" type="zope.schema.Date">
<description />
<title>Date</title>
</field>
<field name="speaker" type="zope.schema.TextLine">
<description />
<title>Speaker</title>
</field>
<field name="service" type="zope.schema.Choice">
<description />
<title>Service</title>
<values>
<element>1st Service</element>
<element>2nd Service</element>
</values>
</field>
<field name="audio_file" type="plone.namedfile.field.NamedFile">
<description />
<title>Audio File</title>
</field>
</schema>
</model>
I shall begin my search here: http://plone.org/products/dexterity/documentation/manual/developer-manual/reference/default-value-validator-adaptors
I've decided to use javascript for my first line of validation.
I've based my solution on information found at <input type="file"> limit selectable files by extensions
Based on the advice my script looks something like this:
$(document).ready( function() {
function checkFile(event) {
var fileElement = document.getElementById("form-widgets-audio_file-input");
var fileExtension = "";
if (fileElement.value.lastIndexOf(".") > 0) {
fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf(".") + 1, fileElement.value.length);
}
if (fileExtension == "mp3") {
return true;
}
else {
alert("You must select a mp3 file for upload");
return false;
}
}
$("form#form").bind("submit",checkFile);
});
This is half the solution, next I'll need to add validation on the server side.

Resources