Alfresco中带参数的新自定义操作

时间:2011-11-22 10:07:15

标签: jsp custom-action alfresco

我想做一个与规则相关的自定义操作。我借助此页面创建了我的proyect结构:http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven 我使用本指南http://wiki.alfresco.com/wiki/Custom_Action_UI进行项目开发。

我的问题:我创建了自定义操作。我在Alfresco UI中选择它并按下“设置值和添加”按钮,但是当我引入参数值时,它不会保存。我不知道是否必须在某处初始化它...但是只有在执行自定义操作时才会调用方法“prepareForSave”。然后参数的值永远不会持续,我不知道该怎么做。

我在方法addParameterDefinitions中定义了参数:

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

}

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>

我的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文件:

<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>

0 个答案:

没有答案