Assets returning null

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Assets returning null

1212jrc
Hi all,

I have a document with a Compound Field Link, this is used to link assets that I have previously added in the CMS.

In my bean:

public HippoAssetBean getAsset() {
        return getLinkedBean("myproject:newsDocumentAsset", HippoAssetBean.class);
}


and then in a jsp:

<hst:link var="linka" hippobean="${document.asset}"/>
<a href="${linka}">link to asset


But I got nullPointerException form the method getAsset and the lhst:link result in "".

Any ideas?

Thanks in advance.
Regards,

Javier.



Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Mathijs den Burger
Hi Javier,

Does the document you're rendering indeed have a linked asset?
If so, does the NPE stacktrace provide any clues?

best,
Mathijs


On Wed, Oct 31, 2012 at 3:01 PM, 1212jrc <[hidden email]> wrote:

> Hi all,
>
> I have a document with a *Compound Field Link*, this is used to link assets
> that I have previously added in the CMS.
>
> In my bean:
>
> *public HippoAssetBean getAsset() {
>         return getLinkedBean("myproject:newsDocumentAsset",
> HippoAssetBean.class);
> }*
>
> and then in a jsp:
>
> *<hst:link var="linka" hippobean="${document.asset}"/>
> link to asset <${linka}>  *
>
> But I got nullPointerException form the method getAsset and the lhst:link
> result in "".
>
> Any ideas?
>
> Thanks in advance.
> Regards,
>
> Javier.
>
>
>
>
>
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607.html
> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

1212jrc
Hey, I've figured out to make this work...


public HippoAssetBean getAsset() {
        final String uuid = getProperty("myProject:newsDocumentAsset");
        try {
            final HippoAssetBean bean = (HippoAssetBean) getObjectConverter().getObject(uuid,getNode());
            return bean;
        } catch (ObjectBeanManagerException e) {
            log.error("While getting Asset.",e);
        }
        return null;
    }


I Still don't know why doesn't work in the other way.

Thanks.
Javier.

Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Wouter Danes-2
You're saving a UUID in a property, instead of using a hippo:facetselect node to create a link.
How are you generating these links?
GetLinkedBean() should work when you have a facetselect childnode that links to the asset.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of 1212jrc
Sent: donderdag 1 november 2012 14:29
To: [hidden email]
Subject: Re: [Hippo-cms7-user] Assets returning null

Hey, I've figured out to make this work...


*public HippoAssetBean getAsset() {
        final String uuid = getProperty("myProject:newsDocumentAsset");
        try {
            final HippoAssetBean bean = (HippoAssetBean) getObjectConverter().getObject(uuid,getNode());
            return bean;
        } catch (ObjectBeanManagerException e) {
            log.error("While getting Asset.",e);
        }
        return null;
    }*

I Still don't know why doesn't work in the other way.

Thanks.
Javier.





--
View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579618.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Bert Leunis
In reply to this post by 1212jrc
Hi Javier,

I see one difference in the two versions that may cause the different result:

myproject:newsDocumentAsset

versus

myProject:newsDocumentAsset

The first way you describe is of course much better. You shouldn't need the objectConverter in this case.
 
With kind regards/Met vriendelijke groet,
Bert Leunis

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

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



On Thu, Nov 1, 2012 at 2:29 PM, 1212jrc <[hidden email]> wrote:
Hey, I've figured out to make this work...


*public HippoAssetBean getAsset() {
        final String uuid = getProperty("myProject:newsDocumentAsset");
        try {
            final HippoAssetBean bean = (HippoAssetBean)
getObjectConverter().getObject(uuid,getNode());
            return bean;
        } catch (ObjectBeanManagerException e) {
            log.error("While getting Asset.",e);
        }
        return null;
    }*

I Still don't know why doesn't work in the other way.

Thanks.
Javier.





--
View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579618.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Ard
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Ard
On Thu, Nov 1, 2012 at 3:50 PM, Bert Leunis <[hidden email]> wrote:
> Hi Javier,
>
> I see one difference in the two versions that may cause the different
> result:

