Custom image set hippo cms 7.8

172 views
Skip to first unread message

arsdee...@incentro.com

unread,
May 15, 2014, 8:19:02 AM5/15/14
to hippo-c...@googlegroups.com

I have created a custom image set by following the documentation:

http://www.onehippo.org/library/concepts/images-and-assets/create-a-custom-image-set.html

 

Completed with no errors, now I have a custom image set with three sets:

1: hippogallery:thumbnail

2: hippogallery:original

3: mycompany:preview (added)


In the CMS it work (three sets), but not on the JSP

 

I have created a Custom Resource Containers. documentation:

http://www.onehippo.org/library/concepts/images-and-assets/custom-resource-containers.html

 

I have created an customResourceContainers.xml in a the Site project folder META-INF/hst-assembly/overrides/


Code customResourceContainers.xml
<?xml version="1.0" encoding="UTF-8"?>
       xsi:schemaLocation="http://www.springframework.org/schema/beans
>
 
    <bean id="customResourceContainers"
          class="org.springframework.beans.factory.config.ListFactoryBean">
        <property name="sourceList">
            <list>
                <bean class=
                     "nl.mycompany.image.set.linking.MyGalleryResourceContainer">
                    <property name="primaryItem" value="hippogallery:original"/>
                    <property name="mappings">
                        <bean class=
                     "org.springframework.beans.factory.config.MapFactoryBean">
                            <property name="sourceMap">
                                <map key-type=
                              "java.lang.String" value-type="java.lang.String">
                                    <entry key="hippogallery:thumbnail"
                                           value="thumbnail"/>
                                    <entry key="mycompany:preview" value="preview"/>
                                </map>
                            </property>
                        </bean>
                    </property>
                </bean>
            </list>
        </property>
    </bean>
</beans>


Code MyGalleryResourceContainer.java
public class MyGalleryResourceContainer extends AbstractResourceContainer {

    @Override
    public String getNodeType() {
        return "mycompany:myimageset";
    }
}

If I upload a new image in the cms I get the image in three sets.

In the JSP:

<c:choose>

              <c:when test="${hst:isReadable(document, 'officeImage.thumbnail')}">

                            <hst:link var="img" hippobean="${document.officeImage.thumbnail}" />

                                           <img src="${img}" title="${fn:escapeXml(document.officeImage.fileName)}" />

              </c:when>

              <c:otherwise>

                            no image

              </c:otherwise>

</c:choose>      

 

Result JSP

1: new image with tree sets: no image

2: old image with two sets: thumbnail image

 

What do I miss or what do I do wrong?

 

Hope te see comments.




Leo G

unread,
May 15, 2014, 12:08:04 PM5/15/14
to hippo-c...@googlegroups.com, arsdee...@incentro.com
Have you defined a bean related to your new image set?

@Node(jcrType = "mycompany:myimageset")
public class MyCompanyImageSetBean extends HippoGalleryImageSet {

   
public HippoResourceBean getPreview() {
       
return getBean("mycompany:preview");
   
}
}

And then the bean of your document would have this method:
public MyCompanyImageSetBean getOfficeImage() {
       
return getLinkedBean("yourcompany:officeimage", MyCompanyImageSetBean.class);
 
}

Arsdeep Singh

unread,
May 15, 2014, 3:34:25 PM5/15/14
to hippo-c...@googlegroups.com

Leo,

 

Thanks for you quick response.

I did not had this code (was not in the documentation), I added and tested it but it does not fix the problem.

I personally think there is something wrong in the customResourceContainers.xml file.





--
*** The 2014 Hippo GetTogether will take place on May 16 in Amsterdam, register at http://hgt14.onehippo.org ***
 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/t6MuwHdzmSA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Arsdeep Singh
Consultant | Incentro Amsterdam

Hessenbergweg 109-119
1101 BS Amsterdam


E: arsdee...@incentro.com
T: +31204090444
M: +31621257791
W: www.incentro.com

Logo Incentro
Logo Incentro

