cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved] Custom Action Wizard

lamba
Champ on-the-rise
Champ on-the-rise
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,
2 REPLIES 2

lamba
Champ on-the-rise
Champ on-the-rise
Do you need any further information to help me?
If it's the case, please, do not hesitate any more

thanks.

lamba
Champ on-the-rise
Champ on-the-rise
Solved Smiley Happy

Here is the code which works for my bean:
- Implementation of the bean (using extends BaseWizardBean instead of extends RunActionWizard)
And I was obliged to change the name of the bean, because if I use the other name "PublishActionWizard" I obtain errors as before!!!? Somebody has an explanation for this?


public class PublishContentWizard extends BaseWizardBean
{
   private static final long serialVersionUID = 5925759221710403043L;
   private static final Log logger = LogFactory.getLog(PublishContentWizard.class);
  
   protected List<SelectItem> filters;
   protected String filter;
    
   protected List<SelectItem> folders;
   protected String folder;
        
   // ——————————————————————————
   // Wizard implementation
  
   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception{
      logger.debug("finishImpl(FacesContext " + context + ",outcome " + outcome + ") called");

      return outcome;
   }
  
   // ——————————————————————————
   // Bean Getters and Setters

   public String getFilter() {
         logger.debug("getFilter() called");
         return filter;
   }
  
   public void setFilter(String filter) {
      logger.debug("setFilter( Filter " + filter + ") called");
      this.filter = filter;
   }
  
   public String getFolder() {
      logger.debug("getFolder() called");
      return folder;
   }
  
   public void setFolder(String folder) {
      logger.debug("setFolder(Folder " + folder + ") called");
      this.folder = folder;
   }
  
   public List<SelectItem> getFilters()
   {
      logger.debug("getFilters() called");
      if (this.filters == null)
      {
         this.filters = new ArrayList<SelectItem>();
       
         try {
                …
      this.filters.add(new SelectItem( filterVal));
        …  
        // make sure the list is sorted by the label
               QuickSort sorter = new QuickSort(this.filters, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
               sorter.sort();
          
        } catch (Exception ex) {
                       …
        }
      }
    
      return this.filters;
   }

   public List<SelectItem> getFolders(){
      logger.debug("getFolders() called");     
      if (this.folders == null || this.folders.isEmpty())
      {
               this.folders = new ArrayList<SelectItem>();
       
         if (selectedFilter != null) {
            try {
                 …
                                        this.folders.add(new SelectItem(folderVal));
                                        …
                 // make sure the list is sorted by the label
                                    QuickSort sorter = new QuickSort(this.folders, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                             sorter.sort();
                   
                 } catch (Exception ex) {
                    …
                 }
         }
      }
     
      return this.folders;
   }
   …
}
- Declaration of the bean in "faces-config-custom.xml":

<?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>PublishContentWizard</managed-bean-name>
      <managed-bean-class>com.rsd.alfresco.action.wizard.PublishContentWizard</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>fileFolderService</property-name>
         <value>#{FileFolderService}</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>dictionaryService</property-name>
         <value>#{DictionaryService}</value>
      </managed-property>
      <managed-property>
         <property-name>namespaceService</property-name>
         <value>#{NamespaceService}</value>
      </managed-property>
   </managed-bean>
  
</faces-config>
- Nothing to put in "web-client-config-custom.xml ", only the declaration of the Handler.
- In the JSP page, I use the following call:
<f:selectItems value="#{PublishContentWizard.filters}" />

Praise to Allah the Lord of the Worlds Smiley Happy