customModel.xml - how to read custom aspect data at run-time
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2007 06:34 AM
I have created a custom aspect (Thumbnail aspect) which gets a path as a parameter.
the problem: I want to read the parameter that the user added (the thumbnail path) at runtime.
(I'm trying to show the thumb icon instead of the built-in icons)
At BrowseBean.java class - "getContent" method returns a List of "Node". i can see that the aspect I've added is a part of the "aspects" collection that "Node" contains, but still…. i can't find a way to get that thumbnailAspect's value…. :evil:
any ideas ? ? ? :idea:
:?:
<aspect name="custom:ThumbnailAspect"> <title>Thumbnail Aspect</title> <associations> <association name="custom:Thumbnail"> <title>Thumbnail</title> <source> <many>true</many> </source> <target> <class>cm:content</class> <mandatory>false</mandatory> <many>false</many> </target> </association> </associations> </aspect>
the whole thing works fine, and i can add an aspect to spaces & contents.the problem: I want to read the parameter that the user added (the thumbnail path) at runtime.
(I'm trying to show the thumb icon instead of the built-in icons)
At BrowseBean.java class - "getContent" method returns a List of "Node". i can see that the aspect I've added is a part of the "aspects" collection that "Node" contains, but still…. i can't find a way to get that thumbnailAspect's value…. :evil:
any ideas ? ? ? :idea:
:?:
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 12:37 PM
? ? ?
anyone?
? ? ?
anyone?
? ? ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2007 03:21 AM
You have defined the thumbnail as an association. This means in order to return the value you need to call the getTargetAssocs() method on the NodeService.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2007 06:02 AM
first of all, thanks for your reply!
I've tried using the method u advised me to, but all i get is an empty array or an array with nulls…
I'm probably doing something wrong here:
what should i put in getTargetAssocs second parameter? (qnamePattern)
i believe this is the loose link in my code…
By the way, all the changes i do are in the source code of alfresco (rev. 569 from svn)
I've tried using the method u advised me to, but all i get is an empty array or an array with nulls…
I'm probably doing something wrong here:
nodeService.getTargetAssocs(nodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Thumbnail"));( Thumbnail comes from here: <association name="custom:Thumbnail"> )
what should i put in getTargetAssocs second parameter? (qnamePattern)
i believe this is the loose link in my code…
By the way, all the changes i do are in the source code of alfresco (rev. 569 from svn)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2007 11:20 AM
OK, i've found what i was doing wrong… i sent the wrong name-space as a parameter. (since i am using customModel.xml to create my aspect, the uri i should use is "custom.model".
now this part works, and now i have problems at the next level:
since i want to show a thumbnail, in the jsp file i do this:
the next step was to add this code to setupCommonBindingProperties method (in BrowseBean.java) :
and then to create a nested class (resolverThumbnail) inside BrowseBean.java (so that the var "r" would know what is "thumbnail"):
so now, #{r.thumbnail} gets the returned value from ref.get(0).getTargetRef();
the returned value i get is this:
but i still get an error, since the image attribute doesn't know how to handle this…
how to i deliver the url that i got from the user (as thumbnail aspect) to the "image" attribute? ? ?
:?:
thanks,
Dror
now this part works, and now i have problems at the next level:
since i want to show a thumbnail, in the jsp file i do this:
<a:actionLink id="col11_thumb-act1" value="#{r.name}" href="#{r.url}" target="new" image="#{r.thumbnail}" showLink="false" styleClass="inlineAction"/>
the next step was to add this code to setupCommonBindingProperties method (in BrowseBean.java) :
node.addPropertyResolver("thumbnail", this.resolverThumbnail);
and then to create a nested class (resolverThumbnail) inside BrowseBean.java (so that the var "r" would know what is "thumbnail"):
public NodePropertyResolver resolverThumbnail = new NodePropertyResolver() {
public Object get(Node node) {
NodeRef nodeRef = node.getNodeRef();
List<AssociationRef> ref = new ArrayList<AssociationRef>();
QNamePattern qualifiefName = QName.createQName(NamespaceService.CUSTOM_MODEL, "Thumbnail");
if(nodeService != null)
{
ref = nodeService.getTargetAssocs(nodeRef,qualifiefName);
}
if ( ref!= null){
if ( ref.size() > 0)
{
return ref.get(0).getTargetRef();
}
}
return null;
so now, #{r.thumbnail} gets the returned value from ref.get(0).getTargetRef();
the returned value i get is this:
workspace://SpacesStore/06395321-082e-11dc-beed-3fbcc9294cb8
but i still get an error, since the image attribute doesn't know how to handle this…
how to i deliver the url that i got from the user (as thumbnail aspect) to the "image" attribute? ? ?
:?:
thanks,
Dror
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2007 11:54 AM
I guess i have the answer to the last part of this puzzle…
you have to return this to the "image" attribute:
this generates the needed URL.
i would love to get more suggestions regarding this issue
Thanks,
Dror

you have to return this to the "image" attribute:
return DownloadContentServlet.generateBrowserURL(ref.get(0).getTargetRef(), ref.get(0).getTargetRef().getId());
this generates the needed URL.
i would love to get more suggestions regarding this issue
Thanks,
Dror
