cancel
Showing results for 
Search instead for 
Did you mean: 

New Custom Action in Alfresco

cristi
Champ in-the-making
Champ in-the-making
Hello all!
I want to do a custom action associated to rule. I have used a guide http://wiki.alfresco.com/wiki/Custom_Action_UI but I don't get I need. I'm really newby using Alfresco…

My problem: I have created my custom action. I select it in Alfresco UI and when I press the button "Set Values and Add" the application doesn't show any window to add any value to parameter that I have defined in method addParameterDefinitions:

protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
        paramList.add(new ParameterDefinitionImpl(PARAM_CUSTOM_URL, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_CUSTOM_URL)));

}

I'm not sure if I need a jsp, all I want is a text box to type a parameter. I have created a jsp and its ActionHandler, defining it in the web-client-config-custom.xml file, but Alfresco don't recognise the jsp. I don't know the location where I have to put the jsp.

Thanks!
4 REPLIES 4

cristi
Champ in-the-making
Champ in-the-making
Hello!

I have already solved that problem. Now, when I introduce a value of parameter, it doesn't save. I don't know if I have to initialize it somewhere…

Thanks!

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

Please post your custom files here… It will be easier to help you…

Take a look here : http://xsudan.info/index.php?n=Alfresco.CustomActionHandlerConfiguration

cristi
Champ in-the-making
Champ in-the-making
Hi!
I have realised that the method "prepareForSave" is never called, only when the custom action is executed. The inserted value of the parameter is never persists and I don't know how to do it.


The jsp:

<r:page titleId="title_custom_url_action_executer">
<f:view>  
<%– load a bundle of properties with I18N strings –%>
<r:loadBundle var="msg"/>
  
<h:form acceptcharset="UTF-8" id="custom_url_action">
……
<tr>
<td valign="top"><h:outputText value="#{msg.custom_url}"/>:</td>
<td width="90%">
   <h:inputText id="custom_url" value="#{WizardManager.bean.actionProperties.custom_url}" size="50" maxlength="1024" />
</td>
</tr>
……
</h:form>
</f:view>
</r:page>


My ActionHandler

   
public class UrlActionHandler extends BaseActionHandler{
       
       protected static final Logger LOG = LoggerFactory.getLogger(UrlActionHandler.class);
   
       /**
        *
        */
       private static final long serialVersionUID = 1L;
       public final static String PROP_CUSTOM_URL = "custom-url";
         
          public String getJSPPath() {
             return "/jsp/actions/custom-url-action-executer.jsp";
          }
         
          public void prepareForSave(Map<String, Serializable> actionProps, Map<String, Serializable> repoProps) {
             repoProps.put(UrlActionExecuter.PARAM_CUSTOM_URL, (String)actionProps.get(PROP_CUSTOM_URL));
          }
   
          public void prepareForEdit(Map<String, Serializable> actionProps, Map<String, Serializable> repoProps) {
             actionProps.put(PROP_CUSTOM_URL, (String)repoProps.get(UrlActionExecuter.PARAM_CUSTOM_URL));
          }
   
          public String generateSummary(FacesContext context, IWizardBean wizard, Map<String, Serializable> actionProps) {
             String url = (String)actionProps.get(PROP_CUSTOM_URL);
             if (url == null) {
                url = "";
             }
            
             return MessageFormat.format(Application.getMessage(context, "custom-url-action-executer"), new Object[] {url});
          }     
       
    }



web-client-config-custom.xml file:

<alfresco-config>

   <config evaluator="string-compare" condition="Action Wizards">
      <action-handlers>
         <handler name="custom-url-action-executer" class="executer.UrlActionHandler" />
      </action-handlers>
   </config>
   
</alfresco-config>

Thanks!

cristi
Champ in-the-making
Champ in-the-making
My problem is solved! In my jsp code had a bug, it was missing a ID.
Thanks everybody!