1

I was trying to add in one more property in Alfresco Share User Profile page. I did all the thing necessary to add one property to content model and user interface.

Then I saw a debug message

Key "nickName" was not found on instance of org.springframework.extensions.webscripts.ScriptUser Introspection information for the class is: {getJobTitle=public java.lang.String org.springframework.extensions.webscripts.ScriptUser.getJobTitle()..

And the new property value was not shown on the page, My Profile page.

What other thing do I need to add to add one property to "My Profile" page in Alfresco Share ?

Any kind help is appreciated.

zawhtut
  • 8,335
  • 5
  • 52
  • 76

2 Answers2

3

This is to help anyone who have the similar requirement. The following files are needed to change.

org.springframework.extensions.webscripts.ScriptUser.java
org.springframework.extensions.webscripts.connector.User.java
org.springframework.extensions.surf.support.AlfrescoUserFactory.java

userprofile.get.html.ftl
contentModel.xml
zawhtut
  • 8,335
  • 5
  • 52
  • 76
  • Thanks for sharing. Any chance you can provide a more detailed explanation of what's needed? – skuro Feb 10 '12 at 09:25
  • Hacking spring-surf / spring-webscripts classes is a fairly bad idea guys ! Not 100% sure, but iirc, you can use the properties property of org.springframework.extensions.webscripts.ScriptBase to transport custom properties. :) – Andreas Steffan Feb 10 '12 at 17:20
  • @skuro My requirement is limited to add another two text field. So I followed the way "skype" property was defined. – zawhtut Feb 11 '12 at 02:20
  • I did not investigate myself, but coincidentally stepped across https://issues.alfresco.com/jira/browse/ALF-3107 . It seems there is indeed core functionality missing in spring-surf-/webscripts. – Andreas Steffan Feb 12 '12 at 08:05
  • @Andreas_Steffan Thanks for your info Andreas. Seems like the best is yet to come. – zawhtut Feb 21 '12 at 09:39
3

You can add custom properties to the cm:person object and then expose those properties to the Alfresco Share user interface without modifying any of the out-of-the-box Alfresco files. I haven't written up the blog post that accompanies it, but the source code that will eventually go with the write up lives here.

At a high-level, the steps are:

Step 1: Extend org.alfresco.web.site.SlingshotUserFactory with your own Factory class - Override the constructSomeUser method. Follow existing pattern to build your own. - Override saveUser - Wire in the custom user factory through Spring using parent="webframework.factory.base"

Step 2: In share-config-custom, override the defaults, user-factory element with a pointer to the new user factory bean

Step 3: Override Alfresco's profile.js with your own. - Modify onEditProfile to include your custom props

Step 4: Extend org/alfresco/components/profile/userprofile.get.html.ftl with your own that includes fields and labels for your custom properties.

Step 5: Externalize the strings.

I have tried this in Alfresco 3.4.d Community but have not yet tried it in Alfresco 4 Community.

Jeff Potts
  • 10,468
  • 17
  • 40
  • @Jeff_Potts Thank you Jeff. Thanks for sharing good practice. – zawhtut Feb 21 '12 at 09:41
  • I'm trying to make this answer, but I have a problem: http://stackoverflow.com/questions/35865875/servlet-service-for-servlet-spring-surf-dispatcher-servlet-in-context-with-p can anyone help me? – PRVS Mar 10 '16 at 21:43