AnsweredAssumed Answered

Adding custom property to Person/User

Question asked by albertomv on Nov 23, 2007
Latest reply on Dec 14, 2007 by kevinr

I'm trying to add a new property to users/people in Alfresco and customising the Web Client to support it.

As I've read in, there is currently no way to customise declaratively the NewUserWizard as with other wizards through Property Sheets. ¿Am I right?

I'd appreciate if someone could show me any way to do this or comment the approach I explain below. Thanks

I've tried the following approach, which works, but it's highly "invasive":

First I created "my.custom.UserWizard" which extends. "org.alfresco.web.bean.wizard.NewUserWizard"

         The bean that backs up the New User Wizard

and added there a new property:

private Boolean myProp = null;
static final QName PROP_MYPROP = QName.createQName(
         NamespaceService.CONTENT_MODEL_1_0_URI, "myProp");   

Redefined some methods:

First init():


Then populate():

// set values for edit mode
Map<String, Object> props = getPerson().getProperties();
this.myProp = (Boolean) props.get("myProp");

And finally finish():

String outcome = super.finish();
      if (outcome == null)
         return null;
      outcome = FINISH_OUTCOME;
UserTransaction tx = null;

      try {
         FacesContext context = FacesContext.getCurrentInstance();
         tx = Repository.getUserTransaction(context);

         // update the existing node in the repository
            NodeRef nodeRef = getPerson().getNodeRef();
            this.nodeService.setProperty(nodeRef, PROP_MYPROP, this.myProp);
            NodeRef person =this.personService.getPerson(this.getUserName());
            this.nodeService.setProperty(person, PROP_MYPROP, this.myProp);

         // commit the transaction

         // reset the richlist component so it rebinds to the users list
      } catch (Throwable e) {
         // rollback the transaction
         try {
            if (tx != null) {
         } catch (Exception tex) {
                        //Treat the error
         outcome = null;

      return outcome;

Then, I added some code into person-properties.jsp:

<td><h:outputText value="My Prop?" />:</td>
<td><h:selectBooleanCheckbox value="#{NewUserWizard.myProp}"/></td>

and changed contentModel.xml:

<property name="cm:myProp">

I don't like this approach because I'd like all the properties of a person to be edited/created in the same transaction, and not having to deal with Faces Navigation issues if one transaction success and the other fails.

I don't like neither changing contentModel.xml nor depending on person-properties.jsp as I'd like to pack this changes into an AMP and installing it on an alfresco.war (with the possibility of upgrading the war!)