[INFO] [talledLocalContainer] 06.12.2016 08:45:25 WARN http-nio-8080-exec-1 [AbstractBaseOrderableValve.handleComponentExceptions:299] Component exception(s) found in page request, 'Request{ method='GET', scheme='http', host='localhost:8080', requestURI='/site/_cmsinternal/', queryString='_hn:type=component-rendering&_hn:ref=r3_r1'}'.
[INFO] [talledLocalContainer] 06.12.2016 08:45:25 WARN http-nio-8080-exec-1 [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on com.companyname.web.components.CopySectionComponent : java.lang.ClassCastException: org.hippoecm.hst.content.beans.standard.HippoFolder cannot be cast to com.companyname.web.beans.CopySection
[INFO] [talledLocalContainer] 06.12.2016 08:45:25 WARN http-nio-8080-exec-1 [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on com.companyname.web.components.CopySectionComponent : java.lang.ClassCastException: org.hippoecm.hst.content.beans.standard.HippoFolder cannot be cast to com.companyname.web.beans.CopySection
Being a front-end developer I am struggling on this. Java code for the class below:
package com.companyname.web.components;
import com. companyname.web.beans.CopySection;import com. companyname.web.interfaces.CopySectionParamsInfo;import org.hippoecm.hst.component.support.bean.BaseHstComponent;import org.hippoecm.hst.core.component.HstComponentException;import org.hippoecm.hst.core.component.HstRequest;import org.hippoecm.hst.core.component.HstResponse;import org.hippoecm.hst.core.parameters.ParametersInfo;import org.onehippo.cms7.essentials.components.CommonComponent;
/** * Created by alasdair_macrae on 05/12/16. */
@ParametersInfo(type = CopySectionParamsInfo.class)public class CopySectionComponent extends BaseHstComponent {
@Override public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException { CopySectionParamsInfo info = getComponentParametersInfo(request);
// info may be null if this component has just been dragged in, without setting this value
if (info != null) { CopySection document = (CopySection) CommonComponent.getScopeBean(info.getDocument()); request.setAttribute("document", document); } }}
package com.companyname.web.interfaces;
import org.hippoecm.hst.core.parameters.DocumentLink;import org.hippoecm.hst.core.parameters.Parameter;
/** * Created by alasdair_macrae on 05/12/16. */public interface CopySectionParamsInfo { /*Allows a component that drops WYSIWYG content into a page*/
String DOCUMENT_TYPE = "corecms:copysection"; String DOC_LINK_NAME = "Linked Document"; String DOC_NAME = "document";
@DocumentLink(allowCreation = true, docType = DOCUMENT_TYPE) @Parameter(description = DOC_LINK_NAME, displayName = DOC_LINK_NAME, name = DOC_NAME, required = true) String getDocument();}
Hippo bean code here:
package com.companyname.web.beans;
import org.hippoecm.hst.content.beans.Node;import org.hippoecm.hst.content.beans.standard.HippoHtml;import org.onehippo.cms7.essentials.dashboard.annotations.HippoEssentialsGenerated;
@HippoEssentialsGenerated(internalName = "corecms:copysection")@Node(jcrType = "corecms:copysection")public class CopySection extends BaseDocument { @HippoEssentialsGenerated(internalName = "corecms:copy") public HippoHtml getCopy() { return getHippoHtml("corecms:copy"); }}
if (info != null)
corecms:copysection
--
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.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.
Hi,
On Tue, Dec 6, 2016 at 10:47 AM, 'alasdair009' via Hippo Community <hippo-c...@googlegroups.com> wrote:Hi Bert,Inconvertible types; cannot cast 'java.lang.Strring' to 'com.companyname.web.beans.CopySection'(Sorry front end developer fail I am sure) :(
On Tuesday, December 6, 2016 at 9:36:58 AM UTC, Bert Leunis wrote:On Tue, Dec 6, 2016 at 9:56 AM, 'alasdair009' via Hippo Community <hippo-c...@googlegroups.com> wrote:if (info != null)If you change this line to the one below you will get rid of the exception. The "document" that is configured turns out to be a folder and not a CopySection or: node of typecorecms:copysection
if (info !=null && info.getDocument() instance of CopySection)I guess typesafe version should be used here:CopySection document = getHippoBeanForPath(info.getDocument(), CopySection.class);request.setAttribute("document", document);I don't think null check for info variable is actually neededcheersmarijan
--
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.