Sharp, but I think that must be a 'mail' typo. His setup seems to
indicate he does not use a hippo:mirror but a property that contains a
uuid:

 final String uuid = getProperty("myProject:newsDocumentAsset");

Now, the code he uses is not only a bit different, but also may result
in very unexpected behavior: Namely, fetching a bean through the
canonical node (uuid) results in a bean that is out of the
live|preview context. That can be painful because you might end up
with a preview document in live.

Note that for the 7.8 this won't be the case any more, as there, we
use canonical beans and filter them on ACL basis

Ard

>
> myproject:newsDocumentAsset
>
> versus
>
> myProject:newsDocumentAsset
>
> The first way you describe is of course much better. You shouldn't need the
> objectConverter in this case.
>
> With kind regards/Met vriendelijke groet,
> Bert Leunis
>
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> Boston - 1 Broadway, Cambridge, MA 02142
>
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
> www.onehippo.com
>
>
>
> On Thu, Nov 1, 2012 at 2:29 PM, 1212jrc <[hidden email]> wrote:
>>
>> Hey, I've figured out to make this work...
>>
>>
>> *public HippoAssetBean getAsset() {
>>         final String uuid = getProperty("myProject:newsDocumentAsset");
>>         try {
>>             final HippoAssetBean bean = (HippoAssetBean)
>> getObjectConverter().getObject(uuid,getNode());
>>             return bean;
>>         } catch (ObjectBeanManagerException e) {
>>             log.error("While getting Asset.",e);
>>         }
>>         return null;
>>     }*
>>
>> I Still don't know why doesn't work in the other way.
>>
>> Thanks.
>> Javier.
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579618.html
>> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

1212jrc
Hi, yes it was a typo, sorry about that.
Here is an image if what I am doing.




Thanks,
Javier.
Ard
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Ard
On Fri, Nov 2, 2012 at 3:53 PM, 1212jrc <[hidden email]> wrote:
> Hi, yes it was a typo, sorry about that.
> Here is an image if what I am doing.
>
> <http://hippo.2275632.n2.nabble.com/file/n7579625/Hippo_CMS_7_-_error.png>

Afaics, the getLinkedBean below should just work in your setup. Can
you post the NPE stacktrace?

public HippoAssetBean getAsset() {
        return getLinkedBean("myproject:newsDocumentAsset",
HippoAssetBean.class);

Regards Ard

>
>
> Thanks,
> Javier.
>
>
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579625.html
> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

Jeroen Reijn
Administrator
In reply to this post by 1212jrc
Great. Such a screenshot helps. Could you perhaps also snap a screenshot of a document from the CMS console for which the link does not seem to work?

Thanks,

Jeroen

On Fri, Nov 2, 2012 at 3:53 PM, 1212jrc <[hidden email]> wrote:
Hi, yes it was a typo, sorry about that.
Here is an image if what I am doing.

<http://hippo.2275632.n2.nabble.com/file/n7579625/Hippo_CMS_7_-_error.png>


Thanks,
Javier.




--
View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579625.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

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

http://about.me/jeroenreijn

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Assets returning null

marijan milicevic
Hi all,

I was just wondering: are those beans annotated & registered as described in here:


cheers
marijan


On Mon, Nov 5, 2012 at 11:17 AM, Jeroen Reijn <[hidden email]> wrote:
Great. Such a screenshot helps. Could you perhaps also snap a screenshot of a document from the CMS console for which the link does not seem to work?

Thanks,

Jeroen

On Fri, Nov 2, 2012 at 3:53 PM, 1212jrc <[hidden email]> wrote:
Hi, yes it was a typo, sorry about that.
Here is an image if what I am doing.

<http://hippo.2275632.n2.nabble.com/file/n7579625/Hippo_CMS_7_-_error.png>


Thanks,
Javier.




--
View this message in context: http://hippo.2275632.n2.nabble.com/Assets-returning-null-tp7579607p7579625.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo


Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466" target="_blank">+31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html