Leo G

unread,
May 16, 2014, 11:17:55 AM5/16/14
to hippo-c...@googlegroups.com, arsdee...@incentro.com
I may be wrong, but for me the resource container configuration is only here to make the url to download the images "more beautiful " (eg. /binaries/preview/content...)

yes indeed this is not in the documentation, I think they should add it since it is pretty important if you want to use  the new image set in your own beans. as far as i know, this is the way it is done inside the demo project GO GREEN and I think I also took the code from there.

I persist to think that the problem might come from the bean initialization. Maybe you should check if the bean in the jsp is null when you specify an image from your new image set, or use the debug mode with a breakpoint on the Bean class

Cheers
Leo

arsdeep.singh

unread,
May 20, 2014, 3:14:52 AM5/20/14
to hippo-c...@googlegroups.com, hippo-c...@googlegroups.com

I tested something.

I added an image in the rich editor text an used the next code:

 

<hst:html hippohtml="${document.textBanner}">

      <hst:imagevariant name="mycompany:preview"/>

</hst:html>

 

This worked I got  the preview image.

Still not as a single image of the type MyCompanyImageSetBean.


Op vrijdag 16 mei 2014 17:17:55 UTC+2 schreef Leo G:

Stephan Westen

unread,
May 20, 2014, 3:18:31 AM5/20/14
to hippo-c...@googlegroups.com, arsdee...@incentro.com
On Fri, May 16, 2014 at 5:17 PM, Leo G <leo.ge...@gmail.com> wrote:
I may be wrong, but for me the resource container configuration is only here to make the url to download the images "more beautiful " (eg. /binaries/preview/content...)

yes indeed this is not in the documentation, I think they should add it since it is pretty important if you want to use  the new image set in your own beans.

If you want us (Hippo) to improve the documentation, please create a Jira issue.

thanks,

Stephan

 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.



--
thanks,

Stephan

Jeroen Reijn

unread,
May 20, 2014, 4:08:34 AM5/20/14
to hippo-c...@googlegroups.com
Hi,

if you get the imagevariant this will not be of your type. 
The  MyCompanyImageSetBean is a representation of the imageset itself and not of a single image. 
The mycompany:preview is a single image and probably of type hippogallery:image.

Cheers,

Jeroen


--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.



--
Jeroen Reijn
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn

Arsdeep Singh

unread,
May 20, 2014, 4:28:38 AM5/20/14
to hippo-c...@googlegroups.com

Hey Jeroen,

 

I know what you have said, I mean something else.

In my previous posts I explained it.

 

I want to have the ‘preview’ image of the MyCompanyImageSetBean (original, thumbnail and preview )

 

I tried this with the next code:

<c:choose>

              <c:when test="${hst:isReadable(document, 'officeImage.preview')}">

                            <hst:link var="img" hippobean="${document.officeImage.preview'}" />

                                           <img src="${img}" />

              </c:when>

              <c:otherwise>

                            no image

              </c:otherwise>

</c:choose>

 

 

I get a result in the jsp: ‘no image’.

 

 

So I find it is weird it does work with:

<hst:html hippohtml="${document.textBanner}">

      <hst:imagevariant name="mycompany:preview"/>

</hst:html>

 

But not in the jsp as an object of MyCompanyImageSetBean.


Cheers,

Arsdeep 

arsdeep.singh

unread,
May 21, 2014, 3:32:52 AM5/21/14
to hippo-c...@googlegroups.com

I went in the debug mode and I found that then bean in not null but the attribute of the object type MycompanyImageSetBean is null, but I don't know why.

Does someone have any idea?


In the bean I use:

    public MycompanyImageSetBean getTestImage() {       

        return getLinkedBean("mycompany:imagelink", MycompanyImageSetBean .class);

    }

 

Cheers,

Arsdeep


Op dinsdag 20 mei 2014 10:28:38 UTC+2 schreef arsdeep.singh:
To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
--
Jeroen Reijn
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Mathijs den Burger

