AnsweredAssumed Answered

Problem with r:property in space editing

Question asked by themarcuz on Mar 29, 2010
Hi,
I have a quite simple question that is giving me lot of headache :)
First, a little intro.
I customized Alfresco model creating new aspects and types, inheriting from both content and folder base class.
Then I customized the document-detail.jsp page creating my extendend-document-detail.jsp, where I handle in a different way (different from standard) some of the properties showed.
What I learned from here is that I can control the jsf component propertySheetGrid, by defining which property to show, and some other details about how to show the different properties.
A sample of what i've done is here
<r:propertySheetGrid id="folder-props"
      value="#{DialogManager.bean.sessionfolder}" var="sessionProps"
      columns="1" mode="view" labelStyleClass="propertiesLabel"
      externalConfig="true" >      
         <r:property name="name" />      
         <r:property name="common:projectNumber" />         
         <r:property name="common:data" />
         <r:property name="common:cliente" />
         <r:property name="common:edr" />
         <r:property name="common:plpm" />
         <r:property name="common:prop-industry" />
         <r:property name="common:prop-argomento" />   
   </r:propertySheetGrid>
As you can see I use propertySheetGrid in a custom page, link to a Node defined by DialogManager.bean.sessionfolder, and then I specify what attribute of this node I want to show (just for been clear, with this tecnique I show some custom attribute of the parent space in the details view of a content).

What I'm trying to do is using the same tecnique in a custom dialog to show some the custom attributes shown in the first code sampe.
I create a custom dialog which backing bean extends EditSpaceDialog: what I do is hook my custom dialog to a custom action that is supposed to help the user create a custom space folder retrieving some data from an external database.
Here is the code of my JSP:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a"%>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r"%>
<h:outputText value="Project: " />
<h:selectOneMenu value="#{DialogManager.bean.selectedproject}">
   <f:selectItems value="#{DialogManager.bean.availableprojects}" />
</h:selectOneMenu>
<f:verbatim>
   <br />
</f:verbatim>
<a:panel label="Progetto" id="project-panel" progressive="true"
   border="white" bgcolor="white" titleBorder="lbgrey"
   expandedTitleBorder="dotted" titleBgcolor="white" rendered="true"
   expanded='True'>
   <h:outputText value="Caratteristiche dello spazio creato" />

   <r:propertySheetGrid id="space-props"
      value="#{DialogManager.bean.editableNode}" var="spaceProps"
      columns="1" labelStyleClass="propertiesLabel" externalConfig="true"
      cellpadding="2" cellspacing="2" />
   <r:property name="common:prop-industry" />
   <r:property name="common:prop-argomento" />
</a:panel>
The first h:selectOneMenu handle the choice of a project from an external DB.
The second part, r:propertySheetGrid , should display the attribute of a space template I defined.
If I delete the 2 rows defining wich attributes to show
<r:property name="common:prop-industry" />
   <r:property name="common:prop-argomento" />
everything works fine, the new space is created, the custom attributes as the value read from the DB and so on…
but trying to show just those 2 properties, nothing works (by the way, it doesn't work with any property I try to specify, neither with just "name" or "description")
The editableNode property of the bean is correctly retrieved, and rapresent a custom type extending cm:folder, instead without specifying any properties in the r:propertySheetGrid component, it shows what it's aspected.

Is there any limitation with the r:propertySheetGrid component when it works with space node?
Am I doing something wrong?

For completeness I'll post also the backing bean code of the jsp posted before, the one with the issue:
package alekso.alfresco.ambrosetti.dialog;

import java.util.ArrayList;

@SuppressWarnings("serial")
public class InternalProjectSelectionDialog extends EditSpaceDialog {

   private static Log logger = LogFactory.getLog(InternalProjectSelectionDialog.class);

   private final String NAMESPACE = "ambrosetti.common.model";

   private String selectedproject;

   public String getSelectedproject() {
      return selectedproject;
   }

   public void setSelectedproject(String selectedproject) {
      this.selectedproject = selectedproject;
   }

   /**
    * Verrà valorizato attraverso dependency injection di JSF
    */
   private RepositoryService repService;

   public RepositoryService getRepService() {
      return repService;
   }

   public void setRepService(RepositoryService repService) {
      this.repService = repService;
   }

   @Override
   protected Node initEditableNode() {
      //return new Node(this.browseBean.getActionSpace().getNodeRef());
      return new Node(new NodeRef(Repository.getStoreRef(), Config
            .getString("InternalProjectSelectionDialog.projectSpaceTemplateId")));
   }

   /**
    * Recupera tutti i progetti esposti dal DB Ambrosetti per proporli all'utente come scelta
    *
    * @return
    */
   public List<SelectItem> getAvailableprojects() {
      // dichiarazione dei SelectItem da presentare all'utente
      List<SelectItem> availableProjects = new ArrayList<SelectItem>();
      // retrieve dei progetti e conversione in select item
      for (InternalProject proj : InternalProject.getAllProject()) {
         availableProjects.add(new SelectItem(proj.getProjectNumber(), proj.getDescrizione()));
      }
      return availableProjects;
   }

   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception {

      logger.debug("Creazione nuovo spazio di progetto");
      // Lettura dei dati relativi al progetto dal db
      InternalProject proj = InternalProject.getInternalProject(getSelectedproject());
      // Creazione nuovo spazio copiando dal template relativo
      NodeRef projectSpace = repService.copyFolder(Config
            .getString("InternalProjectSelectionDialog.projectSpaceTemplateId"), proj.getDescrizione(), proj
            .getDescrizione(), proj.getProjectNumber());
      // Valorizzazione dei metadati della projectfolder
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "projectNumber"),
            proj.getProjectNumber());
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "data"), proj.getData());
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "cliente"), proj.getCliente());
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "edr"), proj.getEdr());
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "plpm"), proj.getPl());
      // recupero valori ausiliari
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "prop-industry"),
            (ArrayList)editableNode.getProperties().get("{" + NAMESPACE + "}prop-industry"));
      getNodeService().setProperty(projectSpace, QName.createQName(NAMESPACE, "prop-argomento"),
            (ArrayList)editableNode.getProperties().get("{" + NAMESPACE + "}prop-argomento"));      
      return outcome;
   }

   @Override
   public boolean getFinishButtonDisabled() {
      return false;
   }

}

Outcomes