AnsweredAssumed Answered

when will AVMBrowseBean be initialized?

Question asked by rockycres on Jul 6, 2009
Hi,

I am currently working on Alfresco WCM  where I have created the custom  action called custom_deploy_file ,to that action I want to set few param vaues like (store,updateTestServer).For setting these param values , I have created a custom class called UserStoreFinder ,in which I will use the AvmBrowseBean's getWebsite method to get storeref…etc..After I login & straightaway access this action ,this method is returning  NULL since in avmbrowseBean some of the values are not set.But after I browse the webproject & clicked the same action again ,then it's working fine.So does AVMbrowseBean will be properly set only when we browse the webproject ?Kindly help in this issue.

web-client-config-custom.xml

<action id="custom_deploy_file">
                             <permissions>
                                <permission allow="true">Write,CreateChildren</permission>
                             </permissions>
                             <evaluator>org.alfresco.web.action.evaluator.WCMTestEvaluator</evaluator>
                             <label>Test Deployment</label>
                             <image>/images/icons/deploy.gif</image>
                             <action-listener>#{DialogManager.setupParameters}</action-listener>
                             <action>dialog:deployWebsite</action>
                             <params>
                                <param name="id">#{actionContext.id}</param>
                                <param name="previewURL">#{actionContext.previewUrl}</param>
                                <param name="deployMode">#{DeployWebsiteDialogTest.deployMode}</param>
                                <param name="webproject">#{DeployWebsiteDialogTest.webProjectRef}</param>
                                <param name="snapshotVersion">#{DeployWebsiteDialogTest.snapshotVersion}</param>
                                <param name="store">#{UserStoreFinder.store}</param>
                                <param name="updateTestServer">#{UserStoreFinder.updateTestServer}</param>
                             </params>
                    </action>

UserStoreFinder.java

public class UserStoreFinder
{
   private static final long serialVersionUID = 59524560340308134L;
   protected String updateTestServer;
   protected String store;
   protected String webapp;
   protected NodeRef webProjectRef;
   protected AVMBrowseBean avmBrowseBean;
   
   public String getUserStore(){
      Node avm = this.avmBrowseBean.getWebsite();
      String userStore = null;
      if(avm != null)
      {
         Map<String, Object> serverProps = avm.getProperties();
         String creator = (String)serverProps.get(ContentModel.PROP_CREATOR);
         WebProject webProject = avmBrowseBean.getWebProject();      
         userStore = AVMUtil.buildUserMainStoreName(webProject.getStoreId(), creator);
      }
      else{
         
      }
      return userStore;
   }

   public String getStore() {      
      return getUserStore();
   }

   public void setStore(String store) {
      this.store = store;
   }

   public void setUpdateTestServer(boolean updateTestServer) {
      this.updateTestServer = updateTestServer;
   }

   public boolean getUpdateTestServer() {   
      
        // if a test server has already been allocated inform the dialog
       // that an update is needed
       NodeRef testServer = DeploymentUtil.findAllocatedTestServer(getUserStore());
       if (testServer != null)
       {
          return  true;
       }
       return false;
   }
   public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) {
      this.avmBrowseBean = avmBrowseBean;
   }

}

faces-config-custom.xml
  
 <managed-bean>
      <description>
        The bean that backs up the view of the Versioned Properties
      </description>
      <managed-bean-name>UserStoreFinder</managed-bean-name>
      <managed-bean-class>
            org.alfresco.web.action.evaluator.UserStoreFinder
      </managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
           <managed-property>
         <property-name>avmBrowseBean</property-name>
         <value>#{AVMBrowseBean}</value>
      </managed-property>
    </managed-bean>

Outcomes