AnsweredAssumed Answered

[Solved] Custom Action Wizard

Question asked by lamba on Sep 13, 2010
Latest reply on Sep 20, 2010 by lamba
Hi everybody,

I want to launch an action using a Wizard. This last one must contain drop-down lists filled by means of a Java bean.

For that purpose, I created the action in the file "web-client-config-custom.xml ".

<alfresco-config>
   <config evaluator="string-compare" condition="Action Wizards">
         <action-handlers>
            <handler name="publish" class="com.custom.alfresco.action.publish.PublishActionHandler" />
      </action-handlers>
   </config>
  
   <config>
      <actions>
         <action id="publish">
            <label>Publish Content</label>
       <image>/images/extension/custom.png</image>
            <action>wizard:publishWizard</action>
            <action-listener>#{BrowseBean.setupSpaceAction}</action-listener>
            <params>
               <param name="id">#{actionContext.id}</param>
            </params>
         </action>
         <action-group id="space_details_actions">
            <action idref="publish" />
         </action-group>
      </actions>
   </config>
  
   <config>
      <wizards>
         <!– Definition of the publish action wizard–>
         <wizard name="publishWizard" managed-bean="PublishActionWizard"
            title-id="publish_action_title" description-id="publish_action_desc"
         icon="/images/icons/new_rule_large.gif">
            <step name="publish" title-id="publish_action_title" description-id="publish_action_desc">
          <page path="/jsp/actions/extension/publish.jsp"
                  title-id="run_action_step1_title"
                  description-id=""
                  instruction-id="default_instruction"/>
            </step>
         </wizard>
      </wizards>
   </config>  
  
</alfresco-config>
At this level the action is shown well in the menu of the actions (on the detailed view of a space and in the list of the actions in "Run Action Wizard").

I created the page jsp under "/ jsp / actions / extension":


<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
     <table cellpadding="2" cellspacing="2" border="0" width="100%">
            <tr>
               <td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.set_action_values}" /></td>
            </tr>
            <tr><td colspan="2" class="paddingRow"></td></tr>
                  <tr>
                      <td><nobr><h:outputText value="#{customMsg.filters}:"/></nobr></td>
                      <td width="95%">
                          <h:selectOneMenu value="#{WizardManager.bean.actionProperties.filter}">
                          <f:selectItems value="#{PublishActionWizard.filters}" />
                      </h:selectOneMenu>
                     </td>
                  </tr>
                                
                  <tr>
                     <td><nobr><h:outputText value="#{customMsg.folders}:"/></nobr></td>
                     <td width="95%">
                         <h:selectOneMenu value="#{WizardManager.bean.actionProperties.folder}">
                        <f:selectItems value="#{PublishActionWizard.folders}" />
                      </h:selectOneMenu>
                     </td>
                  </tr>
                                
                  <tr>
                     <td colspan="2"><h:outputText value="#{customMsg.want_index_content}"/></td>
                  </tr>
                  <tr>
                     <td colspan="2">
                           <table cellpadding="2" cellspacing="2" border="0">
                              <tr>
                                 <td valign="top">
                                    <h:selectOneRadio id="index"                                                                                                                                                                                                                                                                                                                                                                                                                              
                                      value="#{WizardManager.bean.actionProperties.index}">
                                       <f:selectItem itemValue="yes" itemLabel="#{msg.yes}" />
                                       <f:selectItem itemValue="no" itemLabel="#{msg.no}" />
                                    </h:selectOneRadio>
                                 </td>
                              </tr>
                           </table>
                     </td>
                  </tr>
           
                 <tr><td class="paddingRow"></td></tr>
     </table>

I created the "Handler " and the "Executor "
I added the Handler in " web-client-config-custom.xml " (under the condition " Action Wizards ") and I defined Executor in the "service-context.xml"

I created the bean of the wizard:


public abstract class PublishActionWizard extends RunActionWizard
{
   private static final long serialVersionUID = 5925759221710403043L;
   private static final Log logger = LogFactory.getLog(PublishActionWizard.class);
  
   protected List<SelectItem> filters;     
   protected List<SelectItem> folders;
  
// ——————————————————————————
   // Wizard implementation
  
 
   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception{
      logger.debug("finishImpl(FacesContext " + context + ",outcome " + outcome + ") called");
     
      super.finishImpl(context, outcome);
           
      return outcome;
   }
  
   // ——————————————————————————
   // Bean Getters and Setters
 
  public List<SelectItem> getFilters(){
      …
      return this.filters;
   }
     
   public List<SelectItem> getFolders(){
      …
      return this.folders;
   }
  
   …
}

I defined the bean of the wizard in "faces-config-custom.xml" as follows:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
                              "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
    <managed-bean>
      <managed-bean-name>PublishActionWizard</managed-bean-name>
      <managed-bean-class>com.custom.alfresco.action.wizard.PublishActionWizard</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>searchService</property-name>
         <value>#{SearchService}</value>
      </managed-property>
      <managed-property>
         <property-name>navigator</property-name>
         <value>#{NavigationBean}</value>
      </managed-property>
      <managed-property>
         <property-name>browseBean</property-name>
         <value>#{BrowseBean}</value>
      </managed-property>
      <managed-property>
         <property-name>actionService</property-name>
         <value>#{ActionService}</value>
      </managed-property>
      <managed-property>
         <property-name>dictionaryService</property-name>
         <value>#{DictionaryService}</value>
      </managed-property>
      <managed-property>
         <property-name>mimetypeService</property-name>
         <value>#{MimetypeService}</value>
      </managed-property>
      <managed-property>
         <property-name>personService</property-name>
         <value>#{PersonService}</value>
      </managed-property>
      <managed-property>
         <property-name>authorityService</property-name>
         <value>#{AuthorityService}</value>
      </managed-property>
   </managed-bean>
  
</faces-config>
But, when I launch the action from the detailed view, I obtain the following error:
org.alfresco.error.AlfrescoRuntimeException: 08030002 Failed to start wizard as managed bean 'PublishActionWizard' has not been defined

And when I launch the action from "Run Action Wizard", I obtain the following error:
javax.faces.FacesException: javax.faces.el.EvaluationException: Cannot get value for expression '#{PublishActionWizard.filters}'
caused by:
org.apache.jasper.JasperException: javax.faces.el.EvaluationException: Cannot get value for expression '#{PublishActionWizard.filters}'
caused by:
javax.faces.el.EvaluationException: Cannot get value for expression '#{PublishActionWizard.filters}'
caused by:
javax.faces.FacesException: java.lang.InstantiationException
caused by:
java.lang.InstantiationException


N.B: I tested the action with inputText instead of drop-down lists and that works only when I launch the action from the "Run Action Wizard".
But when I launch the action from the detailed view of the space I have the same error as above.
org.alfresco.error.AlfrescoRuntimeException: 08030002 Failed to start wizard as managed bean 'PublishActionWizard' has not been defined

To summarize, the problem is on the JSP page, the bean is not recognized and afterward the properties list of filters and list of folders and thus my drop-down lists are not filled.


thanks for help,

Outcomes