Adding custom property to Person/User

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2007 06:52 AM
Hello!
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 http://issues.alfresco.com/browse/AWC-1665, 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"
and added there a new property:
Redefined some methods:
First init():
Then populate():
And finally finish():
Then, I added some code into person-properties.jsp:
and changed contentModel.xml:
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!)
Thanks!
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 http://issues.alfresco.com/browse/AWC-1665, 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"
….<managed-bean> <description> The bean that backs up the New User Wizard </description> <managed-bean-name>NewUserWizard</managed-bean-name> <managed-bean-class>my.custom.UserWizard</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> …..
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():
super.init();this.myProp=false;
Then populate():
super.populate();// set values for edit modeMap<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); tx.begin(); // update the existing node in the repository if(this.editMode){ NodeRef nodeRef = getPerson().getNodeRef(); this.nodeService.setProperty(nodeRef, PROP_MYPROP, this.myProp); }else{ NodeRef person =this.personService.getPerson(this.getUserName()); this.nodeService.setProperty(person, PROP_MYPROP, this.myProp); } // commit the transaction tx.commit(); // reset the richlist component so it rebinds to the users list invalidateUserList(); } catch (Throwable e) { // rollback the transaction try { if (tx != null) { tx.rollback(); } } catch (Exception tex) { } //Treat the error outcome = null; } return outcome; }
Then, I added some code into person-properties.jsp:
<tr><td><h:outputText value="My Prop?" />:</td><td><h:selectBooleanCheckbox value="#{NewUserWizard.myProp}"/></td></tr>
and changed contentModel.xml:
<property name="cm:myProp"> <type>d:boolean</type></property>
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!)
Thanks!
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 05:47 AM
Some of this support has now been added in the latest 2.9B release. There is an expanded Person model and the ability to add custom properties.
Thanks,
Kevin
Thanks,
Kevin
