cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action - Form [SOLVED]

cjimenez2581
Champ in-the-making
Champ in-the-making
Im developing custom actions but I still dont know how I can customize those forms…

I want to create this in a correct way [img]http://i988.photobucket.com/albums/af4/cjimenez2581/bug/errores/Seleccin_006.png[/img]
Smiley Surprisedops:
4 REPLIES 4

erikwinlof
Confirmed Champ
Confirmed Champ
Please visit the following wiki page for instructions:
http://wiki.alfresco.com/wiki/Custom_Share_Action_UI

Cheers,

:: Erik

cjimenez2581
Champ in-the-making
Champ in-the-making
Please visit the following wiki page for instructions:
http://wiki.alfresco.com/wiki/Custom_Share_Action_UI

Cheers,

:: Erik

well Thanks, but I still dont get it  Smiley Indifferent

erikwinlof
Confirmed Champ
Confirmed Champ
If you could explain exactly what you are trying to do I can hopefully give you some tips.

Cheers, Erik

cjimenez2581
Champ in-the-making
Champ in-the-making
If you could explain exactly what you are trying to do I can hopefully give you some tips.

Cheers, Erik

Thank you,
Im trying to do something like this [img]http://i988.photobucket.com/albums/af4/cjimenez2581/bug/errores/Seleccin_007.png[/img]
but when I do my custom action looks like this
[img]http://i988.photobucket.com/albums/af4/cjimenez2581/bug/errores/Seleccin_006.png[/img]

MiAccion.JAVA

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Date;
import java.util.List;

import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.generator.BaseComponentGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import ak.wf.DatabaseUtil;

/**
* @author Christopher Jiménez Valverde
*
*         24/11/2011
*/
public class MiAccion extends ActionExecuterAbstractBase {

   @Override
   protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
      // TODO Auto-generated method stub
      if (nodeService.exists(actionedUponNodeRef)) // sigue existiendo?
      {
         insertarDatos(action.getCreator(), action.getCreatedDate());
         NodeRef destinationParent = (NodeRef) action
               .getParameterValue(PARAM_DESTINATION_FOLDER);
         QName destinationAssocTypeQName = (QName) action
               .getParameterValue(PARAM_ASSOC_TYPE_QNAME);
         QName destinationAssocQName = (QName) action
               .getParameterValue(PARAM_ASSOC_QNAME);

         boolean deepCopy = false;
         this.copyService.copy(actionedUponNodeRef, destinationParent,
               destinationAssocTypeQName, destinationAssocQName, deepCopy);
      }
   }

   @Override
   protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
      // TODO Auto-generated method stub
      paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER,
            DataTypeDefinition.NODE_REF, true,
            getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
      paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME,
            DataTypeDefinition.QNAME, true,
            getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME)));
      paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME,
            DataTypeDefinition.QNAME, true,
            getParamDisplayLabel(PARAM_ASSOC_QNAME)));
      paramList.add(new ParameterDefinitionImpl(PARAM_DEEP_COPY,
            DataTypeDefinition.BOOLEAN, false,
            getParamDisplayLabel(PARAM_DEEP_COPY)));

   }

   private boolean insertarDatos(String asignado, Date date) {
      try {
         PreparedStatement stmt = null;
         Connection cnx = DatabaseUtil.getConnectionFactory()
               .getConnection();
         stmt = cnx
               .prepareStatement("INSERT INTO listaAsignados(asignado,fecha) VALUES (?,?)");
         stmt.setString(1, asignado);
         @SuppressWarnings("deprecation")
         java.sql.Date d = new java.sql.Date(date.getYear(),
               date.getMonth(), date.getDay());
         stmt.setDate(2, d);
         stmt.execute();
         stmt.close();
         return true;
      } catch (Exception e) {
         System.out.println(e.toString());
         logger.error(e.toString());
         return false;
      }
   }

   /**
    * @return the nodeService
    */
   public NodeService getNodeService() {
      return nodeService;
   }

   /**
    * @param nodeService
    *            the nodeService to set
    */
   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }

   /**
    * @return the copyService
    */
   public CopyService getCopyService() {
      return copyService;
   }

   /**
    * @param copyService
    *            the copyService to set
    */
   public void setCopyService(CopyService copyService) {
      this.copyService = copyService;
   }

   private static Log logger = LogFactory.getLog(BaseComponentGenerator.class);
   private NodeService nodeService;
   private CopyService copyService;
   public static final String NAME = "custom-copy";
   public static final String PARAM_DESTINATION_FOLDER = "destination-folder";
   public static final String PARAM_ASSOC_TYPE_QNAME = "assoc-type";
   public static final String PARAM_ASSOC_QNAME = "assoc-name";
   public static final String PARAM_DEEP_COPY = "deep-copy";

}

acciones-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!– Add aspect custom action –>
<beans>
        <bean id="custom-copy" class="ak.acciones.MiAccion" parent="action-executer">
                <property name="nodeService">
                        <ref bean="nodeService" />
                </property>
                <property name="copyService">
                        <ref bean="copyService"/>
                </property>
                <!– <property name="publicAction"> <value>false</value> </property> –>
        </bean>
        <bean id="custom-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>ak.acciones.Mi-action-messages</value>
         </list>
      </property>
   </bean>
</beans>

properties
custom-copy.title=ParametroNuevo
custom-copy.description=Accion personalizada
custom-copy.{destination-folder}.display-label= Ubicacion a copiar
custom-copy.assoc-type.display-label=Asociacion
custom-copy.assoc-name.display-label=nombre asociacion
custom-copy.deep-copy.display-label=copia profunda


But My UI is wrong or Im doing something wrong…  :?