cancel
Showing results for 
Search instead for 
Did you mean: 

properties actionlink (image)

sjeek
Champ in-the-making
Champ in-the-making
Hi,

I would like to add a image to an actionlink, but you can only add a url to the 'image' tag.
Is it possible to add the values for height and width ibn this tag?
10 REPLIES 10

kevinr
Star Contributor
Star Contributor
The actionlink component supports an image through the 'image' attribute. However you are correct that it does not support width/height attributes at present. It would not be hard to add them! Smiley Happy

http://wiki.alfresco.com/wiki/ActionLink

Thanks,

Kevin

sjeek
Champ in-the-making
Champ in-the-making
It would not be hard to add them! Smiley Happy

If I knew where the begin, I would add it with plesure  :wink:
so, if you would help me?  Smiley Happy

kevinr
Star Contributor
Star Contributor
This assumes you know some background on JSF components. If not, I would read up on some tutorials on the web first, but it's not that hard as everything is pretty much there already for you, it's just a matter of editing some existing classes and changing a tag definition file…

1. You need to add the width/height attributes to the actionlink component tag definition, they are added to this file:
\root\projects\web-client\source\web\WEB-INF\alfresco.tld
- look for the "actionLink" tag definition block.

2. Add the width/height attributes to the Tag class that represents the tag:
org.alfresco.web.ui.common.tag.ActionLinkTag
- look for the similar Integer based attributes (e.g. "padding") so get an idea of the pattern to use.

3. Add the width/height attribute to the Component class that represents the JSF component for the actionlink:
- again look for similar integer based attribute such as "padding" to get an idea of the pattern to use. Also make sure you add the new attributes to the saveState() and restoreState() methods.

4. Change the implementation of the renderer class for the actionlink component to use the new attributtes:
org.alfresco.web.ui.common.renderer.ActionLinkRenderer
- there are 2 rendering methods; renderActionLink() and renderMenuAction() - they will both need editing to use the new attributes when they generate the image URL during component rendering. You should be able to find the lines where the image HTML is generated, look for Utils.buildImageTag() calls - there are already overriden versions of this method that take width/height attributes if they are available…

Hope this helps! Smiley Happy

Kevin

sjeek
Champ in-the-making
Champ in-the-making
Hi Kevin,

I added the Height and the width to the code and it worked.

thx

kevinr
Star Contributor
Star Contributor
Nice one! If you are happy to contribute the code (as an attachment to a JIRA task: http://www.alfresco.org/jira will be fine) then we can add it to the HEAD codeline.

Thanks! Smiley Happy

Kevin

sjeek
Champ in-the-making
Champ in-the-making
I'll try to do that one of these days  :wink:

another question about images
I got this: <h:graphicImage value="#{CheckinCheckoutBean.getImage(r.id)}" height="50" width="50" />

But I'm always get the error:
javax.faces.el.ReferenceSyntaxException: Invalid expression: '${CheckinCheckoutBean.getImage(r.id)}'

caused by:
org.apache.commons.el.parser.ParseException: Encountered "(" at line 1, column 31. Was expecting one of: "}" … "." … ">" … "gt" … "<" … "lt" … "==" … "eq" … "<=" … "le" … ">=" … "ge" … "!=" … "ne" … "[" … "+" … "-" … "*" … "/" … "div" … "%" … "mod" … "and" … "&&" … "or" … "||" … "?" …

Can I give the "r.id" allong with the bean methode?
Of is there another way?

In the Bean, I'v got this:

public String getImage(String id) {

      Node node = setupContentDocument(id);

      //retrieve the content reader for this node
      ContentReader reader = getContentService().getReader(node.getNodeRef(),
            ContentModel.PROP_CONTENT);
      String mimetype = reader.getMimetype();

      String url = (String) node.getProperties().get("url");
      String img = (String) node.getProperties().get("fileType32");

      if (MimetypeMap.MIMETYPE_IMAGE_JPEG.equals(mimetype)
            || MimetypeMap.MIMETYPE_IMAGE_GIF.equals(mimetype)
            || MimetypeMap.MIMETYPE_IMAGE_RGB.equals(mimetype)) {

         return url;

      } else {
         return img;
      }
   }

greetings

kevinr
Star Contributor
Star Contributor
No you can't do that. The JSF expression language doesn't allow you to pass parameters to get() methods - as a true Bean getter method does not have any parameters. So you can only do this:
<h:graphicImage value="#{CheckinCheckoutBean.image}" height="50" width="50" />

Note that that "get" part of the method is implicit.

Also note that your method would have the signature of: public String getImage()

Thanks,

Kevin

sjeek
Champ in-the-making
Champ in-the-making
I want to view the thumbnails from the images just above the name and if the file is not a image, i just want to view the filetype image.
But, when i can't give any parameters, i can't compaire it.

I also found the method:

url="#{CheckinCheckoutBean.image ? 'r.url':'r.fileType32'}"

With image: public boolean image()
But I also got errors with that code.

normally, I think, that should do the trick, but it want work over here

grtz

sjeek
Champ in-the-making
Champ in-the-making
Does anyone know how to work with this method?

url="#{CheckinCheckoutBean.image ? 'r.url':'r.fileType32'}"

at least, if it work in jsp…?