unread,
May 21, 2014, 4:01:22 AM5/21/14
to hippo-c...@googlegroups.com
Hi Arsdeep,

Two things come to mind:

1. is the JCR type in the @Node annotation of your bean correct? (e.g.
no typos in the 'jcrType' value?)
2. is the package of MycompanyImageSetBean scanned by the HST for
beans? In your site's web.xml file, the package should be added to the
'hst-beans-annotated-classes' parameter, e.g.:

<context-param>
<param-name>hst-beans-annotated-classes</param-name>
<param-value>classpath*:org/onehippo/cms7/hst/**/*.class
,classpath*:org/onehippo/**/*.class
,classpath*:com/onehippo/**/*.class
,classpath*:com/mycompany/**/*.class
</param-value>
</context-param>

best,
Mathijs


On Wed, May 21, 2014 at 9:32 AM, arsdeep.singh
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Hippo Community" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to hippo-communi...@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/hippo-community.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>>
>>> --
>>> Jeroen Reijn
>>> Hippo
>>>
>>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>>> Boston - 101 Main Street, Cambridge, MA 02142
>>>
>>> US +1 877 414 4776 (toll free)
>>> Europe +31(0)20 522 4466
>>> www.onehippo.com
>>>
>>> http://about.me/jeroenreijn
>>>
>>> --
>>> Hippo Community Group: The place for all discussions and announcements
>>> about Hippo CMS (and HST, repository etc. etc.)
>>>
>>> You received this message because you are subscribed to the Google Groups
>>> "Hippo Community" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to hippo-communi...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/hippo-community.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Arsdeep Singh

unread,
May 21, 2014, 4:16:25 AM5/21/14
to hippo-c...@googlegroups.com
Hi Mathijs,

thanks a lot man I had not added it in the web.xml it did not know that (not in the documentation).
Seriously the documentation should be improved.
 
Again thanks.
 
You are the only one that came with this solution.

Cheers,
Arsdeep

Mathijs den Burger

unread,
May 21, 2014, 4:40:41 AM5/21/14
to hippo-c...@googlegroups.com
On Wed, May 21, 2014 at 10:16 AM, Arsdeep Singh
<arsdee...@incentro.com> wrote:
> Hi Mathijs,
>
> thanks a lot man I had not added it in the web.xml it did not know that (not
> in the documentation).

Good to hear you got it working!

Note that there *is* a documentation page about bean scanning:

http://www.onehippo.org/library/concepts/web-application/automatic-scanning-for-content-bean-annotated-classes.html

But the general problem is that it's sometimes hard to find the right
page or know all the required steps. I'll add a link to the bean scanning
page to the page about custom resource containers.

Still, when you create a new project using the archetype, the custom
Java package name provided there is added to the bean scanning
configuration automatically. I wonder why that has not worked in your
case. Have you changed your package later on? Did you not start with
the archetype? Or have you spread your code over multiple packages?

best,
Mathijs

Arsdeep Singh

unread,
May 21, 2014, 4:47:13 AM5/21/14
to hippo-c...@googlegroups.com

The bean package was added automatically in the web.xml

I used a different package for the custom image set.




--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)

To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/t6MuwHdzmSA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Mathijs den Burger

unread,
May 21, 2014, 6:13:16 AM5/21/14
to hippo-c...@googlegroups.com
On Wed, May 21, 2014 at 10:47 AM, Arsdeep Singh <arsdee...@incentro.com> wrote:

The bean package was added automatically in the web.xml

I used a different package for the custom image set.


OK, that explains. I've updated the page on custom image sets [1] and included the bean example and a warning about checking the HST bean scanning configuration. I also simplified some steps (e.g. since 7.8 the primary type of the imageset's prototype can be edited directly in the console). Hopefully creating a custom image set has become slightly easier.

Last note: in 7.9 you can also use Hippo Essentials [2] to add custom image variants with only a few clicks.

best,
Mathijs



Reply all
Reply to author
Forward
0 new messages